Rmd:在带有大都会主题的 Beamer 幻灯片中添加编号的 TOC
Posted
技术标签:
【中文标题】Rmd:在带有大都会主题的 Beamer 幻灯片中添加编号的 TOC【英文标题】:Rmd: Add numbered TOC in Beamer slides with metropolis theme 【发布时间】:2021-11-28 19:00:31 【问题描述】:我正在创建 Beamer 幻灯片 的 RMarkdown 模板,并使用 metropolis 主题作为基础。
现在,我想要一个编号的目录,我可以通过toc.tex
实现它。但是当我在这里包含它时
beamer_presentation:
includes:
in_header:
- toc.tex
幻灯片的整个格式都消失了,这是我不想要的。 如何保持幻灯片的格式并获得编号的目录
这是我的(最小的工作示例):
slides.rmd
:
---
title: "Title"
subtitle: "Subtitle"
author: "Simon"
institute: "RUB"
date: "September 22, 2021"
output:
beamer_presentation:
keep_md: true
keep_tex: no
latex_engine: xelatex
#theme: metropolis
includes:
in_header:
- toc.tex
slide_level: 2 # which header level should be printed as slides
incremental: no
header-includes:
- \usetheme[numbering=fraction]metropolis
- \definecolorbeaubluergb0.74, 0.83, 0.9
- \setbeamertemplateframe footer\tiny\textcolorbeaublueConference 56. Jahrestagung der DGSMP, 2021
- |
\makeatletter
\def\ps@titlepage%
\setbeamertemplatefootline
\addtobeamertemplatetitle page\thispagestyletitlepage
\makeatother
---
```r setup, include=FALSE
knitr::opts_chunk$set(echo = FALSE)
```
## Content
\tableofcontents[]
# Level I
Test
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
# Slide with R Output
```r cars, echo = TRUE
summary(cars)
```
toc.tex
:
\setbeamertemplatesection in toc[sections numbered]
\setbeamertemplatesubsection in toc[subsections numbered]
【问题讨论】:
【参考方案1】:您可以将\includetoc
添加到您的标头包含中:
---
title: "Title"
subtitle: "Subtitle"
author: "Simon"
institute: "RUB"
date: "September 22, 2021"
output:
beamer_presentation:
keep_md: true
keep_tex: true
latex_engine: xelatex
#theme: metropolis
slide_level: 2 # which header level should be printed as slides
incremental: no
header-includes:
- \usetheme[numbering=fraction]metropolis
- \definecolorbeaubluergb0.74, 0.83, 0.9
- \setbeamertemplateframe footer\tiny\textcolorbeaublueConference 56. Jahrestagung der DGSMP, 2021
- |
\makeatletter
\def\ps@titlepage%
\setbeamertemplatefootline
\addtobeamertemplatetitle page\thispagestyletitlepage
\makeatother
\includetoc
---
```r setup, include=FALSE
knitr::opts_chunk$set(echo = FALSE)
```
## Content
\tableofcontents[]
# Level I
Test
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
# Slide with R Output
```r cars, echo = TRUE
summary(cars)
```
【讨论】:
以上是关于Rmd:在带有大都会主题的 Beamer 幻灯片中添加编号的 TOC的主要内容,如果未能解决你的问题,请参考以下文章
将latex的beamer做的幻灯片转换为ppt格式后的一些问题