YAML Rmarkdown author lines not working (pdf) - latex

I followed this post to make it so that I could post multiple authors on my front page. However, the YAML is not working correctly. It does not output authors on separate lines, see image:
What am I doing wrong? Code below
---
title: |
Chapter 3
Title Name
author:
- LM Bradley
- Committee Chair, PhD
- Committee Co-chair, PhD
- Committee member, PhD
- Committee member, PhD
- Committee member, PhD
output:
pdf_document:
keep_tex: yes
extra_dependencies: amsmath
html_document:
df_print: paged
word_document: default
This is the abstract.
It consists of two paragraphs.
---

Related

How to make image appear on the top of the first page in rmarkdown documents

I try to put image file (logo.png) on the top of the first page of my document. I followed the guideline from here: Insert a logo in upper right corner of R markdown pdf document. However, the image still does not appear. My code is: I still don't know what's wrong with my codes. Thanks.
---
title: 'Theory'
date: "Fall 2021"
output:
pdf_document:
keep_tex: yes
fig_caption: yes
latex_engine: pdflatex
template: Syllabus_template.tex
html_document:
df_print: paged
geometry: margin=1in
header-includes:
- \usepackage{fancyhdr}
- \usepackage{graphicx}
- \usepackage{eurosym}
- \usepackage{booktabs,xcolor}
- \pagestyle{fancy}
- \fancyhf{}
- \addtolength{\headheight}{1.0cm}
- \rhead{MainSky Stress Test Report - \today}
- \lhead{\includegraphics[width=6cm]{/Users/jj/Documents/logo.png}}
- \rfoot{Page \thepage}
- \fancypagestyle{plain}{\pagestyle{fancy}}
#Fill this in with any number of instructors. It uses a two column layout with a column break after each instructor.
# teachingassistant:
# - name: Filler
# email: filler#fill.com
# officehours: W T
# office: OfficeNumber
# sections: '301'
classroom: 'Remote (either MS Teams or Zoom)'
fontsize: 11pt
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(timeDate)
library(tibble)
library(dplyr)
library(knitr)
#This code chunk sets up a table of meeting days for the course.
#You can set days of the week for course meetings (e.g. Monday and Wednesday).
#Semester start and end dates are selected and then university holidays like spring break are specified.
You can add an image to the title page like this:
---
title: 'Theory'
date: "Fall 2021"
output:
pdf_document:
keep_tex: yes
fig_caption: yes
latex_engine: pdflatex
# template: Syllabus_template.tex
html_document:
df_print: paged
geometry: margin=1in
header-includes:
- \usepackage{graphicx}
- \usepackage{eurosym}
- \usepackage{booktabs,xcolor}
- \makeatletter\patchcmd{\#maketitle}{\begin{center}}{\begin{center}\includegraphics[width=3cm]{example-image-duck}\par}{}{}\makeatother
#Fill this in with any number of instructors. It uses a two column layout with a column break after each instructor.
# teachingassistant:
# - name: Filler
# email: filler#fill.com
# officehours: W T
# office: OfficeNumber
# sections: '301'
classroom: 'Remote (either MS Teams or Zoom)'
fontsize: 11pt
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(timeDate)
library(tibble)
library(dplyr)
library(knitr)
#This code chunk sets up a table of meeting days for the course.
#You can set days of the week for course meetings (e.g. Monday and Wednesday).
#Semester start and end dates are selected and then university holidays like spring break are specified.

Place bibliography before Appendix when using natbib

I have the following document.
---
title: "What comes after the bibliography?"
bibliography: refs.bib
header-includes:
- \usepackage{natbib}
- \setcitestyle{numbers}
- \setcitestyle{square}
output:
pdf_document:
citation_package: natbib
latex_engine: lualatex
keep_tex: yes
---
# A
This document may use knitr[#pKnitr].
# References
<div id="refs"></div>
# Appendix
`1+1` evaluates in R to `r 1+1` (for more information, see [#pRmarkdown])
I used citation() to create the bibtex references in refs.bib.
#InCollection{pKnitr,
booktitle = {{Implementing Reproducible Computational Research}},
editor = {Victoria Stodden and Friedrich Leisch and Roger D. Peng},
title = {knitr: A Comprehensive Tool for Reproducible Research in {R}},
author = {Yihui Xie},
publisher = {Chapman and Hall/CRC},
year = {2014},
note = {ISBN 978-1466561595},
url = {http://www.crcpress.com/product/isbn/9781466561595}
}
#Book{pRmarkdown,
title = {{R Markdown Cookbook}},
author = {Yihui Xie and Christophe Dervieux and Emily Riederer},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2020},
note = {ISBN 9780367563837},
url = {https://bookdown.org/yihui/rmarkdown-cookbook}
}
I want to place my bibliography before the Appendix. So far I've tried the following, unfortunately with no luck.
Add <div id="refs"></div> (see example above)
Using \AtEndDocument{} - its contents won't transpile to LaTeX
\printbibliography does not work with natbib
\bibliography{refs} kinda works, but I have to manually delete the bibliography macro created by md / Rmd
For the last point, if I have the following in my Rmd file...
<!-- ... -->
# References
\bibliography{refs}
# Appendix
`1+1` evaluates in R to `r 1+1` (for more information, see [#pRmarkdown])
... it produces the following LaTeX file.
% ...
\section{A}\label{a}}
This document may use knitr\citep{pKnitr}.
\hypertarget{references}{%
\section{References}\label{references}}
\bibliography{refs.bib}
\hypertarget{appendix}{%
\section{Appendix}\label{appendix}}
\texttt{1+1} evaluates in R to 2 (for more information, see
\citep{pRmarkdown})
\bibliography{refs.bib}
\end{document}
So \bibliography{refs.bib} is now added twice, causing a Citations multiply defined error.
How can I add the bibliography before my Appendix using natbib?
If you use remove all the interference from markdown, you are more flexible with the placement of the bibliography:
---
title: "What comes after the bibliography?"
header-includes:
- \usepackage{natbib}
- \bibliographystyle{plainnat}
- \setcitestyle{numbers}
- \setcitestyle{square}
output:
pdf_document:
latex_engine: lualatex
keep_tex: yes
---
# A
This document may use knitr \cite{pKnitr}.
\bibliography{refs}
# Appendix
`1+1` evaluates in R to `r 1+1` (for more information, see \cite{pRmarkdown})

Changing *Chapter X* name in bookdown PDF

Instead of Chapter X when creating a PDF from bookdown, I would like it to be "Módulo X" (in Spanish).
So I would like to know how to change chapter name using bookdown.
My YAML is:
---
title: "TITLE"
author: "Mario Modesto-Mata"
date: "`r Sys.Date()`"
output: pdf_document
description: This is a minimal example of using the bookdown package to write a book.
The output format for this example is bookdown::gitbook.
documentclass: book
link-citations: yes
bibliography: book.bib
site: bookdown::bookdown_site
language:
label:
chapter_name: "Módulo"
---
I tried with the last three line codes, with no success. Any idea?
From the bookdown documentation we can learn two things:
There is no language.label.chapter_name but language.ui.chapter_name.
This setting is meant for HTML output. For PDF output one should configure LaTeX.
Configuring LaTeX is quite simple. You only need to add lang: es to your header.
However, this will use "Capítulo" instead of "Módulo". One can adjust this by redefining the LaTeX command \chaptername. BTW, at the moment you are not using bookdown but the standard pdf_docuemnt from rmarkdown. If you wont to use bookdown features, you should use bookdown::pdf_book or bookdown::pdf_document2.
Putting everything together:
---
title: "TITLE"
author: "Mario Modesto-Mata"
date: "`r Sys.Date()`"
output: bookdown::pdf_book
description: This is a minimal example of using the bookdown package to write a book.
The output format for this example is bookdown::gitbook.
documentclass: book
lang: es
link-citations: yes
bibliography: book.bib
site: bookdown::bookdown_site
header-includes:
- \AtBeginDocument{\renewcommand{\chaptername}{Módulo}}
---
Result:
Note that header-includes is nice for simple stuff in single file documents like this minimal example. In most cases one is better off including a tex into the header via output.<your-format>.includes.in_header, c.f. Include TeX header in R package for RMarkdown documents.

bookdown chapter heading not correct

I am using the bookdown to write a book. I've defined the documentclass as book. Everything seems to be working correctly - the Table of Contents, List of Tables and List of Figures along with an Appendix, Bibliography and Index. However, in my index.Rmd file I lead off with a Preface section that is not numbered. So, this first "Preface chapter" is marked with a level-1 heading # Preface {-}. The Preface is listed correctly in the Table of Contents as an unnumbered Chapter. However, on the page following the "Preface chapter" the heading at the top of the page still says "List of Figures". So, somehow the chapter heading is being held over and repeated from the List of Figures and not being updated with the "Preface chapter" heading. This "List of Figures" heading stays the same until I get to the next chapter (technically the second chapter) which is numbered, then the rest of the page headings are correct for the rest of the book.
I'm a bit of a LaTeX newbie, so I'm sure there is some option or setting I'm missing. Do I need to add some special LaTeX command or Pandoc argument to make sure that the page headings are aligned with every chapter - both numbered and unnumbered?
Any suggestions are much appreciated. My relevant YAML settings and TEX commands are listed below.
_output.yml
bookdown::pdf_book:
includes:
in_header: preamble.tex
after_body: after_body.tex
latex_engine: xelatex
citation_package: natbib
keep_tex: yes
preamble.tex
\usepackage{booktabs}
\usepackage{makeidx}
\makeindex
\usepackage[nottoc]{tocbibind}
index.Rmd - relevant section of YAML
documentclass: book
bibliography: [manual.bib, packages.bib]
biblio-style: apalike
link-citations: yes
lot: true
lof: true
Since pandoc passes LaTeX commands through you could use
# Preface {-}
\markboth{Preface}{}
(c.f. https://tex.stackexchange.com/questions/89914/chapter-name-in-the-header-with-chapter)

How to interrupt an incremental list of items in Rmarkdown, then retake it after a plot or figure?

I'm really interested in interrupting incremental lists of items created in Rmarkdown with RStudio, to show plots and figures, then retake the list highlighting. This is quite straightforward in Latex, but I couldn't figure out how to achieve the same result using Rmarkdown. Below is some beamer example.
---
title: "Sample Document"
author: "Author"
output:
beamer_presentation:
fonttheme: structurebold
highlight: pygments
incremental: yes
keep_tex: yes
theme: AnnArbor
toc: true
slide_level: 3
---
# Some stuff 1
### Some very important stuff
- More detail on stuff 1
- More detail on stuff 1
- More detail on stuff 1
# The following chart should appear between the first and second item above
```{r, prompt=TRUE}
summary(iris[, "Sepal.Length"])
# Stuff 2
### There are other kinds of stuff?
```{r, prompt=TRUE}
summary(mtcars[, "cyl"])
You're asking about the behaviour of pandoc's incremental option that makes "list items in slide shows display incrementally (one by one)." The option causes pandoc to generate the following LaTeX (which in turn generates the PDF):
\\begin{itemize}[<+->]
I'm not sure of the exact LaTeX behaviour, but what about the following?
- More detail on stuff 1
- ```{r, prompt=TRUE}
summary(iris[, "Sepal.Length"])
```
- More detail on stuff 1
- More detail on stuff 1
You can insert slides in between the items like this:
---
title: "Sample Document"
author: "Author"
output:
beamer_presentation:
fonttheme: structurebold
highlight: pygments
incremental: yes
keep_tex: yes
theme: AnnArbor
toc: true
slide_level: 3
---
# Some stuff 1
``` {=latex}
\end{frame}
\begin{frame}<1>[label=foo]
\frametitle{some very important stuff}
```
- More detail on stuff 1
- More detail on stuff 1
- More detail on stuff 1
``` {=latex}
\end{frame}
```
### Some chart
insert chart here
``` {=latex}
\end{frame}
\againframe<2->{foo}
```
### other stuff

Resources