【发布时间】:2015-09-19 20:09:18
【问题描述】:
当在 .Rmd 文件中使用 xtable() 或 knitr::kable() 时,我想从 R 脚本中命名我的表,而不使用自动 Table 1:... 前缀。输出为 pdf 文档。
这是一个来自 .Rmd 文件的可重现示例:
---
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"))
```
我在here 看到了一些类似的问题,但我似乎无法让它在 .Rmd 文件中工作。
【问题讨论】:
-
IMO 这不是一个 R,而是一个 LaTeX 问题,可以在序言中回答类似
\captionsetup{labelformat=empty}的问题。 -
好的,但是如何将它包含在 .Rmd 文件中?在 YAML 标头中?
-
@daroczig 感谢您的提示。我一直在搞乱诸如 fig.lp = '' 之类的块设置以及您提到的来源中的其他内容。以及在 YAML 部分尝试不同的东西,但到目前为止没有成功。大多数示例似乎是“纯” LaTeX 示例,而不是应用 LaTeX 函数的针织降价(我什至不知道这是否有意义)。关于如何使用 markdown 将 \captionsetup{labelformat=empty} 压缩到 YAML 部分或块选项中的任何其他建议都是很好的。无论如何,感谢您到目前为止的帮助。
标签: r latex rstudio knitr xtable