【发布时间】:2017-10-14 16:36:53
【问题描述】:
我最近开始为块标签添加前缀以帮助我识别预期的输出;即,“情节”用于绘图,“tbl”用于表格等。
今天早上,我尝试将 fig.cap 添加到情节中。标题将无法正确显示;它看起来像这样:
(#fig:plt_cars)此标题将无法正确显示。
我希望这样:
图 1:此标题将正确显示。
在玩了之后,我发现将“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 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.")
```
【问题讨论】: