2

I try to use customize headline of footline of Warsaw theme. MWE as the following

\documentclass[dvipsnames, aspectratio=169]{beamer}
\usepackage{microtype}
\hypersetup{colorlinks=true, urlcolor=blue, linkcolor=blue}

\mode<presentation>
{
  \usetheme{Warsaw}
  \setbeamercovered{transparent}
}

\usepackage[english]{babel}

\usepackage{times}
\usepackage[T1]{fontenc}

\usecolortheme{crane}
\useoutertheme{split}
\usefonttheme[onlysmall]{structurebold}

\setbeamertemplate{headline}
{
  \leavevmode
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex]{section in head/foot}
      \hbox to .5\paperwidth{\hfil\color{white}{}\hfil}
  \end{beamercolorbox}
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex]{subsection in head/foot}
      \hbox to .5\paperwidth{\hfil\color{white}{Headline}\hfil}
  \end{beamercolorbox}
}

\setbeamertemplate{footline}
{
  \leavevmode
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex]{section in head/foot}
      \hbox to .5\paperwidth{\hfil\color{white}{}\hfil}
  \end{beamercolorbox}
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex]{subsection in head/foot}
      \hbox to .5\paperwidth{\hfil\color{white}{Footline}\hfil}
  \end{beamercolorbox}
}

\beamertemplatenavigationsymbolsempty

\begin{document}
    \section{The First Section}
        \subsection{The First Subsection}
            \begin{frame}[t]{}
                \frametitle{Hello World}
            \end{frame}
\end{document}

The generated page is as the following enter image description here

As can be seen, the footline is OK. However for headline, there is an extra white line on top of the page.

What is the difference between headline and footline causing this?

==== New findings =====

Find that add a % between 2 beamercolorbox will resolve the issue

\setbeamertemplate{headline}
{
  \leavevmode
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex, leftskip=2ex,rightskip=2ex]{section in head/foot}
      \hbox to .5\paperwidth{\hfil\color{white}{}\hfil}
  \end{beamercolorbox}% <-add this "%" will resolve the issue
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex, leftskip=2ex,rightskip=2ex]{subsection in head/foot}
      \hbox to .5\paperwidth{\hfil\color{white}{Headline}\hfil}
  \end{beamercolorbox}
}

Looks like a in line comment makes the difference. Not sure what is the root cause.

2

1 Answer 1

2

A new line becomes a space.

Your % simply makes TeX ignore the newline character and therefore ignore a space between the first two heading boxes (50% left, 50% right stuff). Because TeX breaks at glue (spaces have glue) automatically in horizontal mode (explicitly caused by \leavevmode), removing spaces forces all onto the same line. You might notice that the implicit space exists in both the header and footer lines (see the white space).

I am pretty sure that is what is going on.

As far answering the different behaviors by headline and footline

What is the difference between headline and footline causing this?

Finding the answer requires a painful search through the source code of beamer and how frames are built. If I find the reason, I will add it here.

Here is a simple document that repeats the letter "a" under two different conditions.

\documentclass{article}

\begin{document}

\newcount\step%init

\step=0
\loop
a
\ifnum\step<100
\advance\step by 1
\repeat

\step=0
\loop
a% <- cancel out the implicit space caused by the new line here
\ifnum\step<100
\advance\step by 1
\repeat

\end{document}
1
  • Thank you Jonathan. The footline also has problem if don't add the %, it just don't show up because the added line is on top of it and we don't notice that until some content is added near it.
    – Eric Sun
    Oct 29, 2018 at 9:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .