更改头部导航元素的背景颜色(和阴影)

更改头部导航元素的背景颜色(和阴影)

我想更改两个头部导航栏的背景(周围是一个矩形,类似于页脚),用于部分和子部分。这样当前活动的元素就有一种颜色,例如白色,而阴影元素则有另一种颜色,例如绿色。

以下是 mwe:

\documentclass[aspectratio=169]{beamer}

\usetheme{AnnArbor}
\usetheme{Singapore}
\usecolortheme{spruce}

\title{MWE}
\author{trylks}
\date{\today}
\newcommand{\easection}[4]{\section{#1}

\subsection{What}\begin{frame}#2\end{frame}
\subsection{Why}\begin{frame}#3\end{frame}
\subsection{Who}\begin{frame}#4\end{frame}}

\makeatletter
\setbeamertemplate{headline}
{%
\insertsectionnavigationhorizontal{\paperwidth}{}{}
\insertsubsectionnavigationhorizontal{\paperwidth}{}{}
}%
\makeatother

\begin{document}

\frame{\titlepage}
\easection{A}{a}{b}{c}
\easection{B}{d}{e}{f}
\easection{C}{g}{h}{i}
\easection{E}{j}{k}{l}
\easection{D}{m}{n}{o}
\frame{\titlepage}

\end{document}

答案1

你可以将导航栏包装到beamercolorboxes 中:

\documentclass[aspectratio=169]{beamer}

\usetheme{AnnArbor}
\usetheme{Singapore}
\usecolortheme{spruce}

\title{MWE}
\author{trylks}
\date{\today}
\newcommand{\easection}[4]{\section{#1}

\subsection{What}\begin{frame}#2\end{frame}
\subsection{Why}\begin{frame}#3\end{frame}
\subsection{Who}\begin{frame}#4\end{frame}}

\AtBeginDocument{%
  \setbeamercolor{section in head/foot}{bg=white!50!MSUgreen,fg=white}
}


\makeatletter
\setbeamertemplate{headline}
{%
  \leavevmode%
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex]{section in head/foot}%
    \insertsectionnavigationhorizontal{\paperwidth}{}{}
  \end{beamercolorbox}%
  
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex]{subsection in head/foot}%
    \insertsubsectionnavigationhorizontal{\paperwidth}{}{}
  \end{beamercolorbox}%
}%
\makeatother

\begin{document}

\frame{\titlepage}
\easection{A}{a}{b}{c}
\easection{B}{d}{e}{f}
\easection{C}{g}{h}{i}
\easection{E}{j}{k}{l}
\easection{D}{m}{n}{o}
\frame{\titlepage}

\end{document}

在此处输入图片描述

相关内容