get rid of captions when using texreg in Rmarkdown

大城市里の小女人 提交于 2019-12-22 18:11:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!