TransWikia.com

Change bullet color in TOC for current section only

TeX - LaTeX Asked on February 1, 2021

In my TOC I would like to highlight the current section using a different color. Following the answers to this question, I have managed to change the text color of the current section using

setbeamercolor{section in toc}{fg=alerted text.fg, fg = red}

Now I also want to change the bullet color of the current section, but so far I’ve only managed to change to color of all the bullets in the TOC. How can I change the color of the current section bullet in the TOC?

Here’s a MWE:

documentclass[xcolor=dvipsnames]{beamer}
usecolortheme{dolphin} 
useinnertheme{rectangles} % adds squared bullets to TOC

% Define colors of our university
definecolor{UniGreen}{RGB}{ 0,139,0}
definecolor{TitleGreen}{RGB}{0,120,0}
setbeamercolor{title}{fg=TitleGreen}
setbeamercolor{structure}{fg=UniGreen} 
setbeamercolor{item projected}{bg=UniGreen, fg=white} %define color of the item-bullets
setbeamercolor{button}{bg=UniGreen}


AtBeginSection[]
{
setbeamercolor{section in toc}{fg=alerted text.fg, fg = red} % this changes name of current section to red as desired
setbeamercolor{section in toc shaded}{bg=structure!20, fg=structure}
setbeamertemplate{section in toc shaded}[default][100]
setbeamercolor{section number projected}{fg=alerted, bg=red,fg=white} % THIS LINE OF CODE CHANGES ALL THE BULLETS IN THE TOC TO RED
}

begin{document}
section{Test section one}
begin{frame} test end{frame}
section{Test section two}
begin{frame} test end{frame}

frame{frametitle{Outline}tableofcontents[currentsection, currentsubsection, subsectionstyle = show, subsubsectionstyle=show]
} 

section{Test section three}
begin{frame} test end{frame}
section{Test section four}
begin{frame} test end{frame}

end{document}

One Answer

It seems from what I found, it is not possible to achieve your desired behavior solely by redefining colors. Therefore my suggestion is to redefine the section in toc template. To do this, have a look into your inner theme, which is rectangles and by itself only loads setbeamertemplate{sections/subsections in toc}[square] so checkout beamerbaseauxtemplates.sty for the original definition and then use it as a basis for our square_special template, which looks as follows:

defbeamertemplate*{section in toc}{square_special}
{leavevmodeleftskip=1.75ex%
    llap{%
        usebeamerfont*{section number projected}%
        %usebeamercolor[bg]{section number projected}%
        vrule width2.25ex height1.85ex depth.4ex%
        hskip-2.25ex%
        hbox to2.25ex{hfilusebeamercolor[fg]{section number projected}inserttocsectionnumberhfil}}%
    kern1.25exinserttocsectionpar}

What did I do here? Well I removed the original selection of the background color for the section number projected and just use the already installed color (the one for the section title. However we still need the fg color of section number projected.

This is how it looks in your MWE:

documentclass[xcolor=dvipsnames]{beamer}
usecolortheme{dolphin} 
useinnertheme{rectangles} % adds squared bullets to TOC

% Define colors of our university
definecolor{UniGreen}{RGB}{ 0,139,0}
definecolor{TitleGreen}{RGB}{0,120,0}
setbeamercolor{title}{fg=TitleGreen}
setbeamercolor{structure}{fg=UniGreen} 
setbeamercolor{item projected}{bg=UniGreen, fg=white} %define color of the item-bullets
setbeamercolor{button}{bg=UniGreen}


AtBeginSection[]
{
    setbeamercolor{section in toc}{fg=alerted text.fg, fg = red} % this changes name of current section to red as desired
    setbeamercolor{section in toc shaded}{bg=structure!20, fg=structure}
    setbeamertemplate{section in toc shaded}[default][100]
    setbeamercolor{section number projected}{fg=alerted, bg=red,fg=white} % THIS LINE OF CODE CHANGES ALL THE BULLETS IN THE TOC TO RED
}

defbeamertemplate*{section in toc}{square_special}
{leavevmodeleftskip=1.75ex%
    llap{%
        usebeamerfont*{section number projected}%
        %usebeamercolor[bg]{section number projected}%
        vrule width2.25ex height1.85ex depth.4ex%
        hskip-2.25ex%
        hbox to2.25ex{hfilusebeamercolor[fg]{section number projected}inserttocsectionnumberhfil}}%
    kern1.25exinserttocsectionpar}

begin{document}
    section{Test section one}
    begin{frame} test end{frame}
section{Test section two}
begin{frame} test end{frame}

frame{frametitle{Outline}tableofcontents[currentsection, currentsubsection, subsectionstyle = show, subsubsectionstyle=show]
} 

section{Test section three}
begin{frame} test end{frame}
section{Test section four}
begin{frame} test end{frame}

end{document}

In general I would recommend some more simplifications, but I guess they are needed for your theme to work. This is how the Outline looks in my solution:

enter image description here

Answered by TobiBS on February 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP