Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to define a custom theme for beamer. I would like to have a horizontal list of all sections but with a character between them. What I have is:

\setbeamertemplate{headline}[text line]{\insertsectionnavigationhorizontal{\paperwidth}{}{}}

And what I would like to see is something like:

Section1 | Section2 | Section3 | Section4

Is that possible?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Yes, it is possible; not trivial, but possible:

(I will add some explanation when I have time)

\documentclass{beamer}
\usepackage{totcount}
\usepackage{tikz}

\regtotcounter{section}
\newcounter{vertrules}

\setbeamercolor{section in head/foot}{fg=green!40!black}
\setbeamercolor*{frametitle}{fg=green!40!black}
\setbeamercolor{myheadline}{fg=green!40!black,bg=green!10}

\setbeamertemplate{headline}
{%
  \begin{beamercolorbox}[wd=\paperwidth]{myheadline}
    \vskip1.5ex%
    \insertsectionnavigationhorizontal{\paperwidth}{\hskip0pt}{\hskip-12pt}\vskip2pt
  \end{beamercolorbox}%
  \setcounter{vertrules}{\totvalue{section}}
  \ifnum\thevertrules<2 \else
  \addtocounter{vertrules}{-1}
  \begin{tikzpicture}[remember picture,overlay]
  \foreach \i in {1,2,...,\thevertrules}
  \draw[ultra thick,green!40!black] (\i*\sectionboxwd+0.5\i,0) -- (\i*\sectionboxwd+0.5\i,1);
  \end{tikzpicture}%
  \fi%
}

\setbeamertemplate{section in head/foot}{%
    \hspace*{-6pt}\setlength\fboxsep{0pt}%
    \parbox[c][4ex][t]{\dimexpr\sectionboxwd-5pt\relax}{%
      \hfill\parbox{\dimexpr\sectionboxwd-12pt\relax}{%
      \raggedright\insertsectionhead%
      }\hfill\mbox{}%
    }\hspace*{6pt}%
}

\newlength\sectionboxwd

\AtBeginDocument{%
  \ifnum\totvalue{section}>0 
    \setlength\sectionboxwd{\dimexpr\paperwidth/\totvalue{section}\relax}
  \else
    \setlength\sectionboxwd{\paperwidth}
  \fi
} 

\begin{document}

\section{Test Section One with a really long title}
\begin{frame}\frametitle{Test frame one}test\end{frame}
\section{Test Section Two}
\begin{frame}\frametitle{Test frame two}test\end{frame}
\section{Test Section Three}
\begin{frame}\frametitle{Test frame three}test\end{frame}
\section{Test Section Four}
\begin{frame}\frametitle{Test frame four}test\end{frame}

\end{document}

And some images showing the result with the vertical rules:

enter image description here

enter image description here

enter image description here

enter image description here

share|improve this answer
    
Thanks for your help! That's nearly what I was looking for, can you give me a hint how to modify that code to have everything left aligned? ---------------------------------------------- Section1 | Section2 | Section3 ---------------------------------------------- And maybe how to replace the line with a character. Thanks in advance! If that's not possible or too complex, don't mind :) –  Bertram Nudelbach Jun 5 '12 at 7:40
    
Oh dear, I'm not able to format that comment correct. What I mean is, that the sections have only the minimal width required for showing the text. Although this might have the result that not all sections were shown if too much sections are defined (as with normal \insertsectionnavigationhorizontal). –  Bertram Nudelbach Jun 5 '12 at 7:49

So I played around a bit with the solution provided by Gonzola Medina and here is what I wanted to have - thanks again!

\setbeamertemplate{section in head/foot shaded}{%  
\color{white}\insertsectionhead\ \ \ \ |  
}  

\setbeamertemplate{section in head/foot}{%  
\insertsectionhead\color{white}\ \ \ \ |  
}  

\setbeamertemplate{headline}{%  
\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex]{myheadline}  
\Tiny\hspace*{4mm} {\hspace*{2ex}\color{white}|\hspace*{-2ex}}\insertsectionnavigationhorizontal{0ex}{}{}  
\end{beamercolorbox}%  
}

It prints all sections and places | between them. The color white is because it should be white for my color scheme.

The only thing I don't know is how to change the margin/padding of each section. You can see the trailing spaces I added. I did this to have the same space before and after each section.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.