[Tex/LaTex] Highlight current section using alert in beamer

beamertable of contents

The following

\AtBeginSection[]
{
\begin{frame}<beamer>
  \frametitle{Outline}
  \tableofcontents[currentsection]
\end{frame}
}

inserts the table of contents at the beginning of each section, such that the current section is rendered normally and the others are shaded. I would like to have a similar effect but instead of shading the other sections, I'd like to alert the current one. Since, according to the manual, the allowed styles are show, shaded, and hide, I don't know how to accomplish this. Is there a canonical way to obtain this behavior?

Best Answer

You can set the section in toc and section in toc shaded colors appropriately:

\documentclass{beamer}


\AtBeginSection[]
{
\setbeamercolor{section in toc}{fg=alerted text.fg}
\setbeamercolor{section in toc shaded}{fg=structure}
\begin{frame}<beamer>
  \frametitle{Outline}
  \tableofcontents[currentsection]
\end{frame}
}

\begin{document}

\section{Test section one}
\begin{frame} test \end{frame}
\section{Test section two}
\begin{frame} test \end{frame}
\section{Test section three}
\begin{frame} test \end{frame}
\section{Test section four}
\begin{frame} test \end{frame}

\end{document}

enter image description here

If "other" sections should not be shaded, you can add

A complete example:

\documentclass{beamer}


\AtBeginSection[]
{
\setbeamercolor{section in toc}{fg=alerted text.fg}
\setbeamercolor{section in toc shaded}{bg=structure!20,fg=structure}
\setbeamertemplate{section in toc shaded}[default][100]
\begin{frame}<beamer>
  \frametitle{Outline}
  \tableofcontents[currentsection]
\end{frame}
}

\begin{document}

\section{Test section one}
\begin{frame} test \end{frame}
\section{Test section two}
\begin{frame} test \end{frame}
\section{Test section three}
\begin{frame} test \end{frame}
\section{Test section four}
\begin{frame} test \end{frame}

\end{document}

enter image description here