Using beamer in RMarkdown for presentations, I can't figure out why the TOC is empty. I have tried using a MacBook and Windows.
---
title: "test"
author: "my name"
date: "12/6/2016"
output:
beamer_presentation:
keep_tex: true
toc: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
# Slide 1
Slide content
# Slide 2
Slide content
Outputs the pdf presentation with a title slide, an empty page (where the TOC should be), and then the two slides.
On Windows platform:
> R.version
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 3.1
year 2016
month 06
day 21
svn rev 70800
language R
version.string R version 3.3.1 (2016-06-21)
nickname Bug in Your Hair
RStudio:0.99.896
Rmarkdown: 1.2
knitr: 1.15.1
Somewhat related question here: Table of content in beamer generated with R markdown/knitr
Using the keep_tex: true argument in the YAML, I see from the tex file that the level 1 headers (i.e. # Section) are not being properly converted to sections in the tex file. For example, from the tex file:
\begin{frame}{Slide 1}
Slide content
\end{frame}
It seems that RMarkdown is not making the tex file correctly.
As pointed out here, the TOC will list the sections (as defined by single #'s), and the slide level must be a level below the sections (defined below in the YAML as slide_level: 2 and in the presentation by ##'s). I don't completely understand why you can't have sections at the slide level, but at least this works.
---
title: "test"
author: "my name"
date: "12/6/2016"
output:
beamer_presentation:
keep_tex: true
toc: true
slide_level:2
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
# Section 1
## Slide 1
Slide content
# Section 2
# Slide 2
Slide content
Related
I need to knit my Markdown script into a pdf file, but when knitted, the pdf file does not show special Latin characters, such as those used in the International Phonetic Alphabet (IPA).
---
title: "MarkdownIPA"
date: '2022-07-06'
output:
pdf_document:
latex_engine: xelatex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
`Print IPA`
```{r}
'[aɪ.pʰiː.ɛɪ]'
```
Which rends:
How can I fix this?
You'll need to use a font that supports those glyphs. A (IMHO) rather nice one is Source Sans Pro and the monospace variant Source Code Pro.
To use Source Code Pro, you can add the respective LaTeX code directly:
---
title: "MarkdownIPA"
date: '2022-07-06'
output:
pdf_document:
latex_engine: xelatex
header-includes:
- \usepackage{sourcecodepro}
---
Result:
The sourcecodepro package is likely already installed; otherwise you'd have to install it first.
I have a Rmd (see bellow) file and when I execute the file without toc and pandoc I am able to get the title and author, but with them I am not able to see them. How can I get my title and author name to appear with numbered sections and toc?
---
title: "Design"
author: "Jen"
output:
html_document:
toc: true
pandoc_args: [
"--number-sections"
]
---
# plots
You should give rmarkdown full control over the pandoc arguments:
---
title: "Design"
author: "Jen"
output:
html_document:
toc: true
number_sections: true
---
# plots
Source: https://bookdown.org/yihui/rmarkdown/html-document.html#section-numbering
The help file of the pdf_document function of the Rmarkdown CRAN package says that the function is defined with the following options:
pdf_document(toc = FALSE, toc_depth = 2, number_sections = FALSE,
fig_width = 6.5, fig_height = 4.5, fig_crop = TRUE,
fig_caption = TRUE, dev = "pdf", df_print = "default",
highlight = "default", template = "default", keep_tex = FALSE,
latex_engine = "pdflatex", citation_package = c("none", "natbib",
"biblatex"), includes = NULL, md_extensions = NULL,
pandoc_args = NULL, extra_dependencies = NULL)
I am under the impression that I could add any of these arguments as options under pdf_document in the output section of the YAML header in my Rmarkdown document. Is this correct? The document managed to compile when I used the following options/arguments of pdf_document: toc, number_sections, fig_caption, df_print, and keep_tex. However, when I add citation_package to the list, I get an error in compiling. For instance, consider the following template Rmarkdown document.
---
title: "Untitled"
author: "Unknown"
date: "4/18/2019"
output:
pdf_document:
# toc: true
number_sections: true
fig_caption: true
df_print: kable
keep_tex: true
citation_package: biblatex
bibliography: sample_bib.bib
csl: /Users/Shared/Zotero/styles/multidisciplinary-digital-publishing-institute.csl
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
I love R [#rcoreteamLanguageEnvironmentStatistical2018].
The sample_bib.bib mentioned is the bib file that looks like
#software{rcoreteamLanguageEnvironmentStatistical2018,
location = {{Vienna, Austria}},
title = {R: {{A Language}} and {{Environment}} for {{Statistical Computing}}},
url = {https://www.R-project.org/},
version = {3.5.1},
organization = {{R Foundation for Statistical Computing}},
date = {2018},
author = {{R Core Team}}
}
However, I was unable to knit this Rmarkdown document. I got the following error.
/usr/local/bin/pandoc +RTS -K512m -RTS rmarkdown_pdf_document.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output rmarkdown_pdf_document.tex --template /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --number-sections --highlight-style tango --pdf-engine pdflatex --biblatex --variable graphics=yes --variable 'geometry:margin=1in' --variable 'compact-title:yes'
output file: rmarkdown_pdf_document.knit.md
INFO - This is Biber 2.7
INFO - Logfile is 'rmarkdown_pdf_document.blg'
INFO - Reading 'rmarkdown_pdf_document.bcf'
INFO - Found 1 citekeys in bib section 0
INFO - Processing section 0
INFO - Looking for bibtex format file 'sample\_bib.bib' for section 0
ERROR - Cannot find 'sample\_bib.bib'!
INFO - ERRORS: 1
Error: Failed to build the bibliography via biber
Execution halted
Warning message:
LaTeX Warning: Citation 'rcoreteamLanguageEnvironmentStatistical2018' on page 1
undefined on input line 137.
LaTeX Warning: Empty bibliography on input line 169.
Package rerunfilecheck Warning: File `rmarkdown_pdf_document.out' has changed.
(rerunfilecheck) Rerun to get outlines right
(rerunfilecheck) or use package `bookmark'.
LaTeX Warning: There were undefined references.
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
Package biblatex Warning: Please (re)run Biber on the file:
(biblatex) rmarkdown_pdf_document
(biblatex) and rerun LaTeX afterwards.
Luckily, this problem is easily fixed by moving the "citation_package" from an option under pdf_document to a separate line in the YAML header. Or:
---
title: "Untitled"
author: "Unknown"
date: "4/18/2019"
output:
pdf_document:
# toc: true
number_sections: true
fig_caption: true
df_print: kable
keep_tex: true
citation_package: biblatex
bibliography: sample_bib.bib
csl: /Users/Shared/Zotero/styles/multidisciplinary-digital-publishing-institute.csl
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
I love R [#rcoreteamLanguageEnvironmentStatistical2018].
Upon knitting this adjusted Rmarkdown document, the result is a pdf_document.
So my question is: Was I right that you could add any of the arguments found in the pdf_document help file on CRAN as options under "pdf_document" in the YAML header in a Rmarkdown file? Or, upon using this particular citation_package argument/option, could this be a possible bug in the rmarkdown::pdf_document() function?
ALSO POSTED ON RMARKDOWN's GITHUB; see for additional comments.
When I use an R script from the shell to render my bookdown document,
Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')"
it touches all of the .Rmd files. Is there a way to render without touching the files so I don't have to reload them in my editor?
My _bookdown.yml file is:
new_session: yes
rmd_files: [
"index.Rmd",
"encoding.Rmd",
"includes.Rmd",
"comments.Rmd",
"whitespace.Rmd",
"types.Rmd",
"expressions.Rmd",
"statements.Rmd",
"blocks.Rmd",
"user-functions.Rmd",
"execution.Rmd",
"transforms.Rmd",
"syntax.Rmd"
]
before_chapter_script: "_common.R"
delete_merged_file: TRUE
and my _common.R is
library(ggplot2)
library(rstan)
set.seed(10101010)
options(digits = 3)
printf ",
collapse = TRUE,
cache = TRUE,
out.width = "70%",
fig.align = 'left',
fig.width = 6,
fig.asp = 0.618, # 1 / phi
fig.show = "hold"
)
The beginning of my index.Rmd file is:
---
title: "Stan Language Reference"
author: "Stan Development Team"
date: "Version 2.18 (May 2018)"
site: bookdown::bookdown_site
output: bookdown::gitbook
documentclass: book
bibliography: [../bibtex/all.bib]
biblio-style: "apalike"
link-citations: true
fontsize: 11pt
cover-image: img/logo_tm.png
url: 'http\://mc-stan.org/'
github-repo: stan-dev/stan
monofont: "Lucida Console"
description: "Stan reference manual specifying the syntax and semantics of the Stan programming language."
---
I just fixed this issue in bookdown 0.17.2 on Github. Your Rmd files will no longer be touched in future versions of bookdown. For now, you may install the dev version:
remotes::install_github('rstudio/bookdown')
The example document below is intended to include an index after the appendix. In a Sweave document, Rstudio would run a shell escape command to create the index .idx file, but I've not been able to find a way to do this for an Rmarkdown document. Is there a simple header command I'm missing?
---
title: "Untitled"
output:
pdf_document:
toc: yes
header-includes:
- \usepackage{makeidx}
- \makeindex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# R Markdown
This is an \index{R Markdown} R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
# Appendix - A
End of the document
\printindex
I've tried this from both the Knit button and using:
rmarkdown::render(rmd.file, output_format = "pdf_document", clean = FALSE)
I'm looking for a solution that can run as part of an automated process.
UPDATE:
I was able to get the index to work by changing the output type to bookdown::pdf_document2. The additional latex packages were required for a combination of indexing, cross referencing, and formatting.
---
title: "Untitled"
output:
bookdown::pdf_document2:
toc: no
geometry: margin=0.8in
header-includes:
- \usepackage{attachfile2}
- \usepackage{booktabs}
- \usepackage{caption}
- \usepackage{float}
- \usepackage[utf8]{inputenc}
- \usepackage{makeidx}
- \makeindex
- \usepackage{multirow}
- \usepackage{setspace}
- \usepackage{relsize}
- \usepackage[table]{xcolor}
- \setcounter{tocdepth}{5}
- \setcounter{secnumdepth}{0}
- \hypersetup{unicode=true,pdfusetitle,bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2,breaklinks=false,backref=false,colorlinks=true,linkcolor=blue}
---
While this would work when manually pushing the create PDF button, the call to rmarkdown::render() still does not process the indexing.