0

My goal is to create a fancier agenda page and for this I would like to define e.g. an icon and a color for the section that shall be used to format the table of contents. Maybe finally the ToC is actually formatted through TikZ and not as a simple list, hence I am interested in general how to store more information than just the section name in the *.toc file and re-use it with the \tableofcontents-command or maybe define my own \fancytoc-command.

Here is an MWE that defines a \sectionsymbol and a sectioncolor, as well as a command to set them along with the section title \myfancysection.

\documentclass{beamer}

\usepackage{fontawesome}

\definecolor{sectioncolor}{rgb}{0,0,0}
\newcommand{\sectionsymbol}{\relax}
\newcommand{\sectionstart}{\frame{\textcolor{sectioncolor}{\sectionsymbol\ \secname}}}

\newcommand{\myfancysection}[3]{\colorlet{sectioncolor}{#1}\renewcommand{\sectionsymbol}{#2}\section{#3}}

\begin{document}
\begin{frame}{Agenda}
\tableofcontents
\end{frame}

\myfancysection{red}{\faAmbulance}{My red section}
\sectionstart

\myfancysection{green}{\faAutomobile}{My green section}
\sectionstart


\begin{frame}{Agenda as I wanted to be automatically}
\begin{description}[\faAutomobile]
    \item[\color{red}\faAmbulance] \textcolor{red}{My red section}
    \item[\color{green}\faAutomobile] \textcolor{green}{My green section}
\end{description}
\end{frame}
\end{document}

enter image description here

The last frame is just an illustration of how one could use the additional information to format the ToC, as mentioned I could also imagine to build the ToC through TikZ and I don't necessarily want to have a solution that only stores a color and a symbol, but maybe a list of key-value pairs, if that is not too advanced.

1 Answer 1

0

After some more investigation, I found a neat way, combining write contents of an environment to document and toc and How to add additional information to chapters and their entry in the table of contents? and How to create a fancy table of contents for Beamer

The basic idea is to write some commands into the *.toc-file and then reference them in the section in toc template. Putting everything together we get:

\documentclass{beamer}

\usepackage{fontawesome}

\definecolor{sectioncolor}{rgb}{0,0,0}
\newcommand{\sectionsymbol}{\relax}
\newcommand{\sectionstart}{\frame{\textcolor{sectioncolor}{\sectionsymbol\ \secname}}}

\newcommand{\myfancysection}[3]{\addtocontents{toc}{%
\protect\colorlet{sectioncolor}{#1}}\colorlet{sectioncolor}{#1}%
\addtocontents{toc}{\protect\renewcommand{\protect\sectionsymbol}{\protect#2}}\renewcommand{\sectionsymbol}{#2}\section{#3}}

\setbeamertemplate{section in toc}{\textcolor{sectioncolor}{\sectionsymbol\ \inserttocsection}}

\begin{document}
\begin{frame}{Agenda}
\tableofcontents
\end{frame}

\myfancysection{red}{\faAmbulance}{My red section}
\sectionstart

\myfancysection{green}{\faAutomobile}{My green section}
\sectionstart

\end{document}

And on the agenda page:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .