color,amsthm – Coloring Headings for Lemma, Theorem, Corollary, and Definition Using amsthm

amsthmcolor

Would it be possible to have the headings for lemma, theorem, corollary, definition, show in colour?

Best Answer

With the package amsthm you can use the enhanced \newtheorem command.

\newtheorem{⟨env name⟩}{⟨text⟩}[⟨parent counter⟩]

\newtheorem{⟨env name⟩}[⟨shared counter⟩]{⟨text⟩}

Then you add colors to the <text> as shown.

a

Observe that the environment defn used here does not include a shared counter, so it will start as <section number>. 1.

\documentclass[12pt,a4paper]{article}

\usepackage{amsmath,amsthm} 
\usepackage{xcolor}

%*********************************************** put the colors <<<<<
\newtheorem{thm}{\textcolor{green}{Theorem}}[section]
\newtheorem{cor}[thm]{\textcolor{violet}{Corollary}}
\newtheorem{lem}[thm]{\textcolor{orange}{Lemma}}
\newtheorem{prop}[thm]{\textcolor{blue}{Proposition}}
\newtheorem{defn}{\textcolor{red}{Definition}}[section]
%****************************************************

\DeclareMathOperator{\per}{per}
\newcommand{\A}{\mathcal{A}}
\newcommand{\eval}[2][\right]{\relax
    \ifx#1\right\relax \left.\fi#2#1\rvert}

\begin{document}
    
    \section{A color Sampler}
    
    \begin{lem}\label{lem-per}
        \begin{equation}
            \prod_{i\in\mathbf{n}}
            \biggl(\sum_{\,j\in\mathbf{n}}b_{ij}\hat x_i\biggr)
            =\biggl(\prod_{\,i\in\mathbf{n}}\hat x_i\biggr)\per \mathbf{B}
        \end{equation}
        where $\per \mathbf{B}$ is the permanent of $\mathbf{B}$.
    \end{lem}

\begin{thm}\label{thm-main}
    \begin{equation}\label{detB}
        \det\mathbf{B}=
        \sum^n_{l =0}\sum_{I_l \subseteq n}
        \prod_{i\in I_l}(b_{ii}-\lambda_i)
        \det\mathbf{B}^{(\lambda)}(I_l |I_l ),
    \end{equation}
    where $I_l =\{i_1,\dots,i_l \}$ and $\mathbf{B}^{(\lambda)}(I_l |I_l )$
    is the principal submatrix obtained from $\mathbf{B}^{(\lambda)}$
    by deleting its $i_1,\dots,i_l $ rows and columns.
\end{thm}


\begin{cor}\label{tripleA}
    Let $(\A,\A',\A'')$ be a triple of arrangements. Then
    \[ \pi (\A,t) = \pi (\A',t) + t \pi (\A'',t). \]
\end{cor}

\begin{defn}
    Let $(\A,\A',\A'')$ be a triple with respect to
    the hyperplane $H \in \A$. Call $H$ a \textit{separator}
    if $T(\A) \not\in L(\A')$.
\end{defn}

\begin{prop}\label{prop:eg}
    \begin{equation}
        H_c=\frac1{2n}\sum^n_{l =0}(-1)^{l}
        D_{l},
    \end{equation}
    where
    \begin{equation}\label{delta-l}
        D_{l}=\eval[2]{\sum_{I_{l}\subseteq \mathbf{n}}
            D(t_1,\dots,t_n)}_{t_i=\left\{\begin{smallmatrix}
                0,& \text{if }i\in I_{l}\quad\\% \quad added for centering
                1,& \text{otherwise}\end{smallmatrix}\right.\;,\;\; i=1,\dots,n}.
    \end{equation}
\end{prop}
    
    
\end{document}

The math examples were taken from testmath.tex – Examples of the AMS-LaTeX package