Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am customising the footer of my Beamer slides. The footer displays the title of the slides, followed by a ":", and then the current section title. This works fine if the current section is defined. However, if the section is not defined, I am left with the current title followed by a dangling colon. I would like the colon not to be displayed if the current section is not defined.

So, how do I determine if the current slide's section is defined, and how do I use this in a conditional in the footer? For completeness, it would also be helpful to know how one would determine if the current subsection is defined.

My attempt so far:

\begin{beamercolorbox}[wd=.85\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
   \usebeamerfont{author in head/foot}
   \hspace*{2ex}\insertshorttitle  % insert title in footer       
   \, : \insertsection             % insert current section [should only be done if section defined] 
\end{beamercolorbox}%

% more code to insert the slide number in the footer (not shown)
share|improve this question
add comment

1 Answer 1

up vote 7 down vote accepted

If no previous \section exists \insertsection is simply empty (at least in my tests). So you could test for this using:

\ifx\insertsection\empty
     % it is empty
\else
    it is not
\fi

Applied to your code:

\begin{beamercolorbox}[wd=.85\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
   \usebeamerfont{author in head/foot}
   \hspace*{2ex}\insertshorttitle  % insert title in footer       
   \ifx\insertsection\empty\else
      \, : \insertsection             % insert current section [should only be done if section defined] 
   \fi
 \end{beamercolorbox}%
share|improve this answer
    
Thanks for your quick reply. This works perfectly! For subsections, you can simply apply the conditional to \insertsubsection. –  Steve Jun 28 '11 at 13:09
    
In your first code block there is an \if instead of a \fi. –  Wauzl Oct 17 '12 at 7:58
    
@Wauzl: Thanks! Fixed now. –  Martin Scharrer Oct 17 '12 at 16:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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