\framesubtitle 的 R Markdown 版本?

R Markdown version of \framesubtitle?

以下是我所知道的创建带有字幕的 beamer 幻灯片的最少 TeXy 方法:

---
output: beamer_presentation
---

### Title of Slide
\framesubtitle{Subtitle of Slide}

Frame content.

有没有不使用 LaTeX 的方法,或者 R Markdown 不直接支持幻灯片字幕?

Markdown 不支持 \framesubtitles。它假设您将使用常规降价 # 来表示部分单位,并且特定(最高)级别用于框架标题。任何低于该值的内容都只会在 headers 框架内创建 ,但不会创建字幕。来自Pandoc Manual(基于指定的--slide-level或默认):

The document is carved up into slides according to the following rules:

  • A horizontal rule always starts a new slide.

  • A header at the slide level always starts a new slide.

  • Headers below the slide level in the hierarchy create headers within a slide.

  • Headers above the slide level in the hierarchy create "title slides," which just contain the section title and help to break the slide show into sections.

  • Content above the slide level will not appear in the slide show.

这里特别感兴趣的是 "headers below the slide level in the hierarchy creates headers within a slide." 这些 headers 实际上是 block 环境,因为以下最小降价

---
title: A title
output: 
  beamer_presentation:
    keep_tex: true
    slide_level: 1
---

# Title of Slide
## Subtitle of Slide

Frame content.

创建一个 .tex 文件:

\title{A title}
\date{}

\begin{document}
\frame{\titlepage}

\begin{frame}{Title of Slide}

\begin{block}{Subtitle of Slide}

Frame content.

\end{block}

\end{frame}

\end{document}

如果您的演示文稿相当简单,您可以欺骗 LaTeX 将 block 环境转换为 \framesubtitle。在您的工作文件夹中添加以下文件(命名为 block-to-framesubtitle.tex):

\usepackage{environ}
\RenewEnviron{block}[1]{\framesubtitle{#1}\BODY}

现在您可以使用

---
title: A title
output: 
  beamer_presentation:
    slide_level: 1
header-includes:
  - \input{block-to-framesubtitle}
---

# Title of Slide
## Subtitle of Slide

Frame content.