Changing the font size of figure captions in RMarkdown pdf output

symbolrush

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?

henrik_ibsen

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Changing the font size of figure captions in RMarkdown HTML output

Changing the font size of figure captions in RMarkdown Word output

Give a single figure multiple captions in rmarkdown pdf_book output

Change font size in RMarkdown PDF

Changing figure size (Rstudio, Rmarkdown, Shiny)

Changing font size in Rmarkdown presentation using revealjs

How to find figure captions in a PDF?

Rmarkdown: Modify Figure X label to Figure SX in pdf or word output

*Some* figure captions from RMarkdown not showing

Show captions in block on full size video and font-size isn't changing-Video-js

Loops in Rmarkdown: How to make an in-text figure reference? Figure captions?

Stata esttab output to Latex : changing font size

Captions on tables in pdf documents generated by rmarkdown

How to change font size of table in Rmarkdown, LaTeX and .pdf?

Choose font size for table of contents only in a rmarkdown-rendered pdf

R Markdown - changing font size and font type in html output

Changing color of inline citations in a pdf output from RMarkdown

Rmarkdown font size and header

rmarkdown pdf font not available

rmarkdown PDF custom font

Changing Seaborn figure size

Changing the Pandoc monospace font size or style in DOCX output

Align figure captions left in R quarto - knitting to PDF

Dynamically generating figures with captions in Word output from Rmarkdown document

Auto-Numbering of Figure and Table Captions for HTML Output in R Markdown

Changing font size in Java

Font Size Changing with Refresh

PIL font size not changing

Font size changing buttons