knitr 中的短标题 fig.scap 不起作用? [英] Short caption fig.scap in knitr not working?

查看:12
本文介绍了knitr 中的短标题 fig.scap 不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道使用 fig.scap 应该提供一个短标签以与图表一起使用,但事实并非如此,它使用的是长标签.有任何想法吗?Rstudio 版本 0.98.1091.

I understood that using fig.scap should provide a short label for use with the table of figures, but it doesn't, it uses the long label. Any ideas? Rstudio Version 0.98.1091.

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

listoffigures


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

推荐答案

这个选项最初是为.Rnw 文件设计的.它不适用于 .Rmd 文件.但是,您可以通过指定任何块选项 out.widthout.heightfig.align.例如,

This option was originally designed for .Rnw documents only. It does not apply to .Rmd documents. However, you can trigger LaTeX output for plots in R Markdown by specifying any of the chunk options out.width, out.height, and fig.align. For example,

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

listoffigures


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

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

Note you need knitr >= 1.8 (currently on CRAN) and Pandoc >= 1.13.1 (see comments below). The YAML metadata graphics: yes makes sure Pandoc is aware of graphics output in the document (it is too technical to explain here).

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

Update: With knitr >= v1.26.4, no special treatment (such as fig.align = 'center') is needed; using fig.scap will generate the correct LaTeX output. Since someone else has asked the same question again, I just decided to fix the issue on Github, and you will need

remotes::install_github('yihui/knitr')

这篇关于knitr 中的短标题 fig.scap 不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆