1

I'm making a presentation in Warsaw theme of Beamer with headline structure as follows:

\setbeamertemplate{headline}{%
\leavevmode%
  \hbox{%
    \begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex]{palette quaternary}%
    \insertsectionnavigationhorizontal{\paperwidth}{}{\hskip0pt plus1filll}
    \end{beamercolorbox}%
  }
}

How to display only three sections or like so, previous-current-after sections, with highlighting current section ? As I've a large number of sections ~10, all of them can not be displayed in headline. Please suggest.

Ignasi
  • 136,588
  • I think that this kind of headline intention is to show audience in which point of the presentation you are. If you suppress part of this information, headline is useless. Did you considered to change to a sidebar theme? – Ignasi Apr 28 '15 at 12:14
  • Thank you Ignasi for your reply. If you are asking about using themes like Bergen or Marburg , then it is the same reason I did not used default Warsaw theme; i.e. I need more space in slides to add images. And these themes consume space from it. So I used above type of headline , so that it can be confined within a line with less use of space. – shreekant Apr 28 '15 at 13:55
  • Have a look at this answer http://tex.stackexchange.com/a/54956/36296 – samcarter_is_at_topanswers.xyz Apr 28 '15 at 15:06
  • Or at this http://tex.stackexchange.com/questions/96824/set-maximum-number-of-table-of-contents-in-the-header – samcarter_is_at_topanswers.xyz Apr 28 '15 at 15:07
  • Thank you samcarter for your reply. This solves the problem little bit :) Is it possible to keep it as line at top instead of generating bands at top ? – shreekant Apr 28 '15 at 15:33
  • Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – samcarter_is_at_topanswers.xyz Apr 28 '15 at 17:16
  • Sorry samcarter for the inconvenience faced by you. Here is smallest clone of the tex file i am using. \documentclass{beamer} \usetheme{Warsaw} \setbeamertemplate{navigation symbols}{} \newcommand\oldmacro{}% \let\oldmacro\insertshorttitle% \renewcommand\insertshorttitle{% \oldmacro\hfill% \insertframenumber,/,\inserttotalframenumber} \usepackage{graphicx} \title[tit1]{tit2} \author[nam1]{nam2}
    \institute[]{nam3}
    \date{\today}
    \begin{document} \begin{frame} \titlepage \end{frame} \begin{frame} \frametitle{Outline} \tableofcontents \end{frame} \end{document}
    – shreekant Apr 29 '15 at 14:52
  • Here when I wanted to add sections (which in fact large in number ~10, with following command just before \end{document} ) \section{sec1} \begin{frame} \frametitle{sec1}
    \end{frame} Then you can see, these generate bands at top of each slide. So I added commands (what mentioned in my question) in preamble to generate a line instead of band. Hope this information is adequate. Sorry again for inconvenience.
    – shreekant Apr 29 '15 at 15:03

1 Answers1

1
\documentclass{beamer}

\usetheme{Warsaw}

\AtBeginSection[]{\label{sec:\thesection}}

\usepackage{totcount}
\newcounter{totalsection}
\regtotcounter{totalsection}

\AtBeginDocument{%
  \pretocmd{\section}{\refstepcounter{totalsection}}{}{}%
}%

\newcounter{start}
\newcounter{stop}

\usepackage{pgffor}

\setbeamercolor{section in head/foot}{fg=white}
\setbeamercolor{section in head/foot shaded}{fg=white!60!bg}

\setbeamertemplate{headline}{%
\leavevmode%
  \hbox{%
    \begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex]{palette quaternary}%
        \ifnum\value{section}>0%
            \quad
            \setcounter{start}{\value{section}}
                \setcounter{stop}{\value{section}}
                \ifnum\value{section}>1
                    \addtocounter{start}{-1}
                \fi
                \ifnum\value{section}<\totvalue{totalsection}
                    \addtocounter{stop}{1}
                \fi     
                \foreach \i in {\thestart,...,\thestop}{%
                    \ifnum\i=\value{section}
                        \usebeamercolor[fg]{section in head/foot}
                    \else   
                        \usebeamercolor[fg]{section in head/foot shaded}
                    \fi
                    \hfill\hyperlink{sec:\i}{\nameref{sec:\i}}
                }
                \hfill\quad
            \fi
    \end{beamercolorbox}%
  }
}



\begin{document}

\section{test1}\begin{frame}abc\end{frame}  
\section{test2}\begin{frame}abc\end{frame}  
\section{test3}\begin{frame}abc\end{frame}  
\section{test4}\begin{frame}abc\end{frame}  
\section{test5}\begin{frame}abc\end{frame}  
\section{test6}\begin{frame}abc\end{frame}  
\section{test7}\begin{frame}abc\end{frame}  
\section{test8}\begin{frame}abc\end{frame}  
\section{test9}\begin{frame}abc\end{frame}  
\section{test10}\begin{frame}abc\end{frame} 
\section{test11}\begin{frame}abc\end{frame}     

\end{document}

enter image description here