Disable automatic name and table number in .Rmd file using xtable or knitr :: kable

I would like to name my tables without automatic table 1: ... when using xtable or knitr :: kable in a .Rmd file. Conclusion is a pdf document.

Here's a reproducible example from a .Rmd file:

---
title: "Suppress automatic table name and number"
output: pdf_document
---

```{r myirischunk, results = 'asis', tab.cap = NULL, echo = TRUE}
library(xtable)

print(knitr::kable(head(iris), caption = "I sure wish it would say Table    1.a"))
print(knitr::kable(head(iris), caption = "Please stop"))
print(xtable(head(iris), caption = "Same thing with xtable"))
```

I saw similar questions with some suggestions here:

https://tex.stackexchange.com/questions/140645/selectively-suppress-caption-numbering-when-using-xtable

But I can not get it to work in the .Rmd file.

+4
source share
2 answers

Turns out I need to add the following to the YAML section:

header-includes:
    - \usepackage{caption}

And somewhere in front of the code snippet:

\captionsetup[table]{labelformat=empty}

Now it works:

---
title: "Suppress automatic table name and number"
output: pdf_document
header-includes:
    - \usepackage{caption}
---

\captionsetup[table]{labelformat=empty}

```{r myirischunk, results = 'asis', tab.cap = NULL, echo = TRUE}
print(knitr::kable(head(iris), caption = "Table 21.a - My very own table name"))
```

It is also described here:

Get rid of captions using texreg in markdowns

, , .

, daroczig , tex , , chunk - .

+6

, 123apd

---
title: "Suppress automatic table name and number"
output: pdf_document
header-includes:
    - \usepackage[labelformat=empty]{caption}
---

\captionsetup{}.

+2

All Articles