使用 amsthm 包时,如何仅更改定理标题的颜色,即“定理”、“定义”等后面括号中的部分?
我曾尝试传递\color{red}
定理头字体(见下文),但这也会改变第一部分,即不在括号中。
\newtheoremstyle{note}% (name)
{}% (space above)
{}% (space below)
{}% (body font)
{}% (indent amount)
{\bfseries\color{red}}% (Theorem head font)
{:}% (Punctuation after theorem head)
{.5em}% (Space after theorem head)
{}% (Theorem head spec (can be left empty, meaning ‘normal’))
澄清一下,当说
\begin{definition}[foo] an explanation \end{definition}
我只希望“foo”是红色的,但定义保持不变,因为我已经在定理头字体中对它进行了定义。
答案1
您可以为此使用 的最后一个参数。 、和\newtheoremstyle
的参数仅在相关字段存在时才打印。\thmname
\thmnumber
\thmnote
\documentclass{article}
\usepackage{amsthm}
\usepackage{xcolor}
\newtheoremstyle{note}% (name)
{}% (space above)
{}% (space below)
{}% (body font)
{}% (indent amount)
{\bfseries}% (Theorem head font)
{:}% (Punctuation after theorem head)
{.5em}% (Space after theorem head)
{\thmname{#1}\thmnumber{ #2}\thmnote{ (\textcolor{red}{#3})}}
% ^^(Theorem head spec (can be left empty, meaning ‘normal’))
\theoremstyle{note}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[Named theorem]
This theorem has a name.
\end{theorem}
\begin{theorem}
This theorem does not.
\end{theorem}
\end{document}