用R markdown/knitr生成的beamer中的内容表。

时间:2022-02-02 06:12:39

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.

根据这个问题,我在用beamer类文档生成目录时遇到了问题,这是我在RStudio中用R markdown和knitr制作的。

My YAML header looks like this:

我的YAML头看起来是这样的:

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

我在body中使用默认的beamer模板。tex在这里找到了(我需要对标题页进行som调整,因此我明确地引用了它)。

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.

但是,在生成的pdf中只显示一个空白页,没有TOC。我试过多次运行渲染。

1 个解决方案

#1


5  

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.

目录列表列出了部分,而不是单独的页面。但是您的文档中没有部分:因为您使用了slide_level: 1,所以所有的一级标题都是幻灯片。

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

如果在文档中添加部分,将获得toc。这才是正确的用法。喜欢的东西:

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

如果您真的想要获得一个个人幻灯片列表作为内容表,那么可以使用\可更新命令{\tableofcontents}{…在你的序言中,但是text .stackexchange.com更适合这个问题。

#1


5  

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.

目录列表列出了部分,而不是单独的页面。但是您的文档中没有部分:因为您使用了slide_level: 1,所以所有的一级标题都是幻灯片。

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

如果在文档中添加部分,将获得toc。这才是正确的用法。喜欢的东西:

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

如果您真的想要获得一个个人幻灯片列表作为内容表,那么可以使用\可更新命令{\tableofcontents}{…在你的序言中,但是text .stackexchange.com更适合这个问题。