投影機:頭部/腳部字體的顏色與背景/最終顏色不同

投影機:頭部/腳部字體的顏色與背景/最終顏色不同

是否可以獨立於頭部/腳部的 fg/bg 顏色來更改頭部/腳部部分的字體顏色?

編輯:這是一個 MWE:

\documentclass{beamer}
\useoutertheme{miniframes}
\setbeamercolor{palette tertiary}{fg=white,bg=black}

\begin{document}
\section{sec 1}
\begin{frame}
sec 1
\end{frame}

\section{sec 2}
\begin{frame}
sec 2
\end{frame}

\end{document}

如果我想將標題中活動部分名稱的顏色更改為紅色,將非活動部分名稱更改為藍色,但保留第三調色板的黑色和白色 - 我該怎麼做?

答案1

這應該有效:

\setbeamercolor{section in head/foot}{parent=palette tertiary,fg=red}
\setbeamertemplate{section in head/foot shaded}{\color{blue}\usebeamertemplate{section in head/foot}}

說明

看第一行:它說section in head/foot繼承顏色palette tertiary並重新定義fg=red。因此palette tertiary保持不變,活動部分標題設定為紅色。

同樣,我們想要類似\setbeamercolor{section in head/foot shaded}{parent=palette tertiary,fg=blue}非活動部分標題的東西。是的,我們可以設定這些顏色。但不,Beamer 永遠不會使用它。請參閱以下程式碼beamerbasenavigation.sty

\def\sectionentry#1#2#3#4#5{% section number, section title, page
  \ifnum#5=\c@part%
  \beamer@section@set@min@width
  \box\beamer@sectionbox\hskip1.875ex plus 1fill%
  \beamer@xpos=0\relax%
  \beamer@ypos=1\relax%
  \setbox\beamer@sectionbox=
  \hbox{\def\insertsectionhead{#2}%
    \def\insertsectionheadnumber{#1}%
    \def\insertpartheadnumber{#5}%
    {%
      \usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
      \ifnum\c@section=#1%
        \hyperlink{Navigation#3}{{\usebeamertemplate{section in head/foot}}}%
      \else%
        \hyperlink{Navigation#3}{{\usebeamertemplate{section in head/foot shaded}}}%
      \fi}%
  }%
  \ht\beamer@sectionbox=1.875ex%
  \dp\beamer@sectionbox=0.75ex%
  \fi\ignorespaces}

您可以看到有一個\ifnum\c@section=#1檢查是否應該遮蔽部分標題。但是,顏色主題已在 處應用\usebeamercolor[fg]{section in head/foot}。因此\setbeamercolor{section in head/foot shaded}{parent=palette tertiary,fg=blue}合法但無用。

但我們還有一次機會:在\ifnum出現\usebeamertemplate{section in head/foot shaded}.它的定義是beamerouterthemedefault.sty

\defbeamertemplate*{section in head/foot shaded}{default}[1][50]
{\color{fg!#1!bg}\usebeamertemplate{section in head/foot}}

請注意,bg這裡fg是來自 的顏色section in head/foot。這解釋了為什麼不活動的部分標題似乎是透明的。此時殘酷地分配一種新顏色可以解決您的問題。

相關內容