在RMarkdown的PDF输出中更改图题字体大小。

7
我想要将R Markdown文档中所有标题(包括图片和表格)的字号变小。我正在使用bookdown,最终输出为pdf,并在R Studio中工作。为了加载图片,我使用来自knitr的include_graphics函数,因为我被告知这是最好的方法(请参见此处)。我只找到了同样的问题,但是针对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')
```

如您所见,标题字体大小和正文字体大小完全相同,这看起来不太好看。我该如何解决这个问题?

1个回答

8

如果可以使用 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

CTAN 上的 caption 包:

https://ctan.org/pkg/caption


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接