使用 "plot" 或 "plt" 前缀块标签修改图形标题
Prefixing chunk label with "plot" or "plt" modifies figure caption
我最近开始为块标签添加前缀以帮助我确定预期的输出;即,"plot" 表示情节,"tbl" 表示 table,等等
今天早上我试图在情节中添加 fig.cap。标题将无法正确显示;它看起来像这样:
(#fig:plt_cars)This caption will not display correctly.
我希望这样:
Figure 1: This caption will display correctly.
经过反复试验,我发现添加 "plot" 或 "plt" 作为块标签的前缀会导致此问题。
以下示例对此进行了演示。
---
title: Test Post
author: Tim Trice
date: '2017-10-14'
slug: test-post
categories: []
tags: []
---
```{r}
library(ggplot2)
```
```{r}
data(cars)
```
```{r cars, fig.cap = "This caption will display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
```{r plt_cars, fig.cap = "This caption will not display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
```{r plot_cars, fig.cap = "Nor will this caption display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
所有字幕都可以在普通 Rmd 文档中正常呈现;但不在 blogdown 中。
我正在使用 blogdown 0.1。
我已经在 Debian 和 Windows 上验证了这一点,但目前只有 R 3.4.0。
谁能告诉我为什么我不能使用这些前缀?
编辑:它不是前缀,而是使用定界符“_”或“.”。
这些例子不起作用:
```{r test_cars, fig.cap = "Nor will this caption display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
```{r test.cars, fig.cap = "Nor will this caption display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
```{r c_a_r_s, fig.cap = "Nor will this caption display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
编辑 2:同样的问题适用于 knitr::kable 个字幕。
```{r tblcars}
kable(cars, caption = "This table caption works.")
```
```{r tbl_cars}
kable(cars, caption = "This table caption does not work.")
```
来自 Appendix A of the blogdown book:
[...] and you need to read Chapter 2 of the bookdown book (Xie 2016) to learn more about these [R Markdown] features.
来自Section 2.4 of the bookdown book:
If you want to cross-reference figures or tables generated from a code chunk, please make sure the chunk label only contains alphanumeric characters (a-z
, A-Z
, 0-9
), slashes (/
), or dashes (-
).
如果您想对数字进行编号或交叉引用,则不支持下划线。
我最近开始为块标签添加前缀以帮助我确定预期的输出;即,"plot" 表示情节,"tbl" 表示 table,等等
今天早上我试图在情节中添加 fig.cap。标题将无法正确显示;它看起来像这样:
(#fig:plt_cars)This caption will not display correctly.
我希望这样:
Figure 1: This caption will display correctly.
经过反复试验,我发现添加 "plot" 或 "plt" 作为块标签的前缀会导致此问题。
以下示例对此进行了演示。
---
title: Test Post
author: Tim Trice
date: '2017-10-14'
slug: test-post
categories: []
tags: []
---
```{r}
library(ggplot2)
```
```{r}
data(cars)
```
```{r cars, fig.cap = "This caption will display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
```{r plt_cars, fig.cap = "This caption will not display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
```{r plot_cars, fig.cap = "Nor will this caption display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
所有字幕都可以在普通 Rmd 文档中正常呈现;但不在 blogdown 中。
我正在使用 blogdown 0.1。
我已经在 Debian 和 Windows 上验证了这一点,但目前只有 R 3.4.0。
谁能告诉我为什么我不能使用这些前缀?
编辑:它不是前缀,而是使用定界符“_”或“.”。
这些例子不起作用:
```{r test_cars, fig.cap = "Nor will this caption display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
```{r test.cars, fig.cap = "Nor will this caption display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
```{r c_a_r_s, fig.cap = "Nor will this caption display correctly."}
ggplot(cars, aes(x = speed, y = dist)) + geom_point()
```
编辑 2:同样的问题适用于 knitr::kable 个字幕。
```{r tblcars}
kable(cars, caption = "This table caption works.")
```
```{r tbl_cars}
kable(cars, caption = "This table caption does not work.")
```
来自 Appendix A of the blogdown book:
[...] and you need to read Chapter 2 of the bookdown book (Xie 2016) to learn more about these [R Markdown] features.
来自Section 2.4 of the bookdown book:
If you want to cross-reference figures or tables generated from a code chunk, please make sure the chunk label only contains alphanumeric characters (
a-z
,A-Z
,0-9
), slashes (/
), or dashes (-
).
如果您想对数字进行编号或交叉引用,则不支持下划线。