且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 xtable 或 knitr::kable 抑制 .Rmd 文件中的自动表名称和编号?

更新时间:2023-10-02 22:26:28

原来我需要在YAML部分添加以下内容:

It turns out that I needed to add the following in the YAML section:

header-includes:
    - usepackage{caption}

以及代码块之前的某处:

AND the following somewhere before the code chunk:

captionsetup[table]{labelformat=empty}

现在可以了:

---
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"))
```

这里也有描述:

在markdown中使用texreg去掉字幕

是的,我有点尴尬,我没有立即找到答案.

And yes, I'm a bit embarrased that I didn't find that answer straight away.

无论如何,感谢 daroczig 将我指向 tex 方向,而不是尝试使用块选项或类似的东西来解决问题.

Anyway, thanks to daroczig for pointing me in the tex direction instead of trying to solve the problem using chunk options or something like that.