Cross Reference Table in Rmd

I have an Rmd file with latex output. I have a chunk with a hard coded table which has bibliographic references. Everything is fine so far but I'm having trouble cross-referencing that table.


---
title: "title"
subtitle: "(Draft 0)"
output: 
  bookdown::pdf_document2:
    template: NULL
    keep_tex: true
    latex_engine: pdflatex
---

Table \@ref(tab:zifs). 

```{r zifs, echo = FALSE}
a <- "|A | B | C | D |  E | F | Ref |
|:----|:----|:----|:----|:----|:----|:----|
|1 | 5.97511 | 7.23545 | 0.805990 | 4.479583 | 3.319186 | [@tian07] |
|2 | 1.56906 | 4.57554 | 1.449669 | 4.381400 | 1.892099 | [@bennett11] |
|3 | 14.09481 | 15.41630 | 0.748046 | 4.310632 | 2.701110 | [@Zeite] |
|4 | 2.34114 | 4.20920 | 1.277318 | 4.544959 | 6.075565 | [@schroder13] |

: Table caption goes here"

r a


Instead I get:
Warning: LaTeX Warning: Reference `tab:zifs' on page 12 undefined on input line 370.

I can use kable but I can't get it to render the citations.

Can anyone help?

Is this what you tried to do?


---
title: "title"
subtitle: "(Draft 0)"
output: 
  bookdown::pdf_document2:
  template: NULL
  keep_tex: true
  latex_engine: pdflatex
---
  
  Table \@ref(tab:zifs). 

```{r zifs, echo = FALSE}
a <- "|A | B | C | D |  E | F | Ref |
|:----|:----|:----|:----|:----|:----|:----|
|1 | 5.97511 | 7.23545 | 0.805990 | 4.479583 | 3.319186 | [@tian07] |
|2 | 1.56906 | 4.57554 | 1.449669 | 4.381400 | 1.892099 | [@bennett11] |
|3 | 14.09481 | 15.41630 | 0.748046 | 4.310632 | 2.701110 | [@Zeite] |
|4 | 2.34114 | 4.20920 | 1.277318 | 4.544959 | 6.075565 | [@schroder13] |

: \\label{tab:zifs} Table caption goes here"
``` 

`r a`
1 Like

Allow me to wipe the tear in my eye and say yes!!!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.