1

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

6
  • Welcome to TeX.SE! Can you please show us what you have and what you want?
    – Mensch
    Apr 23, 2022 at 16:02
  • I have introduced usepackage[x11names]{xcolor}. Then using \color{blue}. But this only colours the user text rather that the theorem heading,
    – Veak
    Apr 23, 2022 at 16:13
  • Please tell us whether you use the amsthm or the ntheorem package (or maybe some other package?) to help generate the theorem-like environments.
    – Mico
    Apr 23, 2022 at 16:28
  • I am using amsthm, yes.
    – Veak
    Apr 23, 2022 at 17:08
  • This question has nothing to do with amsmath. I'm removing that tag. Apr 25, 2022 at 1:19

1 Answer 1

2

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

3
  • Very good, very nice.
    – Veak
    Apr 23, 2022 at 22:32
  • Typo: asmthm on the first line.
    – Simd
    Apr 24, 2022 at 6:10
  • kindly, How can I do the same thing in lyx?
    – user35528
    Nov 27, 2023 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .