Reputation: 490
I am using Rstudios markdown to write a report which I would like to compile to pdf using latex as well as to html...
Is it somehow possible to adjust the size of caption fonts for images included in an ![caption](figure.jpg)
environment? At the moment captions in html look like the rest of the text.
Upvotes: 4
Views: 4659
Reputation: 1337
Thanks to @Johnny's earlier comment, I wanted a bit more modification to my figure caption in my pdf report. I wanted a caption to look like the following:
Figure 1. This is a graph to explain productivity.
To get this, add in YAML:
---
title: "Title"
author: "Author"
header-includes:
- \usepackage[font={small,it}, labelfont={bf}]{caption}
output:
pdf_document
---
Upvotes: 3
Reputation: 771
This answer has obviously already been accepted but just for completeness I am adding the PDF aspect of the question.
If you wish to alter the caption font size for your PDF documents I would recommend to use the caption
package via one of the following two approaches:
header-includes - option:
---
title: "Title"
author: "Jorge Luis Borges"
header-includes:
- \usepackage[font={small}]{caption}
output:
pdf_document
---
The focus here is on font={<font options>}
.
in_header - option:
---
title: "Title"
author: "Jorge Luis Borges"
output:
pdf_document:
includes:
in_header: style.tex
---
Where style.tex
is included in the same directory that contains the .Rmd file. The style.tex
file needs to contain \usepackage[font={small}]{caption}
.
As before, the focus here is on font={<font options>}
.
With the caption
package you have loads of customisation options, just to name a few, see below:
scriptsize
= very small sizefootnotesize
= size typically used for footnotessmall
= small sizelarge
= large sizeit
= italicsbf
= bold faceFor full reference please visit the official documentation.
Also, some cross-references here to articles on the TexSE site:
Change the font of figure captions
How to include Latex package in RMarkdown
Upvotes: 10