定理标题的背景颜色,包括其编号

定理标题的背景颜色,包括其编号

我从 的经典定理环境开始amsthm,它有我想要的编号。我想要的是给定理名称的背景上色。我曾尝试在定义本身中做一个颜色框,但我只能给名称上色,不幸的是没有编号。基本上,我的问题是:如何让编号也上色?

我知道这个包thmtools,但我只是想给名称和编号的背景上色,而不是给整个定理上色。

梅威瑟:

\documentclass{article}

\usepackage{amsmath,amsthm}

\usepackage{xcolor}
\usepackage{colortbl}

\definecolor{1}{RGB}{255,200,255}
\newtheorem{prop1}{\colorbox{1}{Proposition}}

\begin{document}

\begin{prop1}
For any information provision policy $A$,
\[
\rho^*_A = 1.
\]
\end{prop1}

\end{document}

Solely <code>Proposition' is colored, whereas I would like the numbering</code>1.' to be colored as well.

答案1

你可以定义自己的定理风格:

\documentclass{article}

\usepackage{amsmath,amsthm}

\usepackage{xcolor}
\usepackage{colortbl}

\definecolor{1}{RGB}{255,200,255}
\newtheoremstyle{colth}% 
{}{}% 
{\itshape}{}% 
{}{}% 
{ }% 
{\colorbox{1}{\textbf{\thmname{#1}\thmnumber{ #2}}\thmnote{ (#3)}.}}
\newtheorem{prop}{Proposition}
\theoremstyle{colth}
\newtheorem{prop1}[prop]{Proposition}

\begin{document}
\begin{prop}
An ordinary Proposition
\end{prop}

\begin{prop1}
For any information provision policy $A$,
\[
\rho^*_A = 1.
\]
\end{prop1}

\begin{prop}[With a note]
For any information provision policy $A$,
\[
\rho^*_A = 1.
\]
\end{prop}

\begin{prop1}[With a note]
For any information provision policy $A$,
\[
\rho^*_A = 1.
\]
\end{prop1}

\end{document}

enter image description here

相关内容