quarto-dev / quarto-cli

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

Subfigure Caption and Cross Reference Not in PDF (Reopening #7815) #7818

Closed IULibScholComm closed 11 months ago

IULibScholComm commented 11 months ago

Bug description

Updated description

I made the change that you recommended, but it does not fix the problem, as the main caption and cross reference are still not present in the PDF version (see attached). (Worse, it creates a problem in the HTML version, as the figures are no longer side by side (as intended) but stacked). Through-the-Looking-Glass--I.-Why-Cross-Fertilize-problem2.pdf

Steps to reproduce

::: {#fig-4.1 layout-ncol=2}

![The life cycle of the trematode *Microphallus*](images/fig4-2.jpeg){fig-alt=""}

![Infected female (top) and uninfected female (bottom) of *P. antipodarum*](images/fig4-3.jpg){fig-alt=""}

**Left panel:** the life cycle of the trematode *Microphallus*. The adult worms live in the intestines of waterfowl and wading birds (black stilts). They produce cross-fertilized eggs, which are released into lakes and streams with the bird’s feces. The eggs hatch following ingestion by snails. Infection results in the asexual production of hundreds of cysts (called metacercaria). These cysts "hatch" and mature following ingestion by ducks, thus completing the life cycle. Drawing by Zoe M Dinges. **Right panel:** Infected female (top) and uninfected female (bottom) of *P. antipodarum* (Photo Credit: Gabe Harp). The snails had been removed from their shells. The golden cysts in the infected female (top) are *Microphallus* metacercaria. The white tissue of the uninfected female (bottom) is ovary.     
:::

Expected behavior

The PDF subfigures should have a caption and cross reference number (4.1), as they do in the HTML, EPUB, and DOCX versions. The HTML subfigures should be side by side.

Actual behavior

The PDF subfigures do not have a caption and cross reference number (4.1), despite having them in the HTML, EPUB, and DOCX versions. The HTML subfigures are stacked.

Your environment

Quarto check output

quarto check                                                                                                                                                                                                                    [>] Checking versions of quarto binary dependencies...                                                                        Pandoc version 3.1.1: OK                                                                                                Dart Sass version 1.55.0: OK                                                                                      [>] Checking versions of quarto dependencies......OK                                                                    [>] Checking Quarto installation......OK                                                                                      Version: 1.3.361                                                                                                        Path: C:\Users\amazel\AppData\Local\Programs\Quarto\bin                                                                 CodePage: 1252                                                                                                                                                                                                                            [>] Checking basic markdown render....OK                                                                                                                                                                                                        [>] Checking Python 3 installation....OK                                                                                      Version: 3.11.4                                                                                                         Path: C:/Users/amazel/AppData/Local/Programs/Python/Python311/python.exe                                                Jupyter: 5.5.0                                                                                                          Kernels: ir, python3                                                                                                                                                                                                                      (|) Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may  0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off                                            0.00s - to python to disable frozen modules.                                                                            0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.                  0.00s - Debugger warning: It seems that frozen modules are being used, which may                                        0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off                                            0.00s - to python to disable frozen modules.                                                                            0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.                  [>] Checking Jupyter engine render....OK                                                                                                                                                                                                        [>] Checking R installation...........OK                                                                                      Version: 4.3.0                                                                                                          Path: C:/Users/amazel/AppData/Local/Programs/R/R-4.3.0                                                                  LibPaths:                                                                                                                 - C:/Users/amazel/AppData/Local/R/win-library/4.3                                                                       - C:/Users/amazel/AppData/Local/Programs/R/R-4.3.0/library                                                            knitr: 1.43                                                                                                             rmarkdown: 2.22                                                                                                                                                                                                                           [>] Checking Knitr engine render......OK 
mcanouil commented 11 months ago

I do not think what you used what the suggested code. The following should work as it makes the "figure" a single element.

::: {#fig-4.1}
:::: {layout-ncol=2}
![The life cycle of the trematode *Microphallus*](images/fig4-2.jpeg){fig-alt=""}

![Infected female (top) and uninfected female (bottom) of *P. antipodarum*](images/fig4-3.jpg){fig-alt=""}
::::

**Left panel:** the life cycle of the trematode *Microphallus*. The adult worms live in the intestines of waterfowl and wading birds (black stilts). They produce cross-fertilized eggs, which are released into lakes and streams with the bird’s feces. The eggs hatch following ingestion by snails. Infection results in the asexual production of hundreds of cysts (called metacercaria). These cysts "hatch" and mature following ingestion by ducks, thus completing the life cycle. Drawing by Zoe M Dinges. **Right panel:** Infected female (top) and uninfected female (bottom) of *P. antipodarum* (Photo Credit: Gabe Harp). The snails had been removed from their shells. The golden cysts in the infected female (top) are *Microphallus* metacercaria. The white tissue of the uninfected female (bottom) is ovary.     
:::

Also why creating a new issue instead of continuing and eventually reopening the previous issue? Opening a new issue is not the same as reopening an issue. Now there is two issue to follow up.

IULibScholComm commented 11 months ago

I apologize! I did not know how to reopen an issue, so I created a new one and referenced the closed one. Thank you for helping me.

IULibScholComm commented 11 months ago

I do not think what you used what the suggested code. The following should work as it makes the "figure" a single element.

::: {#fig-4.1}
:::: {layout-ncol=2}
![The life cycle of the trematode *Microphallus*](images/fig4-2.jpeg){fig-alt=""}

![Infected female (top) and uninfected female (bottom) of *P. antipodarum*](images/fig4-3.jpg){fig-alt=""}
::::

**Left panel:** the life cycle of the trematode *Microphallus*. The adult worms live in the intestines of waterfowl and wading birds (black stilts). They produce cross-fertilized eggs, which are released into lakes and streams with the bird’s feces. The eggs hatch following ingestion by snails. Infection results in the asexual production of hundreds of cysts (called metacercaria). These cysts "hatch" and mature following ingestion by ducks, thus completing the life cycle. Drawing by Zoe M Dinges. **Right panel:** Infected female (top) and uninfected female (bottom) of *P. antipodarum* (Photo Credit: Gabe Harp). The snails had been removed from their shells. The golden cysts in the infected female (top) are *Microphallus* metacercaria. The white tissue of the uninfected female (bottom) is ovary.     
:::

Thank you again! This is helpful, but it does not fully solve the issue. In the PDF, the main caption text appears as regular text rather than as a caption, and in the HTML, the images are stacked rather than side by side.

mcanouil commented 11 months ago

Because you did not fill the issue template properly, I have to assume the Quarto version you are using and my guess is you don't use 1.4 pre-release.

Also note that your example is not a reproducible one.

IULibScholComm commented 11 months ago

Yes, my quarto version is 1.3.361, which is stated in the template (Quarto check output)

mcanouil commented 11 months ago

you are not even using the latest stable. And Carlos told you to use the syntax highlighted in the documentation and to use 1.4 pre-release.

It works just fine with 1.4:

HTML PDF
image #4142 & #7017
---
title: "Quarto Playground"
format: html
---

::: {#fig-demo}
:::: {layout-ncol=2}
![A sub caption for A](https://placehold.co/600x400.png)

![A Sub caption for B](https://placehold.co/600x400.png)
::::

A caption
:::
mcanouil commented 11 months ago

I am closing this as there no unknown issue and the syntax was shown.

cscheid commented 11 months ago

@IULibScholComm hi, let me revisit this - does the following syntax not actually solve your issue? We do have to ask you to update to 1.4, because that's where we do the development, but the following should do the trick for you:

---
title: "Quarto Playground"
format: pdf
---

::: {#fig-demo layout-ncol=2}
![A sub caption for A](https://placehold.co/600x400.png)

![A Sub caption for B](https://placehold.co/600x400.png)

A caption
:::

(@mcanouil FYI your suggested syntax with nested divs doesn't actually work in PDF format.)

mcanouil commented 11 months ago

@cscheid the issue is the minipage/figure environment in LaTeX which produces "LaTeX Error: Not in outer par mode.". There is at least the issue I linked and I think this was discussed in another one already. As far as I can tell the HTML version works exactly as it should.

cscheid commented 11 months ago

As far as I can tell the HTML version works exactly as it should.

Do look at the title of this issue. The report is about PDF...

mcanouil commented 11 months ago

Indeed thus the two formats and link to the other issue.

In addition to the title:

(Worse, it creates a problem in the HTML version, as the figures are no longer side by side (as intended) but stacked).

IULibScholComm commented 11 months ago

@IULibScholComm hi, let me revisit this - does the following syntax not actually solve your issue? We do have to ask you to update to 1.4, because that's where we do the development, but the following should do the trick for you:

---
title: "Quarto Playground"
format: pdf
---

::: {#fig-demo layout-ncol=2}
![A sub caption for A](https://placehold.co/600x400.png)

![A Sub caption for B](https://placehold.co/600x400.png)

A caption
:::

(@mcanouil FYI your suggested syntax with nested divs doesn't actually work in PDF format.)

Thank you! Yes, the above fixes my issue. I really appreciate it! (And yes, mcanouil's proposed solution, as you mentioned, caused the pdf to break, unfortunately--I think #4142 is the issue mcanouil mentions. I do need both the HTML and PDF versions to work.)