6

I'm working on a beamer theme custom tailored to my needs. Now I need to introduce a custom field or tag \MYTAG, similar to \frametitle that holds certain information and may be retrieved in the .sty-files via \insertMYTAG, again like \insertframetitle. I tried to mimick it but failed utterly. I would use it like in the following excerpt from my beamerouterthemeMYTHEME.sty

\defbeamertemplate*{frametitle}{MYTHEME theme}
{%
  \begin{beamercolorbox}[wd=\textwidth]{frametitle}
    \usebeamerfont{frametitle}
    \insertframenumber\hskip1em \insertframetitle \insertMYTAG%
    \usebeamerfont{headline}%
    \vskip.5ex  
  \end{beamercolorbox}
}

Can anyone give me a hint on how and where to define this tag?

1
  • tnx Stefan for inline highlighting
    – juisoo
    Mar 21 '16 at 14:17
5

Beamer has the original definitions for the different \insert-commands in the file beamerbasetitle.sty. This is the definition for the date command for example:

%
%
% The \date command
%
%
\def\date{\@dblarg\beamer@date}
\long\def\beamer@date[#1]#2{%
  \def\insertdate{#2}%
  \def\beamer@shortdate{#1}%
  }
\date{\today}


\newcommand\insertshortdate[1][]{%
  {%
    \let\thanks=\@gobble%
    \beamer@setupshort{#1}%
    \beamer@insertshort{\beamer@shortdate}%
  }}

For your needs you can use:

%
%
% The \MYTAG command
%
%
\newcommand{\MYTAG}{\@dblarg\beamer@MYTAG}
\long\def\beamer@MYTAG[#1]#2{%
  \def\insertMYTAG{#2}  %
  \def\insertshortMYTAG{#1}%
  }
\MYTAG[defaultShortMYTAG]{defaultLongMYTAG}

which will work analogously to \author[]{}, \date[]{}, \institute[]{} and so on.

3
  • Thanks for your answer. Do I need to define this command in the same file (i.e. beamerbasetitle.sty) or can I do this in my beamerthemeMYTHEME.sty? If I do the latter I get an ! Undefined control sequence on the line making the call with the default values (last line in your example).
    – juisoo
    Mar 21 '16 at 15:01
  • Dooh, stupid me. Seems like I misinterpreted the error message. I defined the command AFTER defining the outertheme which uses the \insertMYTAG command. Moving the definition up, it works now. Big thanks!
    – juisoo
    Mar 21 '16 at 15:08
  • Feels like it shouldn't matter where in your .sty file you put the definition. You need to have in in the .sty file or in your preamble surrounded by \makeatletter and \makeatother though. Anyhow, I'm glad it's of use to you! I spent quite some time understanding how beamer does this when I was creating a theme of my own.. :)
    – user49901
    Mar 21 '16 at 15:16

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.