Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change PDF output font from within the YAML header when using Pandoc on Markdown?

Tags:

fonts

pandoc

Is there a (built-in) way to set a different font (or fonts) to use in the Pandoc YAML header? Ideally, I would do something like this in the YAML header of my Markdown file:

---
font: MySansSerifFontName  
...

I'm using TexLive on Linux (Ubuntu), with pandoc, of course.

like image 637
Kalin Avatar asked Oct 21 '14 04:10

Kalin


People also ask

How do I change the font in pandoc?

Get the default tex template from pandoc by running pandoc -D latex and then add the font definitions you want to the document. save as my-font. latex . Then run pandoc with the switch --template=my-font .

Can pandoc convert PDF to markdown?

You can use the program pandoc on the SCF Linux and Mac machines (via the terminal window) to convert from formats such as HTML, LaTeX and Markdown to formats such as HTML, LaTeX, Word, OpenOffice, and PDF, among others.

How do I Rmarkdown a PDF?

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.


2 Answers

This should do the trick:

---
fontfamily: arev
---

From Pandoc's README:

fontfamily: font package to use for LaTeX documents (with pdflatex): TeXLive has bookman (Bookman), utopia or fourier (Utopia), fouriernc (New Century Schoolbook), times or txfonts (Times), mathpazo or pxfonts or mathpple (Palatino), libertine (Linux Libertine), arev (Arev Sans), and the default lmodern, among others.

like image 78
mb21 Avatar answered Sep 17 '22 10:09

mb21


When you use xelatex or lualatex to render the PDF you must use:

---
mainfont: Arial
---

Official documentation: Variables for LaTeX

like image 37
adius Avatar answered Sep 17 '22 10:09

adius