跟进https://tex.stackexchange.com/a/174213/36296
长话短说:我想知道如何将参数传递给自定义框架选项。例如,向框架标题添加可自定义的图像。
并且应 MWE Leon Meier 的特别请求(我想知道如果没有它,samcarter 如何回答这个问题):
\documentclass{beamer}
\usepackage{etoolbox}
\defbeamertemplate{frametitle}{mydefault}{%
\insertframetitle%
}
\defbeamertemplate{frametitle}{imagetitle}{%
\insertframetitle \includegraphics[width=0.1\textwidth]{example-image}%
}
\BeforeBeginEnvironment{frame}{%
\setbeamertemplate{frametitle}[mydefault]%
}
\makeatletter
\define@key{beamerframe}{imagetitle}[true]{%
\setbeamertemplate{frametitle}[imagetitle]%
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{bla}
left
\end{frame}
\begin{frame}[imagetitle]
\frametitle{bla}
right
\end{frame}
\begin{frame}
\frametitle{bla}
is left again
\end{frame}
\end{document}
答案1
\documentclass{beamer}
\usepackage{etoolbox}
\defbeamertemplate{frametitle}{mydefault}{%
\insertframetitle%
}
\defbeamertemplate{frametitle}{imagetitle}[1]{%
\insertframetitle \includegraphics[width=0.1\textwidth]{#1}%
}
\BeforeBeginEnvironment{frame}{%
\setbeamertemplate{frametitle}[mydefault]%
}
\makeatletter
\define@key{beamerframe}{imagetitle}[true]{%
\setbeamertemplate{frametitle}[imagetitle]{#1}%
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{bla}
left
\end{frame}
\begin{frame}[imagetitle=example-grid-100x100bp.pdf]
\frametitle{bla}
right
\end{frame}
\begin{frame}
\frametitle{bla}
is left again
\end{frame}
\end{document}