Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use latex packages in R markdown beamer?

I want to include latex packages in R markdown pdf and beamer.

Could you help me in including usepackage command in rmarkdown beamer file?

Thanks a lot.

like image 749
ilker_arslan Avatar asked Dec 16 '14 21:12

ilker_arslan


People also ask

Can you use LaTeX packages in R markdown?

The use of additional LaTeX packages can allow for extensive customization of document styling. In addition, several packages such as kableExtra (Zhu 2021) may have LaTeX dependencies for the R package to function.

How do I add LaTeX in R markdown?

LaTeX \newcommand in R Markdown Define the command as you would in LaTeX. Put it below the YAML header at the beginning of your R Markdown file. Call the new command within $… $ to let R Markdown know that this command is defined in the LaTeX environment.

Do you need LaTeX for R markdown?

If you would like to create PDF documents from R Markdown, you will need to have a LaTeX distribution installed.


Video Answer


2 Answers

A simple solution would be to have your header setup like this:

---
title: "Document title"
author: "Author's name"
date: "Document date"
output: beamer_presentation
header-includes:
- \usepackage[brazil]{babel}
- \usepackage{graphicx}
- \usepackage[a4paper]{geometry}
---
like image 140
Waldir Leoncio Avatar answered Sep 21 '22 18:09

Waldir Leoncio


The YAML header of the Rmd would look like:

---
title: "Habits"
output:
  pdf_document:
    includes:
      in_header: header.tex
---

Then, in the file header.tex, include any usepackage statements you need, eg. \usepackage{pdflscape}

See http://rmarkdown.rstudio.com/pdf_document_format.html for more information.

like image 20
CJGodfrey Avatar answered Sep 22 '22 18:09

CJGodfrey