编织机中的短标题fig.scap无法正常工作? [英] Short caption fig.scap in knitr not working?

查看:78
本文介绍了编织机中的短标题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来触发R Markdown中的图的LaTeX输出.例如,

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')

这篇关于编织机中的短标题fig.scap无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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