Table of content in beamer generated with R markdown/knitr

泄露秘密 提交于 2019-12-29 08:53:06

问题


In line with this question, I have problems generating table of contents with a beamer class document, which I have made in RStudio with R markdown and knitr.

My YAML header looks like this:

---
params:
  x: !r x
author: "Author"
date: "Januar 2016"
graphics: yes
fontsize: 10pt
output:
  beamer_presentation:
    includes:
      in_header: in_header.tex
    keep_tex: yes
    latex_engine: xelatex
    slide_level: 1
    template: body.tex
    toc: true
classoption: aspectratio=169
---

I use the default beamer template in body.tex found here (I needed to make som adjustsments to the title page, so that's why I have referred to it explicitly).

I render the document with

render(input = "file_name.Rmd",
         params = list(x = i),
         output_file = "file_name.beamer.pdf"
         )

However, only a blank page shows up in the pdf generated and no TOC. I have tried to run render several times.


回答1:


A table of contents lists sections, not individual pages. But you have no section in your document: since you used slide_level: 1, all level 1 titles are slides.

If you add sections to your document, you will get a toc. That would be the proper use. Something like:

---
output:
  beamer_presentation:
    slide_level: 2
    toc: true
---

# Section 1

## Slide 1
Slide content

## Slide 2
Slide content

If you really want to get a list of individuals slides as a table of content, there might be a way to do that with \renewcommand{\tableofcontents}{...} in your preamble, but tex.stackexchange.com is better suited for this question.



来源:https://stackoverflow.com/questions/34814100/table-of-content-in-beamer-generated-with-r-markdown-knitr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!