4

Here is an example of a part of a beamer style file I use for a presentation:

{
\nointerlineskip%
\begin{beamercolorbox}[wd=\paperwidth,ht=0.6cm,leftskip=.3cm,rightskip=.3cm]{frametitle}
\usebeamerfont*{frametitle}{\textbf{\insertframetitle}\textcolor{color1}{\insertframesubtitle}}\hfill \strut\par
\usebeamerfont{headline}%
\vskip.5ex
\end{beamercolorbox}
\nointerlineskip
\insertvrule{0.8pt}{black}
}

I would like to create a conditional statement based on the content of \framesubtitle, something like:

if \frametitle empty (or not defined)
  % do something
else
  % do this other thing
    {
    \nointerlineskip%
    \begin{beamercolorbox}[wd=\paperwidth,ht=0.6cm,leftskip=.3cm,rightskip=.3cm]{frametitle}
    \usebeamerfont*{frametitle}{\textbf{\insertframetitle}\textcolor{color1}{\insertframesubtitle}}\hfill \strut\par
    \usebeamerfont{headline}%
    \vskip.5ex
    \end{beamercolorbox}
    \nointerlineskip
    \insertvrule{0.8pt}{black}
    }
end

I tried to use the \@ifempty command but I could not figure a way to make it work... Would you have any idea on how to deal with this efficiently ?

  • 2
    If no \framesubtitle command is given in a frame, \insertframesubtitle is equivalent to \@empty, so you might try \ifx\insertframesubtitle\@empty<code for no subtitle>\else<code for subtitle>\fi Don't use braces around the code for the true and false parts. – egreg Oct 23 '14 at 21:32
2

The comment by egreg gave me the answer I was looking for, thanks ! In the end, the code looks like:

\defbeamertemplate*{frametitle}{smoothtree theme}{
    \nointerlineskip%
    \ifx\insertframesubtitle\@empty
        \begin{beamercolorbox}[wd=\paperwidth,ht=0.6cm,leftskip=.3cm,rightskip=.3cm]{frametitle}
        \usebeamerfont*{frametitle}{\textbf{\insertframetitle}\textcolor{color1}{\insertframesubtitle}}\hfill \strut\par%
        \usebeamerfont{headline}%
        \vskip.5ex
        \end{beamercolorbox}%
    \else
        \begin{beamercolorbox}[wd=\paperwidth,ht=0.6cm,leftskip=.3cm,rightskip=.3cm]{frametitle}
        \usebeamerfont*{frametitle}{\textbf{\insertframetitle}\textcolor{color1}{\insertframesubtitle}}\hfill \strut\par%
        \usebeamerfont{headline}%
        \vskip.5ex
        \end{beamercolorbox}%   
    \fi
    \nointerlineskip
    \insertvrule{0.8pt}{black}}

And I can modify the part of the code after \else at will...

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.