Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure Caption do not continue in next page #1468

Open
LaureTomas opened this issue May 13, 2024 · 1 comment
Open

Figure Caption do not continue in next page #1468

LaureTomas opened this issue May 13, 2024 · 1 comment
Labels
question general questions - not an issue

Comments

@LaureTomas
Copy link

LaureTomas commented May 13, 2024

I'm writing a book in pdf using bookdown and I'm facing right now a little problem.

I have a figure that fits almost the entire space of the page (B5 format) so when I add the caption to the figure, the caption starts in the same page and it disappears (right picture), it doesn't continue in the next page, and it even exceeds the margin limits. In fact, if I open the rendered PDF with a graphical vector editing software (Inkscape) the full caption is there but outside the page limits (left picture).

image

I've been reading a bit about how LaTex deals with figures and I guess the problem is that the figure by default is a floating element and LaTex tries to place together the figure and the caption, so my question is:

How can I make the figure not to be a floating element so the caption can be placed on the following page using bookdown?

Thank you so much in advance.

I've prepared a minimal example of this behaviour:

Index.rmd file

--- 
title: "A Minimal Book Example"
author: "John Doe"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
geometry:
  - top=20mm
  - left=22mm
  - right=22mm
  - bottom=20mm
fontsize: 11pt
lot: false
lof: false
output: 
  bookdown::pdf_book:
    number_sections: true
    latex_engine: xelatex
papersize: b5
link-citations: yes
description: ""
always_allow_html: yes
---

01-intro.rmd file

# Hello bookdown 

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a rutrum orci, in malesuada eros. Nunc et dignissim velit. Nunc vel nulla ipsum. Praesent ut velit arcu. Pellentesque in faucibus urna. Nam at iaculis augue, eu sagittis ligula. Nullam leo erat, mollis in ullamcorper at, fringilla id neque. Suspendisse ultricies quam sed aliquet suscipit. Vestibulum ac elementum quam, in finibus turpis. Morbi id mi ipsum.

Cras suscipit velit in dui sagittis faucibus. Mauris euismod et odio a mollis. Suspendisse quis fermentum libero, eu cursus lorem. Suspendisse diam risus, ullamcorper ut tellus sit amet, suscipit maximus arcu. Praesent laoreet fermentum nisl, quis tristique risus commodo a. Mauris aliquet in tellus in faucibus. Pellentesque auctor finibus purus, finibus porta risus volutpat vitae.

Cras suscipit arcu felis, non feugiat arcu commodo in. Aenean porttitor, turpis vel hendrerit placerat, ligula nulla tincidunt dolor, quis euismod libero sem sit amet magna. Morbi convallis eget enim nec maximus. Vestibulum finibus est in elit varius, eget bibendum sapien vehicula. Quisque ornare sit amet neque a interdum. Etiam ut venenatis urna, sit amet ornare elit. In pulvinar facilisis eros non egestas. Cras ac feugiat turpis.

Pellentesque at elit sed nulla malesuada sodales. Phasellus tincidunt tristique dapibus. Morbi vel nunc justo. Phasellus at scelerisque sem. Aliquam dictum maximus ex, eleifend blandit tortor cursus a. Duis pellentesque tincidunt finibus. Aliquam pharetra lorem volutpat velit gravida accumsan. Sed facilisis aliquam pretium. Quisque tincidunt, diam vel blandit vestibulum, urna ipsum ornare felis, eget ullamcorper magna odio at velit. Donec quis porta nisi.

Phasellus fringilla enim ac eros suscipit, nec euismod augue luctus. Quisque eget consectetur turpis. Curabitur tempor suscipit tristique. Vestibulum rutrum, libero ut molestie pellentesque, odio ante feugiat mi, ac hendrerit risus erat at dolor. Donec faucibus blandit purus, vitae accumsan metus accumsan sed. Fusce faucibus ornare ex in gravida. Ut.

```{r figure, echo=FALSE, fig.align="center", out.width='\\textwidth', fig.cap="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a rutrum orci, in malesuada eros. Nunc et dignissim velit. Nunc vel nulla ipsum. Praesent ut velit arcu. Pellentesque in faucibus urna. Nam at iaculis augue, eu sagittis ligula. Nullam leo erat, mollis in ullamcorper at, fringilla id neque. Suspendisse ultricies quam sed aliquet suscipit. Vestibulum ac elementum quam, in finibus turpis. Morbi id mi ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a rutrum orci, in malesuada eros. Nunc et dignissim velit. Nunc vel nulla ipsum. Praesent ut velit arcu. Pellentesque in faucibus urna. Nam at iaculis augue, eu sagittis ligula. Nullam leo erat, mollis in ullamcorper at, fringilla id neque. Suspendisse ultricies quam sed aliquet suscipit. Vestibulum ac elementum quam, in finibus turpis. Morbi id mi ipsum."}
download.file(url = "https://images.unsplash.com/photo-1563204996-8965f0a4a860?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&i",
          destfile = "image.jpeg",
          mode = 'wb')
knitr::include_graphics(path = "image.jpeg")

Session Info
xfun::session_info()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 20.04.6 LTS, RStudio 2023.12.1.402

Locale:
  LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=es_ES.UTF-8        LC_COLLATE=en_US.UTF-8    
  LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=es_ES.UTF-8       LC_NAME=C                 
  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C       

Package version:
  base64enc_0.1.3   bookdown_0.39     bslib_0.7.0       cachem_1.0.6      cli_3.6.2         compiler_4.4.0   
  digest_0.6.35     evaluate_0.23     fastmap_1.1.1     fontawesome_0.5.2 fs_1.6.4          glue_1.7.0       
  graphics_4.4.0    grDevices_4.4.0   highr_0.10        htmltools_0.5.8.1 jquerylib_0.1.4   jsonlite_1.8.8   
  knitr_1.46        lifecycle_1.0.4   memoise_2.0.1     methods_4.4.0     mime_0.12         R6_2.5.1         
  rappdirs_0.3.3    rlang_1.1.3       rmarkdown_2.26    rstudioapi_0.16.0 sass_0.4.9        stats_4.4.0      
  tinytex_0.50      tools_4.4.0       utils_4.4.0       xfun_0.43         yaml_2.2.1       
@cderv
Copy link
Collaborator

cderv commented Aug 26, 2024

How can I make the figure not to be a floating element so the caption can be placed on the following page using bookdown?

Did you try this recipe already ?
https://bookdown.org/yihui/rmarkdown-cookbook/figure-placement.html

This seems to be LaTeX problem, and you may have more success for answers at LaTeX forums.
You have a big figures with a long caption, so LaTeX needs to know how to handle that. This is definitely not standard for bookdown nor pandoc.

@cderv cderv added the question general questions - not an issue label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question general questions - not an issue
Projects
None yet
Development

No branches or pull requests

2 participants