【问题标题】:rmarkdown beamer presentation: how to not print section slides?rmarkdown beamer 演示:如何不打印部分幻灯片?
【发布时间】:2017-07-15 08:26:39
【问题描述】:

我正在 rmarkdown 中编写投影仪演示文稿,并使用 knitr 将其转换为 pdf。我想在 header1 级别定义部分,例如# Introduction,然后有一张幻灯片,标题为其他内容,例如## Introducing my brilliant research。让 header1 级别定义部分很好,因为部分的名称可以显示在某些投影仪主题的幻灯片标题中,这就是我包含它的原因。

但我不希望 rmarkdown 插入一张幻灯片,该幻灯片仅说明部分之间的部分名称,目前它正在这样做。有没有办法在部分之间不打印带有部分名称的幻灯片?我以为slide_level 会控制这种行为,但它似乎没有(或者我可能用错了)。

可以使用以下代码获得我的问题的最小可重现示例:

---
title: "Test Pres"
author: "Professor Genius Researcher"
date: "24 February 2017"
output: 
  beamer_presentation:
    slide_level: 2
    theme: "Singapore"
    colortheme: "rose"
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

# Markdown Intro

## R Markdown

This is an R Markdown presentation. 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>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

# Using Bullets

## Slide with Bullets

- Bullet 1
- Bullet 2
- Bullet 3

# Including Chunks

## Slide with R Output

```{r cars, echo = TRUE}
summary(cars)
```

## Slide with Plot

```{r pressure}
plot(pressure)
```

目前,此代码会生成显示 Markdown Intro、Using Bullets 和 Include Chunks 的幻灯片。我想要那些标明省略部分的幻灯片。这可能吗?

【问题讨论】:

  • 使用slide_level: 1?这能解决您的问题吗?
  • 不,这使节标题成为幻灯片的标题,并将所有后续幻灯片放入其下方的文本框中
  • 删除 header1 后的空格也不是您的想法吗?
  • LaTeX Beamer prevent showing the TOC,我尝试用\section*{Including Chunks}替换# Including Chunks,但是latex-engine pdflatex返回错误! Missing \endgroup inserted.

标签: r knitr r-markdown beamer


【解决方案1】:

创建一个新的 Latex 模板,在其中从序言中删除此部分:

\AtBeginSection[]
{
  ....
}

将此乳胶模板放在与 .Rmd 文件相同的文件夹中,并在 Rmd Yaml 前端使用 template: mytemplate.tex 引用它,如 here 所述。

【讨论】:

  • 太棒了。非常感谢。一个小的变化:通过您的链接建议的模板文件似乎没有涵盖投影仪。我在我的系统上找不到默认的投影仪模板,所以我得到了它here 并按照你的建议进行了编辑。
  • 上面的模板链接已损坏,因为default_beamer 模板似乎已合并到default_latex。至少,default_latex 对我有用。
  • 使用 header-includes: - \AtBeginSection{} 修改 YAML 标头也是一个可行的选择。请看stackoverflow.com/questions/38180441/…
猜你喜欢
  • 2023-02-23
  • 2018-02-13
  • 2017-12-26
  • 1970-01-01
  • 1970-01-01
  • 2021-05-13
  • 2017-05-31
  • 2017-10-16
  • 1970-01-01
相关资源
最近更新 更多