Nick
Nick

Reputation: 3384

Latex preamble in R Markdown

I have read several discussions and threads detailing how to add latex pre-amble to R markdown, but am yet to find an easy explanation of how to add latex pre-amble to Rmd files. I have templates in latex that I want to use in my Rmd's PDF and Beamer outputs.

I am having great difficulty in adding pre-amble arguments.

I tried:

in_header
<latex preamble>

as well as

%%
<preamble>
%%

But none seem to work.

Any solutions to someone experienced with latex, but far less with using rmd?

Upvotes: 8

Views: 10354

Answers (2)

Martin Smith
Martin Smith

Reputation: 4087

I use the in_header argument to specify the path to a preamble document.

Note that some things you might list in a preamble file can be specified directly, for example options to the geometry package:

---
title: "My Title"
author: "All of Us"
output:
  bookdown::pdf_document:
    includes:
      in_header: preamble.tex
geometry: "a4paper,right=6cm"
---

Upvotes: 3

NotYourIPhone Siri
NotYourIPhone Siri

Reputation: 785

Have you tried this?

---
title: "My Title"
author: "All of Us"
date: "Today, November 2, 2015"
output: 
  pdf_document
fontsize: 12pt
header-includes: \usepackage{graphicx, verbatim, fancyvrb, setspace, xspace, colortbl, longtable, amsmath, caption, xfrac, float, mathabx}
---

where you can include pieces in the "header-includes" portion?

Upvotes: 8

Related Questions