短标题 knitr 中的 fig.scap 不起作用?

Ste*_*ell 5 latex r knitr

我知道使用 fig.scap 应该提供一个用于图表的短标签,但它没有,它使用长标签。有任何想法吗?Rstudio 版本 0.98.1091。

---
output:
  pdf_document:
    fig_caption: yes
---

\listoffigures


```{r, fig.cap="long caption",fig.scap="short"}
plot(1:4)
```
Run Code Online (Sandbox Code Playgroud)

Yih*_*Xie 5

此选项最初仅用于 .Rnw 文档。它不适用于 .Rmd 文件。但是,您可以通过指定任意的块选择触发中的R降价地块LaTeX的输出out.widthout.heightfig.align。例如,

---
graphics: yes
output:
  pdf_document:
    fig_caption: yes
---

\listoffigures


```{r, fig.cap="long caption", fig.scap="short", fig.align='center'}
plot(1:4)
```
Run Code Online (Sandbox Code Playgroud)

请注意,您需要 knitr >= 1.8(目前在 CRAN 上)和 Pandoc >= 1.13.1(请参阅下面的评论)。YAML 元数据graphics: yes确保 Pandoc 知道文档中的图形输出(在这里解释太技术性了)。


更新:使用knitr >= v1.26.4,不需要特殊处理(例如fig.align = 'center');usingfig.scap将生成正确的 LaTeX 输出。由于其他人又问了同样的问题,我决定在 Github 上解决这个问题,你需要

---
graphics: yes
output:
  pdf_document:
    fig_caption: yes
---

\listoffigures


```{r, fig.cap="long caption", fig.scap="short", fig.align='center'}
plot(1:4)
```
Run Code Online (Sandbox Code Playgroud)