6

I'm using \begin{proof}... \end{proof} of amsthm package for demonstrations environment. How I can change only the color of word "Proof"? Thank you.

R.S.

R.S.
  • 61

3 Answers3

6

I suggest an indirect method. For some time I've endorsed replacing the hardwired \itshape with a generic command that can be modified by the user. Alas, it has never been done.

But we can patch \proof and do it ourselves.

\documentclass[twocolumn]{article}
\usepackage{amsthm}
\usepackage{xcolor}

\usepackage{xpatch}% to patch \proof

\newcommand{\proofnameformat}{\itshape}% the default for amsthm \xpatchcmd{\proof}{\itshape}{\proofnameformat}{}{}

\colorlet{proofcolor}{red!75!blue} \renewcommand{\proofnameformat}{\itshape\color{proofcolor}}

\begin{document}

\begin{proof} It's obvious, isn't it? \end{proof}

\end{document}

enter image description here

The twocolumn option is just to make a smaller picture.

I suggest keeping the default value of \proofnameformat for the record, so you start from the same setup as the standard amsthm.

A more flexible version might be

\documentclass[twocolumn]{article}
\usepackage{amsthm}
\usepackage{xcolor}

\usepackage{xpatch}% to patch \proof

\makeatletter \newcommand{\proofnameformat}[1]{\itshape#1@addpunct{.}}% the default \xpatchcmd{\proof} {\itshape#1@addpunct{.}} {\proofnameformat{#1}} {}{} \makeatother for amsthm

\colorlet{proofcolor}{red!75!blue} \renewcommand{\proofnameformat}[1]{\fbox{\itshape\color{proofcolor}#1/}}

\begin{document}

\begin{proof} It's obvious, isn't it? \end{proof}

\end{document}

Here #1 in the definition of \proofnameformat will be replaced by \proofname. The result with the given value for \proofnameformat would be

enter image description here

For your application you'd do

\makeatletter
\renewcommand{\proofnameformat}{\itshape\color{proofcolor}#1\@addpunct{#1}}
\makeatother
egreg
  • 1,121,712
4

The default "proof name" is defined as \proofname in amsthm. So you can just \renewcommand* it.

Example below gives you the word "Proof" in red.

\documentclass[10pt]{article}
\usepackage{amsthm}
\usepackage{xcolor}

\renewcommand*{\proofname}{\color{red}Proof}

\begin{document} \begin{proof} Test \end{proof} \end{document}

Willie Wong
  • 24,733
  • 8
  • 74
  • 106
  • 5
    +1. However, one may want to replace \color{red}Proof with either {\color{red}Proof} or \textcolor{red}{Proof} if one doesn't want the period (aka "full stop") after the string "Proof" to be colored red as well. – Mico Feb 17 '22 at 20:37
3

Another alternative.....redefing with \newenvironment{prof}.

enter image description here

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{xcolor}

\newenvironment{prof} {\begin{proof}[\itshape\textcolor{red}{Proof.}]} {\end{proof}}

\begin{document} \begin{prof} Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit. \end{prof} \end{document}

Sebastiano
  • 54,118