quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.91k stars 322 forks source link

Long captions exceed the page margins in PDF documents instead of autowrapping to the next page. #10365

Closed pedrohbraga closed 3 months ago

pedrohbraga commented 3 months ago

Bug description

In PDF documents, combining a large or long image with a long caption causes the caption to overlap the page number and exceed the page margins instead of wrapping it to the next page.

It is worth noting that I am building my thesis document with Quarto, and that I am explicitly using lists of figures and tables, which I positioned in accordance with thesis regulations. I am adding the captions for figures and tables within code chunks and cross-referencing them, like in the example below.

image

image

image

Steps to reproduce

To reproduce this issue, one can create any Quarto document (e.g., a book project), and add a figure that occupies a large portion of the page, and include a long caption. An example of this content in the .qmd document follows below:

# Preface {.unnumbered}

This is a Quarto book.

To learn more about Quarto books visit <https://quarto.org/docs/books>.

```{r fig.width= 3, fig.height = 3*6, fig.cap = "And cup in iced cup, single shot lungo, so, sugar viennese, cup siphon, dripper white barista, plunger pot caffeine, sugar espresso, decaffeinated arabica chicory carajillo grinder, qui spoon acerbic irish, mug as coffee sugar breve irish carajillo. Steamed acerbic, grinder, ut skinny arabica rich robust trifecta strong macchiato, dark flavour, strong et trifecta aftertaste siphon that wings acerbic redeye. Irish organic, milk, grounds viennese plunger pot in cup, coffee aftertaste, sweet crema roast sweet, beans, irish, cream, café au lait filter cup, id caffeine variety, foam french press redeye to go so shop sweet aftertaste. Caramelization, wings arabica wings, that to go extraction, brewed cup, frappuccino, flavour chicory, filter cappuccino acerbic bar  white cinnamon white variety barista body doppio. Single origin, con panna latte, cultivar, grounds extraction shop qui black, siphon, ristretto grounds dark id, arabica java coffee eu fair trade cream french press con panna. Black, aftertaste, that aged plunger pot, black filter cup mazagran, doppio half and half, blue mountain at iced, crema, so in latte froth, extraction, grinder doppio fair trade, black, steamed shop bar , chicory cup robust half and half ristretto. Cultivar lungo white to go ristretto arabica steamed et café au lait, shop, latte organic pumpkin spice, breve aged decaffeinated siphon, qui flavour, french press dripper white carajillo frappuccino variety, sit variety spoon aromatic lungo turkish. Plunger pot to go flavour cream, mocha filter, robusta et decaffeinated, qui white chicory, eu irish espresso, mocha kopi-luwak barista est, cinnamon single shot mazagran decaffeinated steamed as affogato. Shop galão sugar extra  aged black roast cup flavour coffee, cinnamon as medium roast robusta, whipped caramelization dark, flavour cappuccino macchiato, brewed organic aged sugar mug blue mountain. Sweet sit caramelization dripper, id, lungo, grounds aromatic, whipped shop cinnamon, black as acerbic, so breve cup, whipped frappuccino, strong, iced to go latte crema cinnamon, and steamed, plunger pot, espresso, caffeine, kopi-luwak lungo bar turkish milk."}

library(ggplot2)

p <- ggplot(mpg, aes(displ, hwy)) + geom_point()

ggplot(economics_long, aes(date, value)) +
  geom_line() +
  facet_wrap(vars(variable),
             scales = "free_y", nrow = 6, strip.position = "top") +
  theme(strip.background = element_blank(), strip.placement = "outside")

For the book YAML, they can be as simple as these ones.

````qmd

project: type: book

book: title: "RepDebuggingErrors" author: "Norah Jones" date: "2024-07-23" chapters:

format: pdf: documentclass: scrreprt

editor: visual

bibliography: references.bib

Expected behavior

I expect the caption to wrap up to the next page without requiring resizing the figure or shortening the caption.

Actual behavior

In PDF documents, combining a large or long image with a long caption causes the caption to exceed the page margins instead of wrapping to the next page.

Your environment

"Cranberry Hibiscus" Daily (008dffc4, 2024-07-10) for windows Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2024.07.0-daily+306 Chrome/124.0.6367.243 Electron/30.1.2 Safari/537.36, Quarto 1.5.54 (C:/Program Files/RStudio/resources/app/bin/quarto/bin/quarto.exe Windows 11

Quarto check output

Quarto 1.5.54
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.5.54
      Path: C:\Program Files\RStudio\resources\app\bin\quarto\bin
      CodePage: 1252

[>] Checking tools....................OK
      TinyTeX: (external install)
      Chromium: (not installed)

[>] Checking LaTeX....................OK
      Using: TinyTex
      Path: C:\Users\phper\AppData\Roaming\TinyTeX\bin\windows\
      Version: 2024

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
      Version: 3.12.2
      Path: C:/Users/phper/AppData/Local/Programs/Python/Python312/python.exe
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with py -m pip install jupyter

[>] Checking R installation...........OK
      Version: 4.3.3
      Path: C:/PROGRA~1/R/R-43~1.3RC
      LibPaths:
        - C:/Users/phper/AppData/Local/R/win-library/4.3
        - C:/Program Files/R/R-4.3.3rc/library
      knitr: 1.47
      rmarkdown: 2.27

[>] Checking Knitr engine render......OK
cscheid commented 3 months ago

There isn't much we can do here. Multipage captions are simply not something that the LaTeX templates we use (through Pandoc) supports. The best you can do is create small-enough images so that the captions fit.