r - 更改 RMarkdown pdf 输出中图形标题的字体大小

标签 r r-markdown bookdown

我想让 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/

相关文章:

R:Bookdown:每个 Markdown 文件一章 (Rmd)

javascript - Shiny 的 ui.R 是否支持在每个带有 tabsetPanel 的 tabPanel 上包含 html 页面?

css - bookdown 中自定义 block 中的样式链接

r - 改进R中从google获取股票新闻数据的功能

r - 彩色打印 R 标记 html

r - “Erroneous nesting of equation structures”在rmarkdown中的多行方程式中使用“\begin{align}”到knit + pandoc pdf

html - 如何增加 bookdown 中侧边栏菜单的宽度

r-markdown - Rmarkdown 与 html,如何引用数字?

r - 如何在R-studio的功能主体中设置断点?

r - 如果达到最大内存,如何进行代码中断