Where to put header.tex to change page to Landscape Rmarkdown

1.4k views Asked by At

I read here how to add what is needed to give me the ability to change my page to landscape: enter link description here

However I have saved the header.tex file everyplace I could think of and I still end up getting the following error:

Called from: (function (e) 
{
if (inherits(e, "shiny.silent.error")) 
    return()
handle <- getOption("shiny.error")
if (is.function(handle)) 
    handle()
})(list(message = "pandoc document conversion failed with error 43", 
call = NULL))
Browse[1]> 

I know this is do to me typing \blandscape and \elandscape because the PDF works as soon as I delete those commands. What I need help with is figuring out where to save the header.tex file to so that Rmarkdown knows how to locate it. Thanks in advance for everyone's your help!

Follow up: Taking scoa's advice about adding it to my header I edited the top of my Rmd file to the following. Unfortunately it still didn't work.

---
title: "Lake Report"
output: pdf_document
header-includes:
- \usepackage{lscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
---
\newpage
\blandscape
```{r Non-Seasonal MK results, echo=FALSE}
# MKanalysis <- reactive(HM_MK(data = NonSeasonalData(),n = 4))
kable(MKanalysis(), caption = "Non-Seasonal Trend Analysis")
```
The results of the Mann Kendall analysis....
\elandscape

Latex program/verision: pdfTex, Version 3.14159265-2.6-1.40.17

1

There are 1 answers

5
scoa On BEST ANSWER

Save the header.tex in the same directory your Rmd file is. Also, rather than an external file, you could just add those commands in your yaml front matter, a more portable solution:

---
title: "Lake Report"
output: pdf_document
header-includes:
- \usepackage{lscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
---