I want a textline that shows all section titles in gray and the current section highlighted e.g. in black or boldprint as here:
title of sec1 | title of sec2 | tilte of sec3 | title of sec4
So far I've come to this point
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage{totcount}
\regtotcounter{section} % total amount of sections
\begin{document}
\begin{frame}
\section{First section} \label{sec:first_section}
\foreach \x in {1,...,\totvalue{section}}{
\ifnum\x=1
\ifnum\x=\value{section}
\textcolor{black}{\insertsection}
\else
\textcolor{gray}{\insertsection}
\fi
\else
\ifnum\x=\value{section}
| \textcolor{black}{\insertsection}
\else
| \textcolor{gray}{\insertsection}
\fi
\fi}
\\
Text of first section.\\
\vspace{2mm}
\section{Second section} \label{sec:second_section}
\foreach \x in {1,...,\totvalue{section}}{
\ifnum\x=1
\ifnum\x=\value{section}
\textcolor{black}{\insertsection}
\else
\textcolor{gray}{\insertsection}
\fi
\else
\ifnum\x=\value{section}
| \textcolor{black}{\insertsection}
\else
| \textcolor{gray}{\insertsection}
\fi
\fi}
\\
Text of second section.\\
\vspace{2mm}
\section{Third section} \label{sec:Third_section}
\foreach \x in {1,...,\totvalue{section}}{
\ifnum\x=1
\ifnum\x=\value{section}
\textcolor{black}{\insertsection}
\else
\textcolor{gray}{\insertsection}
\fi
\else
\ifnum\x=\value{section}
| \textcolor{black}{\insertsection}
\else
| \textcolor{gray}{\insertsection}
\fi
\fi}
\\
Text of third section.\\
\end{frame}
\end{document}
It highlights the right position of the section, but with \insertsection I - of course - get only the current section' name.
How can I get the right section names?
Can I call a section name by its number, something like \insertsection[\x] (which is not how it's working!)
or can I store the section names (or their labels) in a storage array and then 'pick' out the right one with \x from the for loop?
edit:
Thx, I've come one step further after adding
\setbeamercolor{section in toc}{fg=black} (after \begin{document})
and replacing \insertsection with \tableofcontents[sections={\x}] (for black) and \tableofcontents[sections={\x}, sectionstyle=shaded] for gray.
Is there a way to prevent the linebreak after the \tableofcontents entry?


\tableofcontents[currentsection,hideallsubsections]. Or take a look how it is defined to alternate it. – Skillmon Sep 08 '17 at 10:21\namerefto get the names based on the section number, see https://tex.stackexchange.com/a/303968/36296 for "work in action" – samcarter_is_at_topanswers.xyz Sep 08 '17 at 11:47