Broken table references in Rmarkdown when figure references work

21 Views Asked by At

I am using rmarkdown to generate a scientific paper in PDF format. I am using R 4.3.1 and the latest version of Rstudio on Linux. Obviously, I have Tinytex, rmarkdown, knitr, and all the relevant packages loaded.

I am successfully generating a PDF file using pdf_document2 output. References to figures resolve perfectly, while those for tables are not working, displaying ?? instead. Here is what the output looks like: enter image description here

I believe I am using the correct syntax the references. Here is the source for the above snippet of text:

Table \@ref(tab:Floor-Model) and Figures \@ref(fig:Floor-Model-Pre-Marg-fx) and \@ref(fig:Floor-Model-Final-Marg-fx) show the results.

And I believe I am using the correct code chunk labels. Here is the first line of the table code chunk that doesn't reference properly:

```{r Floor-Model, echo=FALSE, message=FALSE, warning=FALSE, out.height="40%"}

And here is the first line of the figure code chunk that does reference correctly:

```{r Floor-Model-Pre-Marg-fx, echo=FALSE, message=FALSE, warning=FALSE, out.height="40%"}

So I'm mystified why the references to figures are working just fine, but not those for tables. Any ideas?

0

There are 0 best solutions below