我正在创建一个,tcbtheorem
其颜色取自 beamer 的block
环境。出于某种原因,列表的颜色意外地coltitle
为 而不是coltext
。我该如何解决这个问题?
\documentclass{beamer}
\usepackage[theorems]{tcolorbox}
\newtcbtheorem{mythm}{My Theorem}{%
code={\usebeamercolor{block title}},
colback=gray!5,
coltext=black,
colbacktitle=bg,
coltitle=fg,
size=fbox,
}{}
\begin{document}
\begin{frame}
\begin{mythm}{}{}
Text
\begin{enumerate}
\item List
\end{enumerate}
\end{mythm}
\end{frame}
\end{document}
请注意枚举列表的字体颜色不是黑色,而是蓝色(与标题前景相同)。
答案1
我在写作时遇到了同样的问题https://ctan.org/pkg/beamertheme-tcolorbox。我的解决方法如下:
\documentclass{beamer}
\usepackage[theorems]{tcolorbox}
\setbeamercolor{block title}{bg=white}
\setbeamercolor{block body}{bg=gray!5,fg=black}
\makeatletter
\newcommand{\beamer@tcb@colini}[1][]{
\usebeamercolor{block body#1}
\colorlet{beamer@tcb@bodybg}{block body#1.bg}
\colorlet{beamer@tcb@bodyfg}{block body#1.fg}
\usebeamercolor{block title#1}
\colorlet{beamer@tcb@titlebg}{block title#1.bg}
\colorlet{beamer@tcb@titlefg}{block title#1.fg}
\usebeamercolor{normal text}
}
\newtcbtheorem{mythm}{My Theorem}{%
code={\beamer@tcb@colini},
colback=beamer@tcb@bodybg,
colbacktitle=beamer@tcb@titlebg,
coltext=beamer@tcb@bodyfg,
coltitle=beamer@tcb@titlefg,
before title={\usebeamerfont{block title}},
before upper={\usebeamercolor{block body}\usebeamerfont{block body}},
size=fbox,
}{}
\makeatother
\begin{document}
\begin{frame}
\begin{mythm}{}{}
Text
\begin{enumerate}
\item List
\end{enumerate}
\end{mythm}
\end{frame}
\end{document}
由于该问题已在 tcolorbox 内部主题中得到解决,如果您自己重新定义定理,也可以使用此主题:
\documentclass{beamer}
\setbeamertemplate{theorems}[numbered]
\useinnertheme{tcolorbox}
\setbeamercolor{block title}{bg=white}
\setbeamercolor{block body}{bg=gray!5,fg=black}
\tcbsetforeverylayer{
size=fbox,
boxrule=1pt,
borderline={1pt}{0pt}{gray},
titlerule=1pt,
titlerule style=gray
}
\begin{document}
\begin{frame}
\begin{theorem}
Text
\begin{enumerate}
\item List
\end{enumerate}
\end{theorem}
\end{frame}
\end{document}