2

I am using RMarkdown to pull various .pdf's into one central file. These .pdfs are multiple pages in length. The code that I am using is:

---
title: <center> <h1>Analysis Data</h1> </center>
mainfont: Arial
output:
  pdf_document:
    latex_engine: xelatex
sansfont: Arial
fig_crop: false
toc: true
classoption: landscape
fontsize: {10}
geometry: margin=0.30in
header-includes:
- \usepackage{booktabs} 
- \usepackage{sectsty} \sectionfont{\centering}
- \renewcommand{\contentsname}{}\vspace{-2cm} 
---
# File One
\begin{center} 
\includegraphics[width=9.5in]{~/Desktop/DatasetOne.pdf} 
\end{center}
\newpage
# File Two 
\begin{center} 
\includegraphics[width=9.5in]{~/Desktop/DatasetTwo.pdf} 
\end{center}

However, when I knit the final .pdf together, only the first page of each .pdf document ("DatasetOne.pdf" and "DatasetTwo.pdf") are included and not the entire document.

Is it possible to pull through the entire .pdf's rather than just the first page?

Thank you.

user2716568
  • 1,866
  • 3
  • 23
  • 38
  • See https://stackoverflow.com/questions/2739159/inserting-a-pdf-file-in-latex – Marius Sep 08 '17 at 01:15
  • Unfortunately, when I try to use the pdfpages package, I get the following error: `! Missing $ inserted. $ l.137 ...esktop/DatasetOne.pdf} pandoc: Error producing PDF Error: pandoc document conversion failed with error 43 Execution halted` – user2716568 Sep 08 '17 at 01:46
  • I was able to get your example working on my end, see my answer. – Marius Sep 08 '17 at 02:02

1 Answers1

5

I'm able to successfully include two different multi-page PDFs in your example document using pdfpages:

---
title: <center> <h1>Analysis Data</h1> </center>
mainfont: Arial
output:
  pdf_document:
    latex_engine: xelatex
sansfont: Arial
fig_crop: false
toc: true
classoption: landscape
fontsize: {10}
geometry: margin=0.30in
header-includes:
  - \usepackage{booktabs} 
  - \usepackage{sectsty} \sectionfont{\centering}
  - \renewcommand{\contentsname}{}\vspace{-2cm} 
  - \usepackage{pdfpages}
---

# File One

\includepdf[pages={-}]{pdf1.pdf}

\newpage

# File Two 

\includepdf[pages={-}]{pdf2.pdf}
Marius
  • 58,213
  • 16
  • 107
  • 105