我希望获得我在以下 MWE 中描述的内容,即符号itemize
应该是
- 黑色外部块;
- 蓝色普通的块;
- 警报块中为红色;
- 示例块中为绿色。
梅威瑟:
\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{itemize}
\item Here in blue, I'd like it in black.
\end{itemize}
\begin{block}{A block}
\begin{itemize}
\item Here in blue, I'd like keep it in blue.
\end{itemize}
\end{block}
\begin{alertblock}{An alert block}
\begin{itemize}
\item Here in red, I'd like keep it in red.
\end{itemize}
\end{alertblock}
\begin{exampleblock}{An example block}
\begin{itemize}
\item Here in green, I'd like keep it in green.
\end{itemize}
\end{exampleblock}
\end{frame}
\end{document}
如果我查看beamercolorthemedefault.sty
,我会看到item
s 使用以下颜色进行着色local structure
:
- 如果我把 改为
local structure
黑色,普通的块变黑; - 如果我直接将
item
颜色改为黑色,那么所有块都是黑色。
那么,获得期望结果的正确方法是什么?
答案1
我会将普通文本的颜色设置local structure
为黑色,然后在启动普通块时将其更改为再次匹配的颜色structure
。这可以通过将颜色的重新定义添加到 beamer 模板来实现block begin
:
\documentclass{beamer}
\setbeamercolor{local structure}{parent=normal text}
\addtobeamertemplate{block begin}{\setbeamercolor{local structure}{parent=structure}}{}
\begin{document}
\begin{frame}
\begin{itemize}
\item Here in blue, I'd like it in black.
\end{itemize}
\begin{block}{A block}
\begin{itemize}
\item Here in blue, I'd like keep it in blue.
\end{itemize}
\end{block}
\begin{alertblock}{An alert block}
\begin{itemize}
\item Here in red, I'd like keep it in red.
\end{itemize}
\end{alertblock}
\begin{exampleblock}{An example block}
\begin{itemize}
\item Here in green, I'd like keep it in green.
\end{itemize}
\end{exampleblock}
\end{frame}
\end{document}
答案2
一种可能性是设置itemize item
颜色设置为黑色。这将影响全部环境itemize
,然后借助包,etoolbox
您可以恢复块内的所需颜色:
\usepackage{etoolbox}
\setbeamercolor{itemize item}{fg=black}
\AtBeginEnvironment{block}{\setbeamercolor{itemize item}{fg=structure}}
\AtBeginEnvironment{alertblock}{\setbeamercolor{itemize item}{fg=block title alerted.fg}}
\AtBeginEnvironment{exampleblock}{\setbeamercolor{itemize item}{fg=block title example.fg}}
完整示例:
\documentclass{beamer}
\usepackage{etoolbox}
\setbeamercolor{itemize item}{fg=black}
\AtBeginEnvironment{block}{\setbeamercolor{itemize item}{fg=structure}}
\AtBeginEnvironment{alertblock}{\setbeamercolor{itemize item}{fg=block title alerted.fg}}
\AtBeginEnvironment{exampleblock}{\setbeamercolor{itemize item}{fg=block title example.fg}}
\begin{document}
\begin{frame}
\begin{itemize}
\item Here in black, as desired.
\end{itemize}
\begin{block}{A block}
\begin{itemize}
\item Here in blue, I'd like keep it in blue.
\end{itemize}
\end{block}
\begin{alertblock}{An alert block}
\begin{itemize}
\item Here in red, I'd like keep it in red.
\end{itemize}
\end{alertblock}
\begin{exampleblock}{An example block}
\begin{itemize}
\item Here in green, I'd like keep it in green.
\end{itemize}
\end{exampleblock}
\end{frame}
\end{document}