-
Notifications
You must be signed in to change notification settings - Fork 323
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 divs for pdf format cause LaTeX error #4142
Comments
Thanks for the report. Ideally, we'd be more robust in these situations. But I'm wondering if the syntax we recommend in the docs isn't working for you for some reason. |
Hi, yeah. The standard syntax works: ![Caption here](quarto.png){#fig-quarto fig-align="center" width="2in"} But, when the caption gets longer, it gets a little unwieldy, especially when you want to include text formatting. I suppose you can do this: ![
This is a __long__ caption with _formatting_.
](quarto.png){fig-align="center" width="2in"} though the Pandoc div is still easier to read (mainly because you reference the image before the caption, but it can also handle empty lines, too). I guess that's a minor, somewhat nitpicky point, but it's worth noting that the div syntax works as expected for html, so it seems like it should in the pdf case, too. Or, maybe it should? I would defer to you all on this one. |
Eventually we would like to fix things like these, but the fact that this works for HTML is (more or less) a happy accident. The spurious extra div doesn't hurt HTML, but creates a bad scaffolding in .tex that causes the error you're seeing. Leaving this one for the future (it might shake out of some of the changes we're making) but to be honest, there are other matters in the quarto codebase we will want to attend to first. |
For now (Quarto 1.3.433), you can use div for single image for pdf and long caption in this way:
In fact, the error is caused by the |
Thanks for the addition ! This is definitely the issue as we are in that case creating two I believe the issue is in that we are processing twice the figure first as a quarto-cli/src/resources/filters/layout/figures.lua Lines 6 to 41 in 9c2bcc2
When For each we are creating the logic \begin{figure}
{\centering And nesting this structure is I think not allowed in LaTeX. We should not process the same when extended figures are inside Div IMO. At least in LaTeX. |
This behaves better in the new crossref work, FYI. Keep an eye out for #4944. |
Just to add to this, I found the same error message when I added |
Hi, the problem happens with subfigures as well. The following snippet can also reproduce the problem with PDF output:
|
For information and help with the issue solution, we can use Figures and Subfigures in latex. The latex output would be something like this: \begin{figure}
\centering
\begin{subfigure}[b]{\linewidth}
\centering
\includegraphics[width=\linewidth]{a.png}
\caption{}\label{fig:a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{\linewidth}
\vspace{0.75cm}
\centering
\includegraphics[width=\linewidth]{b.png}
\caption{}\label{fig:b}
\end{subfigure}
\hfill
\caption{}\label{fig:ab}
\end{figure} |
@felipecrp this does work when I try latest 1.4 ---
title: "Untitled"
format: pdf
---
::: {#fig-basic}
![Caption for a](surus.png){#fig-basic-a}
![Caption for b](surus.png){#fig-basic-b}
Caption for fig
:::
The LaTeX produced is \begin{figure}
\centering{
\centering{
\includegraphics{surus.png}
}
\subcaption{\label{fig-basic-a}Caption for a}
\centering{
\includegraphics{surus.png}
}
\subcaption{\label{fig-basic-b}Caption for b}
}
\caption{\label{fig-basic}Caption for fig}
\end{figure}%
Please to open a new issue if you have a new issue related to subfigures, and share a reproducible example. This issue was about ---
title: "Untitled"
format: pdf
keep-tex: true
---
::: {#fig-basic}
![](surus.png){fig-align='center' width="2in"}
Caption for fig
::: @cscheid was there anything specific or has this been fixed by the work on Figures for 1.4 ? |
It looks fixed to me. If we can get a new reprex for a specific use case, then we should open a new issue. I'm going to go ahead and close. |
Bug description
Sorry if this has already been reported. I did a quick search to check, but didn't see anything...
It looks like Pandoc's div blocks for figures, under certain conditions, generate the LaTeX error - Not in outer par mode.
Here's an example:
Here's what I think is the relevant Quarto output during render:
A few things to note:
::: {#fig-quarto fig-align="center" width="2in"}
, the document renders but the figure options are ignored. Is this expected behavior?Here's my system info:
Checklist
The text was updated successfully, but these errors were encountered: