[英]rmarkdown caption numbering/reference work with underscores?
有没有其他人注意到,如果引用使用下划线而不是连字符,则rmarkdown不会对表标题进行编号? 请参见下面的代码段。 或构建此网站以获取有效示例。
---
title: "Table Captioning"
output:
bookdown::html_document2:
number_sections: true
fig_caption: true
---
# Example
It works in table \@ref(tab:dummy-table) when using hypens.
Table: (\#tab:dummy-table) Some caption.
\```{r dummy-table, echo=FALSE}
knitr::kable(data.frame(a = letters[1:3],
b = 1:3))
\```
But not in table \@ref(tab:dummy_table) when using underscores?
Table: (\#tab:dummy_table) Some caption.
\```{r dummy_table, echo=FALSE}
knitr::kable(data.frame(a = letters[4:6],
b = 4:6))
\```
没什么大不了的,只是让我绊了一下。 抱歉,如果将此行为记录在某处,但我错过了。
RMarkdown书中的 2.6节建议,下划线可能会给您带来麻烦:
我强烈建议您在标签中仅使用字母数字字符(az,AZ和0-9)和破折号(-),因为它们不是特殊字符,并且肯定适用于所有输出格式。 特别是其他字符,空格和下划线,可能会在某些包装中引起麻烦,例如书本。
现在,由于在YAML中进行了设置,因此您正在使用bookdown
:
output:
bookdown::html_document2:
您需要bookdown
选项才能使引用首先bookdown
。 默认的rmarkdown html输出为html_document
,不适用于自动引用。 换句话说:R代码块标签中的下划线对您来说是不可行的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.