Search code examples
r-markdowntexreg

get rid of captions when using texreg in Rmarkdown


How do you suppress captions for a texreg table? I'm using Rmarkdown to generate a LaTeX file. Here's a simple example:

```{r, echo=FALSE, message=FALSE, results="asis"}
library(texreg)
data <- data.frame(a=c(1,2,3,4), b=c(6,3,4,4))
texreg(lm(a~b, data=data), caption="", custom.note="", float.pos="h!")
```

The table I get has a caption on the bottom that says "Table 1:". How do I get rid of it? Thanks.


Solution

  • In the YAML section where LaTeX packages can be included, add the caption package:

    header-includes:
        - \usepackage{caption}
    

    Then at the beginning of the RMarkdown document body add:

    \captionsetup[table]{labelformat=empty}
    

    This removes the caption labels for all tables.