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.

In my presentation composed with the beamer class I have the following piece of code:

\documentclass[dvips, 9pt, unicode, t]{beamer}
\usepackage{ifthen}
\usetheme{CambridgeUS}

\setbeamertemplate{footline}{%
\leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
    \usebeamerfont{author in head/foot}\hspace*{1em}good footline
  \end{beamercolorbox}}%
\vskip0pt}

\begin{document}

  \begin{frame}
    Frame one (with footline)
  \end{frame}

  \begin{frame}
    Frame two (with footline)
  \end{frame}

\end{document}

which gives the right footlines. However, the following piece of code

\documentclass[dvips, 9pt, unicode, t]{beamer}
\usepackage{ifthen}
\usetheme{CambridgeUS}

\newcommand\Switttch{0}
\setbeamertemplate{footline}{%
\ifthenelse{\equal{\Switttch}{0}}{}{\leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
    \usebeamerfont{author in head/foot}\hspace*{1em}bad footline
  \end{beamercolorbox}}%
  \vskip0pt}}

\begin{document}

  \begin{frame}
    Frame one (without footline)
  \end{frame}

  \renewcommand\Switttch{1}
  \begin{frame}
    Frame two (with footline)
  \end{frame}

\end{document} 

gives a footline on second frame which overlaps with the bottom line of the page. What's wrong with the second piece of code? (I want to switch on and switch off the footline for different frames.)

share|improve this question
    
Kindly post a complete MWE starting from \documentclass and ending with \end{document} –  Harish Kumar Oct 18 '12 at 22:51

2 Answers 2

up vote 2 down vote accepted

(Moved my answer from a comment to here, and now put in the context of the MWE given.)

beamer only calculates the size (height) of the headlines and footlines once (at \begin{document}, I think). If you wish to have footlines of different heights on different slides and you don't want to take egreg's approach of using struts to make all footline's appear the same height, you can to ask beamer to recalculate this by calling \beamer@calculateheadfoot before every frame in which the footline height changes from the previous frame.

I have modified your syntax for changing \Switttch to facilitate this.

\documentclass[dvips, 9pt, unicode, t]{beamer}
\usepackage{ifthen}
\usetheme{CambridgeUS}

\newcommand\Switttch{0}
\makeatletter
\newcommand*\setSwitttch[1]{\renewcommand\Switttch{#1}\beamer@calculateheadfoot}
\makeatother
\setbeamertemplate{footline}{%
\ifthenelse{\equal{\Switttch}{0}}{}{\leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
    \usebeamerfont{author in head/foot}\hspace*{1em}bad footline
  \end{beamercolorbox}}%
  \vskip0pt}}

\begin{document}

  \begin{frame}
    Frame one (without footline)
  \end{frame}

  \setSwitttch{1}
  \begin{frame}
    Frame two (with footline)
  \end{frame}

\end{document}

The footline now appears in the correct position on both slides, and the navigation buttons/main slide content now finishes just above the footline.

share|improve this answer
    
Works perfect. The only question. What does * in command \newcommand*\setSwitttch[1]{\renewcommand\Switttch{#1}\beamer@calculateheadfoot‌​} mean? PS For those who don't know sense of commands \makeatletter and \makeatother see here –  godsdog Oct 23 '12 at 10:56
1  
@godsdog. The star means that the command is not to be declared \long, so it will not accept paragraph breaks in its argument (that is normally a mistake that it is helpful to catch; the error will be along the lines of paragraph ended before \setSwitttch was complete). See e.g. this question for more: tex.stackexchange.com/q/1050/17427 –  cyberSingularity Oct 23 '12 at 14:05

I believe that the simpler definition

\setbeamertemplate{footline}{%
  \ifthenelse{\equal{\Switttch}{0}}
    {\vrule height 2.25ex depth 1ex width 0pt}
    {\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
     \usebeamerfont{author in head/foot}\hspace*{1em}Good footline
     \end{beamercolorbox}}}

will do what you're looking for.

share|improve this answer

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.