1

I am trying to create an own variable like \author{} or \date{} in the LaTeX Beamer class. I need it for a title image that I use multiple times in the document. In the preamble I would like to specify the path to that image like \setTitleImage{path/to/image} and then in the document it should be possible to get that path by using \titleImage. I tried it with \newcommand{} but somehow it won't work as expected. Does anybody have an idea of how to do that?

Thank you very much in advance.

Daniel

1
  • Can you edit your question and add MWE with what you tried? Jan 26, 2017 at 9:44

3 Answers 3

2

beamer-fuberlin theme defines commands \titlegraphic and \inserttitlegraphic which can do what you want.

\documentclass{beamer}

\mode
<all>
{
  \renewcommand\titlegraphic[2][]{%
    \edef\inserttitlegraphic{%
      \ifx\relax#2\relax\else
        \noexpand\includegraphics[#1]{#2}%
      \fi}%
    }%
  \titlegraphic{}
}

\titlegraphic[width=5cm,keepaspectratio]{images/valley}

\begin{document}
\begin{frame}
\inserttitlegraphic{}
\titlegraphic[width=3cm,keepaspectratio]{example-image}
\inserttitlegraphic{}
\end{frame}
\end{document}

enter image description here

2

enter image description here

\documentclass{beamer}

\titlegraphic{\includegraphics[width=.5\textwidth]{example-image}}

\begin{document}


\begin{frame}
\inserttitlegraphic
\end{frame}

\end{document}
1

To answer your general question

I am trying to create an own variable like \author{} or \date{} in the LaTeX Beamer class.

e.g., with a variable containing a supervisor, we can define the following:

\newcommand\insertsupervisor{}  % Empty by default.
\newcommand\supervisor[1]{\renewcommand\insertsupervisor{#1}}

We can now use \supervisor{} in the preamble, just like we would use \author{}. To display the (content of) supervisor, we can use \insertsupervisor.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .