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!
-
1Do you want to change the color of the label, or of all the text in the proof? – Bernard Apr 1 '15 at 21:28
Prepend \proof
(similar to \begin{proof}
) with \color{blue}
using the following:
\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 ofletltxmacro
). – egreg Apr 1 '15 at 21:40
The package etoolbox
allows you to easily patch everything:
\usepackage{etoolbox}
\usepackage{xcolor}
\usepackage{amsthm}
\AtBeginEnvironment{proof}{\color{blue}}