Open aaronrudkin opened 2 months ago
You should not use bare LaTeX code in the middle of Markdown.
See https://quarto.org/docs/authoring/markdown-basics.html#raw-content.
This being said, you should use Quarto cross-reference system instead of overtaking it using LaTeX.
---
title: "Reprex for Italic Table issue"
format: pdf
---
Below I cross-ref @tbl-example
::: {#tbl-example}
```{=latex}
\begin{tabular}{lr}
\tabularnewline \midrule \midrule
Text Here & 123 \\
Text Here & 456 \\
\midrule \midrule
\end{tabular}
Italic A caption goes here :::
Finally, when working with LaTeX and encountering LaTeX error, use `keep-tex: true` in your YAML front matter to investigate the issue.
FYI, this is the same kind of issues as of:
This is being used in a pipeline wherein the LaTeX is being generated programmatically by outside code and included using an include directive e.g. {{< include ../tables/table_goes_here.tex >}}
. The LaTeX appearing in "the middle of Markdown" is an artifact of the reprex. It would be possible to write a shim that wraps the LaTeX output in an additional layer to build markdown around it, but honestly not ideal. I did keep the intermediate TeX file, which generates the TeX in my "Behavior" section and is how I diagnosed that.
It does seem to me like this is a bug with how the cross-ref rewrites the LaTeX table. If it's a wontfix for the same reason as the linked issue, then fine, but I figured I'd report it nonetheless.
but I figured I'd report it nonetheless.
Thanks for that! We do appreciate the report.
If it's a wontfix for the same reason as the linked issue
I can't answer that myself.
Regarding the include, I suggest (which should work and put some safety in parsing the LaTeX code):
```{=latex}
{{< include ../tables/table_goes_here.tex >}}
Quarto 1.4.553
I'll note that this is an old version of Quarto, and it might be worth confirming that the issue persists in 1.5.
@cscheid The code lead to a crash using the latest development version. Same thing as in the other issue. The brackets from the italic command causes the parsing issue in Quarto cross-ref codepath.
\begin{table}
\caption{\label{tbl-example} \textit{Italic}
\centering{
\begin{tabular}{lr}
\tabularnewline \midrule \midrule
Text Here & 123 \\
Text Here & 456 \\
\midrule \midrule
\end{tabular}
A caption goes here}
}
\end{table}%
Bug description
If I attempt to use LaTeX formatting commands (e.g.
\textit{italic text}
) inside a table caption and the table has a cross-ref, the document will not compile. Removing the italic command compiles successfully. I assume this is true of any arbitrary LaTeX comand. The reason this is important is because I want to set arbitrary styling for the caption, and in particular I want to be able to have a "title" in the caption, which I do via italic/bold text.Steps to reproduce
Behavior
When Quarto re-writes the table to hook up the cross-ref, it generates the following invalid intermediate LaTeX which will not compile. You can see that the italic text gets pulled up into the caption, but the stuff following the
}
closing curly brace does not, leaving it stranded under the tabular environment, and causing a compilation error because the caption now wraps all the way around the table.Your environment
Quarto check output