4

I'm using the \begin{proof} of the amsthm package. And I want to change the color of everything in this environment. Currently, I use {\color{blue} \begin{proof} ... \end{proof}}. But I need to do this every time. How can I do it more easily, please? Thank you!

  • 1
    Do you want to change the color of the label, or of all the text in the proof? – Bernard Apr 1 '15 at 21:28
8

Prepend \proof (similar to \begin{proof}) with \color{blue} using the following:

enter image description here

\documentclass{article}

\usepackage{amsthm,xcolor}
\usepackage{mathtools}% To colour equation numbers in proof

\let\oldproof\proof
\renewcommand{\proof}{\color{blue}\oldproof}

\begin{document}

\begin{proof}
This is a proof. Here is an equation:
\begin{equation} f(x) = ax^2 + bx + c \end{equation}
Here is another equation, this time unnumbered
\[ f(x) = ax^2 + bx + c \]
And the end of the proof.
\end{proof}

Some text between proofs.
\begin{equation} f(x) = ax^2 + bx + c \end{equation}

\begin{proof}[abc]
This is a proof. Here is an equation:
\begin{equation} f(x) = ax^2 + bx + c \end{equation}
Here is another equation, this time unnumbered
\[ f(x) = ax^2 + bx + c \]
And the end of the proof.
\end{proof}

\end{document}

The grouping provided by \begin...\end limits the scope of \color{blue} to everything inside the proof environment (including math content).

I've added mathtools above since it redefines the way tags work under amsmath. In that sense, it automatically colours equation numbers inside the proof environment as well. Without it, you may be left with black equation numbers and have to redefine the tag-form yourself.

The proof environment takes an optional argument. In such cases it may be safer to use \LetLtxMacro (from the similarly-named package) instead of a pure \let. See When to use \LetLtxMacro?

  • Using \color{blue} in vertical mode? Hmm. And \proof is a command with optional argument, so \renewcommand\proof is quite risky (see the doc of letltxmacro). – egreg Apr 1 '15 at 21:40
7

The package etoolbox allows you to easily patch everything:

\usepackage{etoolbox}
\usepackage{xcolor}
\usepackage{amsthm}
\AtBeginEnvironment{proof}{\color{blue}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.