关于r:在RMarkdown pdf输出中更改图形标题的字体大小

Changing the font size of figure captions in RMarkdown pdf output

我想缩小我的R Markdown文档中所有标题(图和表格)的字体大小。 我正在使用书本。 最终输出是pdf,我正在R Studio中工作。 要加载图片,我使用了knitr中的include_graphics函数,因为有人告诉我这是最好的方法(请参见此处)。

我只找到了完全相同的问题,但此处为html输出

示例.rmd

1
2
3
4
5
6
7
8
9
---
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

1
2
3
4
5
6
7
8
9
10
11
12
13
---
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://zh.wikibooks.org/wiki/LaTeX/Fonts#Built-in_sizes

CTAN上的caption软件包:

https://ctan.org/pkg/caption