在 Markdown Beamer 中切换背景

问题描述 投票:0回答:1

我正在尝试将 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

有什么想法吗?

r latex r-markdown beamer
1个回答
1
投票

通常在 Beamer 中切换不同的背景模板是小菜一碟,基于 https://tex.stackexchange.com/questions/173201/beamer-template-with- different-style-options-for-frames 可以只需创建一个新的框架选项即可。

不幸的是,rmarkdown 简单地忽略了用户创建的框架选项,并且只传递一小部分预定义选项。为了欺骗 rmarkdown,人们可以重新利用通常不被 beamer 使用的框架选项,即

standout
框架选项(仅由 moloch 主题使用)

---
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

© www.soinside.com 2019 - 2024. All rights reserved.