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.
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}
Related
Recently, I encounter a problem in Rmarkdown.
When I add Chinese characters into xlab() and ylab() in ggplot2. The pdf document generated by rmd will display strange ...... symbol. However, I try to search useful something and the result told me I should add dev: cairo_pdf. Ok, after I add the code to YAML, the new error strange symbols occur again. It displays another strange symbols of □□□.
I want to ask for help from someone who may pay attention to my quesiton. Could you help me? Thank you very much. And here my test code:
---
title: "test.Rmd"
author: "author"
documentclass: ctexart
output:
rticles::ctex:
fig_caption: yes
number_sections: yes
toc: no
dev: cairo_pdf
word_document: default
keywords:
header-includes: \usepackage{booktabs} \usepackage{longtable} \usepackage{array} \usepackage{multirow}
\usepackage{wrapfig} \usepackage{float} \floatplacement{figure}{H}
---
library(ggplot2)
ggplot(cars,aes(speed,dist)) +
geom_line()+xlab("速度\nSpeed") + ylab("距离\nDist")
Sorry, I cannot replicate your images. I just altered the header-includes and included the figure in a code chunk. Did you install xelatex and TeX Live?
Here is the code that worked fine for me:
---
title: "test.Rmd"
author: "author"
documentclass: ctexart
output:
rticles::ctex:
fig_caption: yes
number_sections: yes
toc: no
dev: cairo_pdf
word_document: default
header-includes:
- \usepackage{booktabs}
- \usepackage{longtable}
- \usepackage{array}
- \usepackage{multirow}
- \usepackage{wrapfig}
- \usepackage{float}
- \floatplacement{figure}{H}
---
```{r}
library(ggplot2)
ggplot(cars,aes(speed,dist)) +
geom_line()+xlab("速度\nSpeed") + ylab("距离\nDist")
```
-output
I have a large bookdown project. My YAML header below.
My only desired output is a PDF. However, bookdown by default produces a HTML as well. This makes compilation take more time, and also uses more caching space on my disk. Any chance I can disable producing HTML output? I have tried to play around with the site parameter in the YAML heading, but no luck.
title: "Title"
subtitle: "Subtitle"
author:
- "Name"
- "Institution"
date: "September 2020"
output:
bookdown::pdf_book:
toc: false
includes:
in_header: preamble.tex
keep_tex: yes
latex_engine: xelatex
citation_package: natbib
fontsize: 12pt
linestretch: 1.5
site: bookdown::bookdown_site
documentclass: book
bibliography: [references.bib]
biblio-style: "apalike"
geometry: "left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm"
bookdown doesn't really have a "default" output format. If it produces HTML, the output format must have been provided somewhere. Check if you have a _output.yml under the root directory of your book project. If you do, you may delete it. Then bookdown will use the output field that you specified in the YAML frontmatter of your Rmd document.
I'm looking to create a cover page for a PDF document rendered via rmarkdown, with an image cover.png that I'd have right-aligned right up against the page border. In my YAML below, I currently have it centered on the page. How do I move it to the right?
---
title: \vspace{3cm} \fontsize{1.5cm}{2cm}\selectfont Report Title
header-includes:
- \usepackage{titling}
- \pretitle{\begin{center}\includegraphics[width=20cm]{cover.png}\\[\bigskipamount]}
- \posttitle{\end{center}}
- \pagenumbering{gobble}
output:
pdf_document:
latex_engine: xelatex
mainfont: Calibri
editor_options:
chunk_output_type: console
---
You could include raw latex in your Rmd doc that will situate the picture where you want it. For example:
---
title: Dogs are the best
output:
pdf_document:
header-includes:
- \usepackage{graphicx}
---
```{r include = FALSE}
library(httr)
dog <- "https://www.cesarsway.com/sites/newcesarsway/files/styles/large_article_preview/public/Common-dog-behaviors-explained.jpg"
GET(dog, write_disk("dog.jpg", overwrite = TRUE))
```
\begin{figure}
\raggedleft
\begin{minipage}{5cm}
\includegraphics[width = 5cm]{dog.jpg}
\end{minipage}
\end{figure}
\pagebreak
## Introduction
Dogs dogs dogs
Which results in:
I had to add \hspace*{2cm} before \includegraphics to move it to as far right as I want. I used trial and error to move it to the edge of the page. I got the answer from here.
---
title: \vspace{3cm} \fontsize{1.5cm}{2cm}\selectfont Report Title
header-includes:
- \usepackage{titling}
- \pretitle{\begin{center}\hspace*{2cm}\includegraphics[width=20cm]{cover.png}\\[\bigskipamount]}
- \posttitle{\end{center}}
- \pagenumbering{gobble}
output:
pdf_document:
latex_engine: xelatex
mainfont: Calibri
editor_options:
chunk_output_type: console
---
I'd like to create a PDF using rmarkdown that is A3 (or 11x17, ideally) and in landscape orientation. I can get it to do one or the other by specifying options in the YAML header, but not both at the same time. Here's my best attempt - the classoption values each work individually, but not together:
---
title: "Test"
output:
pdf_document:
toc: true
number_sections: true
documentclass: article
classoption:
landscape
a3paper
---
This question is related, but doesn't have the answer in this case. Thanks in advance for any help you can provide!
It doesn't seem to be documented, but you can include more than one classoption by separating the options with commas or by using a bulleted list with hyphens. Either of the following will work:
---
title: "Test"
output:
pdf_document:
toc: true
number_sections: true
documentclass: article
classoption:
- landscape
- a3paper
---
---
title: "Test"
output:
pdf_document:
toc: true
number_sections: true
documentclass: article
classoption: landscape, a3paper
---
When I use this code to make a square root in my pdf document (rendered by rmarkdown):
---
title: "Test"
author: "test test"
geometry: margin=1in
output:
pdf_document:
keep_tex: yes
latex_engine: xelatex
number_sections: yes
toc: yes
toc_depth: 3
html_document:
css: tables.css
number_sections: yes
theme: cerulean
toc: yes
toc_depth: 3
header-includes:
- \usepackage[dutch]{babel}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyfoot[LE,RO]{this is a fancy foot}
- \usepackage{dcolumn}
- \usepackage{here}
- \usepackage{longtable}
- \usepackage{caption}
- \captionsetup{skip=2pt,labelsep=space,justification=justified,singlelinecheck=off}
subtitle: test test test
fontsize: 12pt
---
$$ S_E\text{=}S_x\sqrt{\text{(}\text{1}\text{-}r_{xx}\text{)}} $$
this is the result:
Notice the strange looking square root. Does anyone know what's going wrong here in my code?
I found the solution to this problem here:
https://tex.stackexchange.com/questions/210153/pdftex-font-expansion-error-during-compilation
In the directory C:\Program Files\MiKTeX 2.9\miktex\bin\x64 I ran updmap.exe. After that the problem was solved.