Table Cross-References in Bookdown with MS-Word Output?

后端 未结 1 549
自闭症患者
自闭症患者 2021-02-06 08:51

How can I make table cross-references work in a bookdown document with all of the output formats pdf, docx, and html? Or maybe more specifically, how can I get table cross-refer

1条回答
  •  情书的邮戳
    2021-02-06 09:42

    Add tab.cap="Your Caption" to the knitr chunk options:

    ```{r, test03, echo = FALSE, eval = !knitr::is_latex_output(), tab.cap="My flextable caption!"}
    mtcars %>%
      head() %>%
      flextable() %>%
      autofit()
    ```
    
    Reference to Table \@ref(tab:test03). 
    

    See here for more table caption options.

    This also adds numbers to tables correctly. If you want your table captions to be in a format designated in your reference document like "Table Caption" or "Caption", you can specify tab.cap.style = "Table Caption".

    0 讨论(0)
提交回复
热议问题