4

Follow up to https://tex.stackexchange.com/a/174213/36296

Long story short: I wondered how to pass arguments to custom frame options. For example add customisable an image to the frametitle.


And on special request from Leon Meier a MWE (I wonder how samcarter could answer this question without it):

\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
    @LeonMeier Can be found in my self answer I posted together with this questions to share this information with the nice people from this community. – user36296 Aug 11 '17 at 17:40
  • @LeonMeier Specially for you I added one :) – user36296 Aug 11 '17 at 18:10
5
\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.