簡體   English   中英

在RMarkdown pdf輸出中更改圖形標題的字體大小

[英]Changing the font size of figure captions in RMarkdown pdf output

我想縮小我的R Markdown文檔中所有標題(圖和表格)的字體大小。 我正在使用書本。 最終輸出是pdf,我正在R Studio中工作。 要加載圖片,我使用了knitrinclude_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')
```

如您所見,標題字體大小和常規文本字體大小完全相同 ,看起來不太好。 我怎么解決這個問題?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM