# Only 3 items in navigation bar, is that possible?

I saw a beamer presentation that shows only 3 items in navigation bar (the last one, the current -highlighted- and the next). How is that possible? I am using Warsaw theme, and I have (until now) 7 sections, so the navigation bar is too long…

-

Here's a possible solution; the idea is to have two auxiliary commands \prevsection and \nextsection to hold the names of the previous and next section to the current section; those commands will be used in the headline template to display the required information instead of the usual navigation bar.

The updating of \prevsection, \nextsection is done internally using a redefinition of \beamer@section.

All that you have to do is to fill in the mandatory argument for the commands \sectioni, \sectionii, ... ,\sectionviii with the information to be displayed in the navigation bar.

\documentclass{beamer}
\usetheme{Warsaw}

\newcounter{prevsection}
\newcounter{nextsection}

\newcommand\prevsection{}
\newcommand\nextsection{}

\makeatletter
\long\def\beamer@section[#1]#2{%
\beamer@savemode%
\mode<all>%
\ifbeamer@inlecture%
\refstepcounter{section}%
\beamer@ifempty{#2}%
{\long\def\secname{#1}\long\def\lastsection{#1}}%
\long\def\secname{#2}%
\long\def\lastsection{#1}%
{\the\beamer@tocsectionnumber}}}%
\beamer@ifempty{#1}{}{%
}%
\beamer@sectionstartpage=\c@page%
\beamer@subsectionstartpage=\c@page%
\def\insertsubsection{}%
\def\insertsubsubsection{}%
\def\lastsubsection{}%
\Hy@writebookmark{\the\c@section}{\secname}{Outline\the\c@part.\the\c@section}{2}{toc}%
\hyper@anchorstart{Outline\the\c@part.\the\c@section}\hyper@anchorend%
\beamer@ifempty{#2}{\beamer@atbeginsections}{\beamer@atbeginsection}%
\fi%
\beamer@resumemode
\setcounter{prevsection}{\thesection}%
\setcounter{nextsection}{\thesection}%
\gdef\prevsection{\csname section\romannumeral\theprevsection \endcsname}%
\renewcommand\nextsection{\csname section\romannumeral\thenextsection \endcsname}%
}%

{%
\leavevmode%
\@tempdimb=2.4375ex%
\ifnum\beamer@subsectionmax<\beamer@sectionmax%
\multiply\@tempdimb by\beamer@sectionmax%
\else%
\multiply\@tempdimb by\beamer@subsectionmax%
\fi%
\ifdim\@tempdimb>0pt%
\vbox to \@tempdimb{%
\ifnum\thesection=1 \else%
\vfill{\color{fg!40!bg}\prevsection}%
\fi%
\ifnum\thesection=\beamer@sectionmax \else%
\vfill{\color{fg!40!bg}\nextsection}%
\fi\vfill%
}%
\end{beamercolorbox}%
\end{beamercolorbox}%
\fi%
}%
\makeatother

% Here you put the names that will go in the navigation bar
\newcommand\sectioni{test one}
\newcommand\sectionii{test two}
\newcommand\sectioniii{test three}
\newcommand\sectioniv{test four}
\newcommand\sectionv{test five}
\newcommand\sectionvi{test six}
\newcommand\sectionvii{test seven}
\newcommand\sectionviii{test eight}

\begin{document}

\section{test one}
\begin{frame}test\end{frame}

\section{test two}
\begin{frame}test\end{frame}

\section{test three}
\begin{frame}test\end{frame}

\section{test four}
\begin{frame}test\end{frame}

\section{test five}
\begin{frame}test\end{frame}

\end{document}