I'm doing my presentation in beamer and I use warsaw theme. I have around 5-6 sections and they are all mentioned at the top of every page. This makes available frame space smaller. Can I limit this number by 3? For example, to show previous, current and next sections.

MWE:

\documentclass{beamer}

\mode<presentation>
{

\usetheme{Warsaw}
\usefonttheme[onlysmall]{structurebold}
}

\begin{document}
\section{Test 1}
\begin{frame} \end{frame}
\section{Test 2}
\begin{frame} \end{frame}
\section{Test 3}
\begin{frame} \end{frame}
\section{Test 4}
\begin{frame} \end{frame}
\section{Test 5}
\begin{frame} \end{frame}

\end{document}

-

## Version 1

Hi you could alter the macro which inserts the navigation list.

    \documentclass{beamer}

\makeatletter
\hbox to #1{%
\vskip0.5625ex%
\def\slideentry##1##2##3##4##5##6{}%
\def\sectionentry##1##2##3##4##5{%
\ifnum##5=\c@part%
\setbox\beamer@tempbox=\hbox{%
\hskip0.3cm%
\ifnum\c@section=##1%
\else%
{%
\ifnum##1 = \c@section%
\else%
\ifnum##1 = \c@section%
\else
\fi
\fi
}%
\fi\hskip0.3cm}}}%
\ht\beamer@tempbox=1.6875ex\dp\beamer@tempbox=0.75ex%
\box\beamer@tempbox\fi}%
\makeatother

\usetheme{Warsaw}
\usefonttheme[onlysmall]{structurebold}

\begin{document}
\section{Test 1}
\begin{frame} \end{frame}
\section{Test 2}
\begin{frame} \end{frame}
\section{Test 3}
\begin{frame} \end{frame}
\section{Test 4}
\begin{frame} \end{frame}
\section{Test 5}
\begin{frame} \end{frame}

\end{document}

Here two new conditionals are introduced, which check for the distance between the active section (stored in \c@section) and the printed sections.

The result is this:

![enter image description here][1]


## Version 2

This version provides a better fit to the size of three lines. Please note, that the height of the colored beamer box is adjusted manually.

\documentclass{beamer}
\usetheme{Warsaw}
\usefonttheme[onlysmall]{structurebold}

\makeatletter
\newcount\c@p
\newcount\c@m
\hbox to #1{%
\vskip0.5625ex%
\def\slideentry##1##2##3##4##5##6{}%
\def\sectionentry##1##2##3##4##5{%
\ifnum##5=\c@part%
\c@p=\c@section%
\c@m=\c@section%
\ifnum\c@section=##1%
\setbox\beamer@tempbox=\hbox{%
\else%
\ifnum##1=\c@m%
\setbox\beamer@tempbox=\hbox{%
%
\else%
\ifnum##1=\c@p%
\setbox\beamer@tempbox=\hbox{%
%
\else%
%
\fi%
\fi%
%
\fi%%
%

\ht\beamer@tempbox=1.6875ex%
\dp\beamer@tempbox=0.75ex%
\box\beamer@tempbox\fi}%

{%
\leavevmode%
\@tempdimb=3em%
\ifdim\@tempdimb>0pt%
\end{beamercolorbox}%
\end{beamercolorbox}%
\fi%
}

\makeatother

\begin{document}
\section{Test 1}
\begin{frame} \end{frame}
\section{Test 2}
\begin{frame} \end{frame}
\section{Test 3}
\begin{frame} \end{frame}
\section{Test 4}
\begin{frame} \end{frame}
\section{Test 5}
\begin{frame} \end{frame}

\end{document}


Again the if structure picks the wanted entries. But in this case the box is only filled when needed. I also introduced two helper variables c@p and c@m to avoid too complicated grouping. This renders to:

and the following frame will look like this:

## Version 3

Now featuring three navigation elements at any time:

\documentclass{beamer}
\usetheme{Warsaw}
\usefonttheme[onlysmall]{structurebold}

\makeatletter
\newcount\c@p
\newcount\c@m
\newcount\c@pp
\newcount\c@mm
\hbox to #1{%
\vskip0.5625ex%
\def\slideentry##1##2##3##4##5##6{}%
\def\sectionentry##1##2##3##4##5{%
\ifnum##5=\c@part%
\c@p=\c@section%
\c@m=\c@section%
\c@pp=\c@section%
\c@mm=\c@section%
%
\ifnum \c@section=1
\ifnum\c@section=##1%
\setbox\beamer@tempbox=\hbox{%
\else%
\ifnum##1=\c@p%
\setbox\beamer@tempbox=\hbox{%
%
\else%
\ifnum##1=\c@pp%
\setbox\beamer@tempbox=\hbox{%
%
\else%
%
\fi%
\fi%
%
\fi%%
\else%
\ifnum \c@section=\beamer@sectionmax
\ifnum\c@section=##1%
\setbox\beamer@tempbox=\hbox{%
\else%
\ifnum##1=\c@m%
\setbox\beamer@tempbox=\hbox{%
%
\else%
\ifnum##1=\c@mm%
\setbox\beamer@tempbox=\hbox{%
%
\else%
%
\fi%
\fi%
%
\fi%%
\else%
\ifnum\c@section=##1%
\setbox\beamer@tempbox=\hbox{%
\else%
\ifnum##1=\c@m%
\setbox\beamer@tempbox=\hbox{%
%
\else%
\ifnum##1=\c@p%
\setbox\beamer@tempbox=\hbox{%
%
\else%
%
\fi%
\fi%
%
\fi%%
%
\fi
\fi
%

\ht\beamer@tempbox=1.6875ex%
\dp\beamer@tempbox=0.75ex%
\box\beamer@tempbox\fi}%

{%
\leavevmode%
\@tempdimb=3em%
\ifdim\@tempdimb>0pt%
\end{beamercolorbox}%
\end{beamercolorbox}%
\fi%
}

\makeatother

\begin{document}
\section{Test 1}
\begin{frame} \end{frame}
\section{Test 2}
\begin{frame} \end{frame}
\section{Test 3}
\begin{frame} \end{frame}
\section{Test 4}
\begin{frame} \end{frame}
\section{Test 5}
\begin{frame} \end{frame}

\end{document}


It important to say that his is hard coded. This applies on 3 elements only and is not quite versatile. What it does is easy: it checks if the current frame is the first or last and inserts the navigation accordingly.

I want to add that this kind of navigation is very reader unfriendly. One has to look very carefully to understand it.

The first slide would look like this:

-
it's just great, thanks! I love latex, but when I need to write 60 lines of code to implement such simple request, it drives me crazy... I'm wondering if there is standard solution for this. –  damluar Feb 5 '13 at 13:36
I didn't write all those lines. I just altered the original definition. That makes app. 15 loc to write. A standard solution won't never exist in the world of latex. At least for such high level things like here there is always a alternative way. If you're looking for an option... well someone has to implement it. And i think (qualified) help is always wellcome ;) –  bloodworks Feb 5 '13 at 13:40
hello, could you tell me please how I can add 2 logo images to this customized header? I tried adding \includegraphics into \setbeamertemplate{headline}, but compilation fails.. –  damluar Mar 14 '13 at 11:44