quarto-dev / quarto-dev/quarto-cli
Compilation error when using italic text in LaTeX table caption
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
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
---
title: "Reprex for Italic Table issue"
format: pdf
---
Below I cross-ref @tbl-example
\begingroup
\centering
\begin{table}
\begin{tabular}{lr}
\tabularnewline \midrule \midrule
Text Here & 123 \\
Text Here & 456 \\
\midrule \midrule
\end{tabular}
\caption{\label{tbl-example} \textit{Italic} A caption goes here}
\end{table}
\par\endgroup
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.
\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}%
Your environment
- IDE RStudio Version 2024.04.0+735 (2024.04.0+735)
- MacOS Sonoma 14.6.1
- R version 4.3.2
Quarto check output
Quarto 1.4.553
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.1.11: OK
Dart Sass version 1.69.5: OK
Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.4.553
Path: /Applications/RStudio.app/Contents/Resources/app/quarto/bin
[✓] Checking tools....................OK
TinyTeX: (not installed)
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Using: Installation From Path
Path: /Library/TeX/texbin
Version: 2024
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.12.4
Path: /opt/homebrew/opt/python@3.12/bin/python3.12
Jupyter: (None)
Jupyter is not available in this Python installation.
Install with python3 -m pip install jupyter
[✓] Checking R installation...........OK
Version: 4.3.2
Path: /Library/Frameworks/R.framework/Resources
LibPaths:
- /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
knitr: 1.45
rmarkdown: 2.25
[✓] Checking Knitr engine render......OK
maja:writing aaron$
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the provided Quarto .qmd reproduction and render it to PDF with the table cross-reference and italic caption. Inspect the generated intermediate LaTeX around the rewritten table caption, then verify that the complete caption remains inside the caption command and the document compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- latex
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100