更改 RMarkdown pdf 输出中图形标题的字体大小 [英] Changing the font size of figure captions in RMarkdown pdf output

查看:127
本文介绍了更改 RMarkdown pdf 输出中图形标题的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让 R Markdown 文档中所有标题(图形和表格)的字体大小变小.我正在使用bookdown.最终输出是 pdf,我在 R Studio 中工作.为了加载图片,我使用了 knitr 中的 include_graphics 函数,因为有人告诉我这是最好的方法(请参阅

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

解决方案

如果使用 LaTeX 包可以接受,可以使用 caption

---输出:pdf_document标题-包括:- \usepackage{标题}- \captionsetup[figure]{font=scriptsize}---普通文本的大小与标题相同.```{r, echo = FALSE, out.width = '50%', fig.cap = "标题与普通文本大小相同."}knitr::include_graphics('logo.png')``

替换 scriptsize 以更改大小.您可以在此处找到默认 LaTeX 字体大小的列表:

https://en.wikibooks.org/wiki/LaTeX/Fonts#内置尺寸

CTAN 上的 caption 包:

https://ctan.org/pkg/caption

I would like to make the font size of all captions (figures and tables) in my R Markdown document smaller. I'm using bookdown. The final output is pdf and I'm working in R Studio. To load the picture, I use the include_graphics function from knitr, because I've been told it's the best way (see here).

I only found the exact same question, but for html output here

An example .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')
```

As you can see, the caption font size and the regular text font size are exactly the same, which doesn't look that nice. How can I solve this problem?

解决方案

If it's acceptable using LaTeX packages, you can use 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')

```

Replace scriptsize to change size. You can find a list of default LaTeX font sizes here:

https://en.wikibooks.org/wiki/LaTeX/Fonts#Built-in_sizes

The caption package on CTAN:

https://ctan.org/pkg/caption

这篇关于更改 RMarkdown pdf 输出中图形标题的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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