用R markdown/knitr生成的投影仪中的目录 [英] Table of content in beamer generated with R markdown/knitr

查看:85
本文介绍了用R markdown/knitr生成的投影仪中的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题一致,我在生成带有投影仪类文档的目录时遇到了问题在RStudio中使用R markdown和knitr.

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.

我的YAML标头看起来像这样:

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

我在发现此处(我需要对标题页进行som调整,因此这就是我明确引用它的原因).

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

我使用

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

但是,在生成的pdf中仅显示空白页,而没有TOC.我试图运行渲染几次.

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

推荐答案

目录列出了部分,而不是单独的页面.但是您的文档中没有节:由于您使用了slide_level: 1,所以所有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

如果您真的想获得一张单独的幻灯片列表作为目录,则可能有一种方法可以在序言中使用\renewcommand{\tableofcontents}{...}进行操作,但是

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.

这篇关于用R markdown/knitr生成的投影仪中的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆