# Prevent hyperref from changing the color of section and subsection hyperlinks

I am trying to customize my themes, but also would like to use hyperref to get quick links for ease of navigation. However, hyperref seems to replace the color of all contents to its linkcolor option.

The MWE shows that the section and subsection titles colors are blue but I actually sat them to orange and white.

The answer in Changing hyperlink color changes beamer section header colors proposes not using \hypersetup, but I would like to use it anyway because colored equations referencing makes it easier to find equations quickly and see where they are used in text. Can I enable link coloring as normal but exclude sections and subsections?

Here is the result I want

\documentclass[aspectratio=169, xcolor={x11names}]{beamer}

\usecolortheme{seahorse}
\setbeamercolor{palette primary}{fg=black, bg=LemonChiffon2}
\setbeamercolor{palette secondary}{fg=white, bg=DarkOrange2}
\setbeamercolor{palette tertiary}{fg=black, bg=white}
\setbeamercolor{palette quaternary}{fg=black, bg=white}

\useoutertheme[]{miniframes}

\useinnertheme{inmargin}
\setbeamersize{sidebar width left=1cm, sidebar width right=1cm}
\setbeamersize{text margin left=0.5mm, text margin right=0.5mm}
\setbeamercovered{transparent=30}

\usepackage{hyperref}

\begin{document}

\section{My Section}

\subsection{My Subsection}

\begin{frame}
contents
\end{frame}

\section{My Section}

\subsection{My Subsection}

\begin{frame}
contents
\end{frame}

\section{My Section}

\subsection{My Subsection}

\begin{frame}
contents
\end{frame}

\end{document}

• Don't load \usepackage{hyperref}, beamer already loads it for you Mar 23 '19 at 11:20
• Does it really make difference if I loaded it? I load all packages even if I know that the class loads them. This is just because I write my own notes about each package and what commands I need from it. It also helps me copy preambles from one document to another Mar 23 '19 at 11:34
• If you load packages that are already loaded, you risk option clashes. So better avoid this by only loading the packages you really need for this specific document. Mar 23 '19 at 11:37

\documentclass[aspectratio=169, xcolor={x11names}]{beamer}

\usecolortheme{seahorse}
\setbeamercolor{palette primary}{fg=black, bg=LemonChiffon2}
\setbeamercolor{palette secondary}{fg=white, bg=DarkOrange2}
\setbeamercolor{palette tertiary}{fg=black, bg=white}
\setbeamercolor{palette quaternary}{fg=black, bg=white}

\useoutertheme[]{miniframes}

\useinnertheme{inmargin}
\setbeamersize{sidebar width left=1cm, sidebar width right=1cm}
\setbeamersize{text margin left=0.5mm, text margin right=0.5mm}
\setbeamercovered{transparent=30}

\usepackage{hyperref}

\makeatletter
\makeatletter

\begin{document}

\section{My Section}

\subsection{My Subsection}

\begin{frame}
contents
$$a \label{eq}$$
\end{frame}

\section{My Section}

\subsection{My Subsection}

\begin{frame}
contents \ref{eq}
\end{frame}

\section{My Section}

\subsection{My Subsection}

\begin{frame}
contents
\end{frame}

\end{document}


• This will set only one color for sections in the secondary palette and tertiary palette. I would like white colored text in the secondary palette and orange colored text in the tertiary Mar 23 '19 at 11:14
• Hm. Not sure if I get what color you want, but you could try \makeatletter \newcommand\disablecolorlinks{\def\HyColor@UseColor##1{}} \addtobeamertemplate{headline}{\disablecolorlinks{}}{} Mar 23 '19 at 11:26
• Yes, this works. Would you like to update your answer to accept it? Mar 23 '19 at 11:32
• I edited the answer. Mar 23 '19 at 11:41