我正在尝试为我的 beamer 主题创建两种不同风格的块,一种有轮廓,另一种是倒置的。我已经实现了它们,但这是关于正确的选择方法。所以这是我的 MWE:
\documentclass{beamer}
\usepackage{ifthen}
\defbeamertemplate*{block alerted begin}{mytest}[1][outline]{%
\ifthenelse{\equal{#1}{outline}}%
{%
Beginn Outline%
}%
{%
\ifthenelse{\equal{#1}{inverted}}
{%
Beginn Inverted%
}%
{%
}%
}%
}
\defbeamertemplate*{block alerted end}{mytest}[1][outline]{%
\ifthenelse{\equal{#1}{outline}}%
{%
Beginn Outline%
}%
{%
\ifthenelse{\equal{#1}{inverted}}
{%
Beginn Inverted%
}%
{%
}%
}%
}
\begin{document}
\begin{frame}[label=myframe]
\begin{alertblock}{}
Test
\end{alertblock}
\end{frame}
\setbeamertemplate{blocks}[mytest][inverted]
\againframe{myframe}
\setbeamertemplate{blocks}[mytest][outline]
\againframe{myframe}
\setbeamertemplate{block alerted begin}[mytest][inverted]
\setbeamertemplate{block alerted end}[mytest][inverted]
\againframe{myframe}
\end{document}
如您所见,我定义了阻止警报模板的两个选项,然后针对不同的框架调用它。然而,我得到的结果如下:
因此,在我尝试设置父模板后,我在第一张幻灯片上打印了[inverted]
或[outline]
,但并没有设置它。但是对每个单独模板的调用都有效。据我了解手册,它应该有效:
父级 Beamer 模板更改此父级模板会更改普通块、警报块和示例块的模板。
示例:\setbeamertemplate{blocks}[default]
示例:\setbeamertemplate{blocks}[rounded][shadow=true]
因此,似乎出于某种我不知道的原因,我可以通过模板本身调用模板,但不能通过父模板调用模板,我不明白为什么会出现这种情况。有人能解释一下吗?
答案1
您还必须定义mytest
样式的父模板:
\documentclass{beamer}
\usepackage{ifthen}
\defbeamertemplateparent{blocks}[mytest]{block alerted begin,block alerted end}[1][outline]{[#1]}
\defbeamertemplate{block alerted begin}{mytest}[1][outline]{%
\ifthenelse{\equal{#1}{outline}}%
{%
Beginn Outline%
}%
{%
\ifthenelse{\equal{#1}{inverted}}
{%
Beginn Inverted%
}%
{%
}%
}%
}
\defbeamertemplate{block alerted end}{mytest}[1][outline]{%
\ifthenelse{\equal{#1}{outline}}%
{%
Beginn Outline%
}%
{%
\ifthenelse{\equal{#1}{inverted}}
{%
Beginn Inverted%
}%
{%
}%
}%
}
\setbeamertemplate{blocks}[mytest][outline]
\begin{document}
\begin{frame}[label=myframe]
\begin{alertblock}{}
Test
\end{alertblock}
\end{frame}
\setbeamertemplate{blocks}[mytest][inverted]
\againframe{myframe}
\setbeamertemplate{blocks}[mytest][outline]
\againframe{myframe}
\setbeamertemplate{block alerted begin}[mytest][inverted]
\setbeamertemplate{block alerted end}[mytest][inverted]
\againframe{myframe}
\end{document}