我最近開始爲區塊標籤添加前綴以幫助識別預期輸出;即對於曲線的「繪圖」,對於表格的「tbl」等。使用「plot」或「plt」前綴塊區標籤可修改數字標題
今天早上我試圖給圖表添加一個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.")
```