问题
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.
回答1:
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.
回答2:
In case you have an external .tex file for additional formatting (i. e. I made a file for including a logo in the header of each page as described here) you should include \usepackage{caption}
(just this line) in the external .tex file, not in the yaml header of the RMarkdown document.
来源:https://stackoverflow.com/questions/30679537/get-rid-of-captions-when-using-texreg-in-rmarkdown