Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify Font type on R Markdown

How can I specify a font type i.e Tahoma on R Markdown. I am using the following to define my document

---
bibliography: bibliography.bib
csl: nature.csl
documentclass: article
fontsize: 12pt
linkcolor: blue
mainfont: Arial
output: 
  pdf_document:
    fig_caption: Yes

---

How can I also specify the font size of figure captions -- like for the figure below

![Figure 2: The impact of malaria disease the factors within the bednet that in turn affect infections and other health issues](climate_change.png)
like image 301
Keniajin Avatar asked Feb 14 '15 17:02

Keniajin


1 Answers

Here an example using LaTeX-code. You need a seperate style-file in the same folder of your R markdown file, where you define the font-family.

In the style-file (mystyle.sty) you can define any font from the LaTeX Font Catalogue, e.g. Palatino Sans Serif:

\usepackage{palatino}
\renewcommand{\familydefault}{\sfdefault} % sans serif
\fontfamily{ppl}\selectfont

For a way to use Tahoma via LaTeX, please have a look here, or here.

The R markdown file looks like this and you can also use LaTeX fontsize commands to change the size of the caption:

---
output: 
pdf_document:
    includes:
        in_header: mystyle.sty 
---

\begin{huge}
![Figure 2: the caption of the picture](picture.png)
\end{huge}
like image 191
jmjr Avatar answered Sep 28 '22 01:09

jmjr