使用rmarkdown和knitr将节添加到beamer演示文稿中

时间:2021-03-04 06:12:44

I am trying to add section slides to a beamer presentation written in rmarkdown using the latex command \section{}. However, it gets inserted between a \begin{frame} & \end{frame} automatically during the conversion, which causes the compilation to fail. Is there any way to stop this happening so that the section slide can be added without having to manually edit the tex file?

我正在尝试使用latex命令\ section {}将部分幻灯片添加到使用rmarkdown编写的beamer演示文稿中。但是,它会在转换期间自动插入\ begin {frame}和\ end {frame},这会导致编译失败。有没有办法阻止这种情况发生,以便可以添加部分幻灯片而无需手动编辑tex文件?

Here is my rmarkdown code:

这是我的rmarkdown代码:

---
title: "Beamer presentation"
output: beamer_presentation
---

\section{Section one}

which gets converted to:

转换为:

\title{Beamer presentation}

\begin{document}
\frame{\titlepage}

\begin{frame}
\section{Section one}
\end{frame}

\end{document}

1 个解决方案

#1


Slides and section slides are both defined by markdown headings, a series of # character at the beggining of a line, the number of # indicating the hierarchical level of the title.

幻灯片和部分幻灯片都由降价标题定义,一行是在行的开头处的#字符,#的数字表示标题的层次级别。

By default [the level that defines frames] is the highest header level in the hierarchy that is followed immediately by content, and not another header, somewhere in the document.

默认情况下[定义框架的级别]是层次结构中最高的标题级别,后面紧跟内容,而不是文档中某处的另一个标题。

All title of higher level than this one will become section titles.

比这一级更高级别的所有标题将成为章节标题。

From the rmarkdown documentation ; See also the pandoc documentation on slideshows.

来自rmarkdown文档;另请参阅幻灯片上的pandoc文档。

For instance :

例如 :

# Section title

## Frame title

Frame content

### Subtitle inside a frame

#1


Slides and section slides are both defined by markdown headings, a series of # character at the beggining of a line, the number of # indicating the hierarchical level of the title.

幻灯片和部分幻灯片都由降价标题定义,一行是在行的开头处的#字符,#的数字表示标题的层次级别。

By default [the level that defines frames] is the highest header level in the hierarchy that is followed immediately by content, and not another header, somewhere in the document.

默认情况下[定义框架的级别]是层次结构中最高的标题级别,后面紧跟内容,而不是文档中某处的另一个标题。

All title of higher level than this one will become section titles.

比这一级更高级别的所有标题将成为章节标题。

From the rmarkdown documentation ; See also the pandoc documentation on slideshows.

来自rmarkdown文档;另请参阅幻灯片上的pandoc文档。

For instance :

例如 :

# Section title

## Frame title

Frame content

### Subtitle inside a frame