Quarto cross reference inside caption - pdf

119 Views Asked by At

For some reason cross referencing to e.g. another table within a table-caption works perfectly well when rendering to html, but not when rendering to pdf. As you can see from the output below, @tbl-tab1 in the .md-file, is translated correctly to \ref{tbl-tab1} in the main text in the .tex-file, but remains @tbl-tab1 in the caption.

MWE:

```{r}

tab <- data.frame(A = "A")
```

```{r}
#| label: tbl-tab1
#| tbl-cap: cap 1

kableExtra::kable(tab)
```
An in-text reference to @tbl-tab1

```{r}
#| label: tbl-tab2
#| tbl-cap: This table is identical to @tbl-tab1

kableExtra::kable(tab)
```

(Quarto 1.3)

While in html the caption of the second table reads This table is identical to Table 1, the caption in pdf reads This table is identical to @tbl-tab1

Any thoughts why or how to circumvent this (ideally something that works for html and pdf simultaneously)?

Looking at the intermediate .md-file, and comparing the in-text reference with the in-caption reference, it seems the error is in the conversion from .md to .tex

.md (part):

A in-text reference to @tbl-tab1


::: {#tbl-tab2 .cell tbl-cap='This table is identical to @tbl-tab1'}
::: {.cell-output-display}
\begin{tabular}{l}
\hline
A\\
\hline
A\\
\hline
\end{tabular}
:::
:::

.tex (part):

An in-text reference to Table~\ref{tbl-tab1}

\hypertarget{tbl-tab2}{}
\begin{table}
\caption{\label{tbl-tab2}This table is identical to @tbl-tab1 }\tabularnewline

\centering
\begin{tabular}{l}
\hline
A\\
\hline
A\\
\hline
\end{tabular}
\end{table}
0

There are 0 best solutions below