I'm trying to add frame numbers to my Beamer presentation written in rmarkdown. However, I would like to suppress the numbers on the title page using the \begin{frame}[plain] option (from the second answer here: https://tex.stackexchange.com/questions/82794/removing-page-number-from-title-frame-without-changing-the-theme). However, when compiling from rmarkdown to tex, the \titlepage already creates a frame environment, so in effect I get a double frame and thus an error.
我正在尝试将帧编号添加到我在rmarkdown中编写的Beamer演示文稿中。但是,我想使用\ begin {frame} [plain]选项来抑制标题页上的数字(来自第二个答案:https://tex.stackexchange.com/questions/82794/removing-page-number - 从标题帧,而无需改变最主题)。但是,当从rmarkdown编译为tex时,\ titlepage已经创建了一个框架环境,所以实际上我得到了一个双帧,因此出现了错误。
So when compiling this:
所以在编译时:
---
output:
beamer_presentation:
includes:
in_header: header.tex
---
\begin{frame}[plain]
\titlepage
\end{frame}
I get this in latex:
我用胶乳得到这个:
\begin{frame{
\begin{frame}
\titlepage
\end{frame}
\end{frame}
In the header.tex I have this:
在header.tex我有这个:
\let\otp\titlepage
\renewcommand{\titlepage}{\otp\addtocounter{framenumber}{-1}}
So my workaround now is to just use a plain \maketitle in rmarkdown, then compile to .tex, add the [plain] option, then compile to pdf. However, I would like to avoid that intermediate step. Is this possible in rmarkdown?
所以我现在的解决方法是在rmarkdown中使用普通的\ maketitle,然后编译为.tex,添加[plain]选项,然后编译为pdf。但是,我想避免那个中间步骤。这可能在rmarkdown?
2 个解决方案
#1
5
rmarkdown
uses pandoc
to convert a Rmd file to a pdf via beamer/latex. pandoc
uses templates to control how the conversion goes.
rmarkdown使用pandoc通过beamer / latex将Rmd文件转换为pdf。 pandoc使用模板来控制转换的方式。
One way to deal with your problem is to :
解决问题的一种方法是:
-
Download the default beamer template
rmarkdown
uses and open it.下载rmarkdown使用的默认beamer模板并将其打开。
-
Change line 137 from this :
从这里改变第137行:
\frame{\titlepage}
To this :
对此:
\frame[plain]{\titlepage}
-
Add the path to your modified template in your
Rmd
file :在Rmd文件中添加修改模板的路径:
--- output: beamer_presentation: includes: in_header: header.tex template:/path/to/new/template.tex ---
Note that you need to specify the whole path, or store the template where pandoc
can find it (~/.pandoc/templates
on a linux machine)
请注意,您需要指定整个路径,或将模板存储在pandoc可以找到它的地方(〜/ .pandoc / templates在linux机器上)
#2
1
Add {.plain}
after the title as in:
在标题后添加{.plain},如下所示:
----
# I'm the title {.plain}
Source: Pandoc User’s Guide
来源:Pandoc用户指南
#1
5
rmarkdown
uses pandoc
to convert a Rmd file to a pdf via beamer/latex. pandoc
uses templates to control how the conversion goes.
rmarkdown使用pandoc通过beamer / latex将Rmd文件转换为pdf。 pandoc使用模板来控制转换的方式。
One way to deal with your problem is to :
解决问题的一种方法是:
-
Download the default beamer template
rmarkdown
uses and open it.下载rmarkdown使用的默认beamer模板并将其打开。
-
Change line 137 from this :
从这里改变第137行:
\frame{\titlepage}
To this :
对此:
\frame[plain]{\titlepage}
-
Add the path to your modified template in your
Rmd
file :在Rmd文件中添加修改模板的路径:
--- output: beamer_presentation: includes: in_header: header.tex template:/path/to/new/template.tex ---
Note that you need to specify the whole path, or store the template where pandoc
can find it (~/.pandoc/templates
on a linux machine)
请注意,您需要指定整个路径,或将模板存储在pandoc可以找到它的地方(〜/ .pandoc / templates在linux机器上)
#2
1
Add {.plain}
after the title as in:
在标题后添加{.plain},如下所示:
----
# I'm the title {.plain}
Source: Pandoc User’s Guide
来源:Pandoc用户指南