sym*_*ush 5 r r-markdown bookdown
我想让 R Markdown 文档中所有标题(图形和表格)的字体大小变小。我正在使用bookdown。最终输出是 pdf,我在 R Studio 中工作。要加载图片,我使用include_graphicsfrom的函数knitr,因为有人告诉我这是最好的方法(请参阅此处)。
我只找到了完全相同的问题,但对于 html 输出在这里
一个例子.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')
```
Run Code Online (Sandbox Code Playgroud)
如您所见,标题字体大小和常规文本字体大小完全相同,看起来不太好。我怎么解决这个问题?
如果可以接受使用 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')
```
Run Code Online (Sandbox Code Playgroud)
更换scriptsize以更改大小。您可以在此处找到默认 LaTeX 字体大小的列表:
https://en.wikibooks.org/wiki/LaTeX/Fonts#Built-in_sizes
captionCTAN上的包: