我想让 R Markdown 文档中所有标题(图形和表格)的字体大小变小。我正在使用bookdown。最终输出是 pdf,我在 R Studio 中工作。要加载图片,我使用 include_graphics
函数来自 knitr
,因为有人告诉我这是最好的方法(请参阅 here )。
我只发现了完全相同的问题,但对于 html 输出 here
一个例子 .rmd
:
---
output: pdf_document
---
Normal text has the same size as the captions.
```{r, echo = FALSE, out.width = '50%', fig.cap = "The caption has the same size as normal text."}
knitr::include_graphics('logo.png')
```
如您所见,标题字体大小和常规文本字体大小完全相同,看起来不太好。我怎么解决这个问题?
最佳答案
如果可以接受使用 LaTeX 包,您可以使用 caption
---
output: pdf_document
header-includes:
- \usepackage{caption}
- \captionsetup[figure]{font=scriptsize}
---
Normal text has the same size as the captions.
```{r, echo = FALSE, out.width = '50%', fig.cap = "The caption has the same size as normal text."}
knitr::include_graphics('logo.png')
```
替换
scriptsize
改变大小。您可以在此处找到默认 LaTeX 字体大小的列表:https://en.wikibooks.org/wiki/LaTeX/Fonts#Built-in_sizes
caption
CTAN 上的包裹:https://ctan.org/pkg/caption
关于r - 更改 RMarkdown pdf 输出中图形标题的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56271711/