Change paper size and orientation in an rmarkdown pdf - r

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
---

Related

RMarkdown / Knitr: Hide code for Word document, but code folding in HTML document

For a project, I would like the knitr-output when choosing for a HTML to enable code folding, but to hide all code when knitting a word document.
My current RMarkdown YAML:
---
title: "Title"
author: "me"
output:
bookdown::html_document2:
code_folding: hide
number_sections: false
word_document:
reference_docx: reference.docx
# Option to hide code in word document?
pdf_document:
latex_engine: xelatex
bibliography: references.bib
link-citations: yes
editor_options:
markdown:
wrap: 72
linestretch: 2
lang: en
---
Is there an option for the word_document YAML-tag to make this possible? Or another workaround or package? If you set echo=FALSE or include=FALSE in the R chuncks, then this also omits the code in the HTML document. Looked around in RMarkdown documentation and different forums, but can't find a way to achieve this.
One option would be to use knitr::is_html_output to check whether you are rendering to HTML or not. This could then be used to conditionally set echo=FALSE for non-HTML output:
---
title: "Title"
author: "me"
output:
word_document:
# Option to hide code in word document?
#reference_docx: reference.docx
bookdown::html_document2:
code_folding: hide
number_sections: false
pdf_document:
latex_engine: xelatex
---
```{r include=FALSE}
if (!knitr::is_html_output()) knitr::opts_chunk$set(echo=FALSE)
```
```{r}
library(ggplot2)
ggplot(mtcars, aes(hp, mpg)) +
geom_point()
```
Word Output
HTML Output

How to set position of list of figure (lof) in R bookdown YAML

I have a R bookdown whose YAML looks like this:
---
title: "My title"
toc: False
lof: True
author: "the author"
output:
bookdown::pdf_document2:
keep_tex: yes
---
By default it generates a pdf file with the list of figures at the beginning just after the title.
Is there a way to have this list at the end, after the references?
Remove lof: True and add \listoffigures after your references.

How to reference sections in rmarkdown with pdf output

How do I use \label and \ref to link sections in rmarkdown when outputting to pdf please. I have tried various permutations from https://bookdown.org/yihui/bookdown/cross-references.html and https://bookdown.org/yihui/rmarkdown-cookbook/cross-ref.html with no success.
One attempt
---
title: "Untitled"
output: pdf_document
---
See Section \#ref(sec:label).
# Section One (\#sec:label)
which gives
You can modify your document as follows:
---
title: "Untitled 1"
date: "28 de junio de 2020"
link-citations: yes
output:
pdf_document:
includes:
keep_tex: yes
number_sections: yes
toc_depth: 2
---
\section{This is the first section} \label{section1}
You will be some in \ref{section1}
Then you can see how numbers appear, just add \label{} to your sections and use \ref{} to call. Also, I suggest using \section{}, and modify YAML as I included. Hoping this can help.

Rmarkdown and Latex format citations with round paranthesis

I feel like this is a straight forward thing, but everything I find doesn't quite get me what I want. I'm using rmarkdown and knitting to a latex .pdf. I'd like to have my in-text citations have round () parenthesis instead of the block ones. The yaml below uses a references.bib file to correctly import the references. Is there anything I can do to easily change my parenthesis to round?
---
title: "Title"
author: "Author"
date: "16/03/2020"
output:
pdf_document:
fig_caption: yes
citation_package: natbib
bibliography: references.bib
editor_options:
chunk_output_type: console
---
I've used an approach here, but it returns an error:
Error in yaml::yaml.load(..., eval.expr = TRUE) :
Parser error: while parsing a block mapping at line 6, column 5 did not
find expected key at line 7, column 30`
---
title: "Title"
author: "Author"
date: "16/03/2020"
output:
pdf_document:
fig_caption: yes
bibliography: references.bib
editor_options:
chunk_output_type: console
\usepackage[round]{natbib}
---
Any ideas? Thanks for your suggestions / ideas...
The problem with your attempt to include \usepackage[round]{natbib} in the rmarkdown header is that rmarkdown seems not clever enough to parse commands with optional arguments. One can trick it by hiding the command in a .tex file
---
title: "Title"
author: "Author"
date: "16/03/2020"
output:
pdf_document:
fig_caption: yes
includes:
in_header: preamble.tex
bibliography: references.bib
---
test [#knuth]
with preamble.tex
\usepackage[round]{natbib}
https://rstudio.cloud/project/1061588
Using the header-includes: option should fix the issue.
---
title: "Title"
author: "Author"
date: "16/03/2020"
output:
pdf_document:
fig_caption: yes
citation_package: natbib
bibliography: references.bib
editor_options:
chunk_output_type: console
header-includes:
- \usepackage[round]{natbib}
---

changing rmarkdown "table of contents" default title

I am using RMarkdown to write my MSc thesis, in a language different than English. The thesis shall be rendered in .docx format. Reading around SO, I found that it is possible to provide some pandoc arguments among which toc-title could address my issue. Nevertheless I was not able to do it. My current YAML header is:
output:
word_document:
reference_docx: stile_tesi.docx
toc: yes
fig_caption: true
#pandoc_args: [
# "--toc-title", "INDICE"
#]
Thanks in advance
---
title: "Untitled"
output:
word_document:
toc: yes
toc-title: "INDICE"
---
Important: Watch out the correct indention!

Resources