使用 itemize 更改文本的颜色

使用 itemize 更改文本的颜色

我正在创建自己的beamer主题。我可以使用 更改项目符号的颜色\setbeamercolor{}。但是如何更改项目符号后的文本颜色?我想在文件中使用它.sty

\documentclass[10pt]{beamer}

\definecolor{INBObrown}{RGB}{118, 91, 52}
\definecolor{INBOreddishbrown}{RGB}{182, 101, 70}
\definecolor{INBOblue}{RGB}{86, 152, 200}
\setbeamercolor{item}{fg=INBObrown}
\setbeamercolor{subitem}{fg=INBOreddishbrown}
\setbeamercolor{subsubitem}{fg=INBOblue}

\begin{document}

\begin{frame}
  \begin{itemize}
    \item This text should be in colour INBObrown
    \begin{itemize}
      \item This text should be in colour INBOreddishbrown
      \begin{itemize}
        \item This text should be in colour INBOblue
      \end{itemize}
    \end{itemize}
  \end{itemize}
\end{frame}

\end{document}

答案1

以下应该有效:

\setbeamercolor{itemize/enumerate body}{fg=INBObrown}
\setbeamercolor{itemize/enumerate subbody}{fg=INBOreddishbrown}
\setbeamercolor{itemize/enumerate subsubbody}{fg=INBOblue}

编辑:刚刚发现一个现有答案

答案2

以下工作:

在此处输入图片描述

\documentclass[10pt]{beamer}% http://ctan.org/pkg/beamer

\definecolor{INBObrown}{RGB}{118, 91, 52}
\definecolor{INBOreddishbrown}{RGB}{182, 101, 70}
\definecolor{INBOblue}{RGB}{86, 152, 200}
\setbeamercolor{item}{fg=INBObrown}
\setbeamercolor{subitem}{fg=INBOreddishbrown}
\setbeamercolor{subsubitem}{fg=INBOblue}

\makeatletter
\def\beamer@origitem{%
  \@inmatherr\item\@ifnextchar[\@item{\@noitemargtrue\@item[\@itemlabel]%
  \csname beamer@thcfg@\beameritemnestingprefix item\endcsname% Insert colour in \beamer@thc@fg
  \ifx\beamer@thc@fg\@empty\relax\else\color{\beamer@thc@fg}\fi% Execute colour
  }}
\makeatother

\begin{document}

\begin{frame}
  \begin{itemize}
    \item This text should be in colour INBObrown
    \begin{itemize}
      \item This text should be in colour INBOreddishbrown
      \begin{itemize}
        \item This text should be in colour INBOblue
      \end{itemize}
    \end{itemize}
  \end{itemize}
\end{frame}

\end{document}

\beamer@thc@fg这个想法是通过执行相关的键值宏来捕获当前项目(前景)颜色。然后,在设置项目标签后简单地应用该颜色。

答案3

刚刚遇到过类似的问题并使用了更简洁的解决方案

\let\olditem\item
\renewcommand{\item}{\olditem  \color{INBObrown}}

较低级别也同样如此。

相关内容