【问题标题】:Add beamer frame options in knitr/rmarkdown在 knitr/rmarkdown 中添加投影仪框架选项
【发布时间】:2015-04-21 21:33:55
【问题描述】:

我正在尝试将帧号添加到用 rmarkdown 编写的 Beamer 演示文稿中。但是,我想使用 \begin{frame}[plain] 选项抑制标题页上的数字(来自这里的第二个答案:https://tex.stackexchange.com/questions/82794/removing-page-number-from-title-frame-without-changing-the-theme)。但是,当从 rmarkdown 编译到 tex 时,\titlepage 已经创建了一个框架环境,所以实际上我得到了一个双框架,因此出现了错误。

所以编译时:

---
output:
  beamer_presentation:
    includes:
      in_header: header.tex
---

\begin{frame}[plain]
\titlepage
\end{frame}

我在乳胶中得到这个:

\begin{frame{

  \begin{frame}
     \titlepage
  \end{frame}

\end{frame}

在 header.tex 我有这个:

\let\otp\titlepage
\renewcommand{\titlepage}{\otp\addtocounter{framenumber}{-1}}

所以我现在的解决方法是在 rmarkdown 中使用普通的 \maketitle,然后编译为 .tex,添加 [plain] 选项,然后编译为 pdf。但是,我想避免那个中间步骤。这在 rmarkdown 中可行吗?

【问题讨论】:

    标签: r latex knitr r-markdown beamer


    【解决方案1】:

    rmarkdown 使用 pandoc 通过 beamer/latex 将 Rmd 文件转换为 pdf。 pandoc 使用 templates 来控制转换的进行。

    解决问题的一种方法是:

    1. Download the default beamer template rmarkdown 使用并打开它。

    2. 从这里更改第 137 行:

      \frame{\titlepage}
      

      到这里:

      \frame[plain]{\titlepage} 
      
    3. Rmd 文件中添加修改后模板的路径:

      ---
      output:
        beamer_presentation:
          includes:
            in_header: header.tex
          template:/path/to/new/template.tex
      ---
      

    请注意,您需要指定整个路径,或者将模板存储在pandoc 可以找到的位置(Linux 机器上为~/.pandoc/templates

    【讨论】:

      【解决方案2】:

      在标题后添加{.plain},如:

      ----
      
      # I'm the title {.plain}
      

      来源:Pandoc User’s Guide

      【讨论】:

        猜你喜欢
        • 2014-04-06
        • 1970-01-01
        • 1970-01-01
        • 2014-11-08
        • 2014-05-09
        • 2017-12-07
        • 2020-12-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多