# Problem with \setbeamertemplate{footline} when using \ifthenelse inside

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{%
\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{%
\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.)

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

(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
\makeatother
\setbeamertemplate{footline}{%
\ifthenelse{\equal{\Switttch}{0}}{}{\leavevmode%
\hbox{%
\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.

-
@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}