Rpresentation的内容表

时间:2015-10-15 12:03:20

标签: r shiny knitr r-markdown

我正在使用knitr使用Rstudio创建演示文稿,我想使用幻灯片的类型在开头生成目录幻灯片。如果我有以下代码:

Some fun lecture
========================================================
author: some guy
date: in the future

Table of content slide
========================================================
Here I want the table of content based on the following slide types

Some stuff 1
========================================================
type:section
Some very important stuff

More detail on stuff 1
========================================================
type:subsection
Did not get enough of stuff 1!? Here is more :D

Stuff 2
========================================================
type:section
There are other kinds of stuff?

Prompt slide
========================================================
type:prompt
Do not display prompt or alert types in TOC

所以基本上我想在标题幻灯片之后找到一张内容幻灯片,如下所示:

  • 有些东西1
    • 关于东西的更多细节1
  • 东西2

默认情况下是否可用,或者我是否需要一些额外的CSS样式才能处理此问题?

1 个答案:

答案 0 :(得分:2)

要生成目录,请包含带有选项" toc:true"的文档标题。在文件的开头。 1级标题用##表示,2级标题用##表示,依此类推。以下是一个例子。 "提示"选项仅与R代码块相关。 R代码块未列在目录中。

但是,这只会产生一个html文档。如果您希望使用单个幻灯片进行类似Latex的演示,则可以将html_document替换为beamer_presentation。在投影仪演示中,目录中仅列出了1级标题。

---
title: "Sample Document"
author: "Author"
output:
  html_document:
    toc: true
---

# Some stuff 1
Some very important stuff

## More detail on stuff 1
Did not get enough of stuff 1!? Here is more :D

# Stuff 2
There are other kinds of stuff?

```{r, prompt=TRUE}
summary(iris[, "Sepal.Length"])
```

有关Rmarkdown中Beamer演示文稿的更多信息,请参阅http://rmarkdown.rstudio.com/beamer_presentation_format.html。类似的问题已经回答here