在Markdown Beamer中切换背景

5
我正在尝试将LaTeX / LyX演示文稿转换为Beamer markdown文档。在某些幻灯片上,我暂停背景图像(其中包含资助机构的徽标),以腾出更多空间来显示代码输出。我之前使用以下命令实现了这一点:
\bgroup
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{background.png}}
\begin{frame}[plain]
Some text here!}
\end{frame}
\egroup

我尝试了以下类似的方法(但并不起作用):

\bgroup
\pgfdeclareimage[width=\paperwidth]{empty}{Template_blank.png}
\usebackgroundtemplate{\pgfuseimage{empty}}

## New Slide

some text
\egroup

任何想法?
1个回答

1
通常在beamer中切换不同的背景模板非常容易,基于https://tex.stackexchange.com/questions/173201/beamer-template-with-different-style-options-for-frames,可以简单地创建一个新的帧选项。
不幸的是,rmarkdown简单地忽略了用户创建的帧选项,并且只传递了一小部分预定义选项列表。为了欺骗rmarkdown,可以重新使用一个通常不被beamer使用的帧选项,即standout帧选项(它仅由metropolis主题使用)。
---
output: 
  beamer_presentation:
    keep_tex: true
    includes:
header-includes: |
  \usepackage{etoolbox}

  \defbeamertemplate{background canvas}{mydefault}{%
    \includegraphics[width=\paperwidth,height=\paperheight]{example-image-duck}
  }
  \defbeamertemplate{background canvas}{standout}{%
    \includegraphics[width=\paperwidth,height=\paperheight,page=2]{example-image-duck}
  }

  \BeforeBeginEnvironment{frame}{%
    \setbeamertemplate{background canvas}[mydefault]%
  }

  \makeatletter
  \define@key{beamerframe}{standout}[true]{%
    \setbeamertemplate{background canvas}[standout]%
  }
  \makeatother

---

# frametitle 

test

# frametitle with different background {.standout}

test

# frametitle

test

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接