Change background color across different environments
As suggested in one of my comments to the question, I would use tcolorbox
and its \newtcbtheorem
macros, having two basically identical environments, where one uses the checkedstyle
and the other one the uncheckedstyle
. If a theorem is not checked yet, use \begin{uctheorem}...\end{uctheorem}
and edit it later to \begin{theorem}...\end{theorem}
or just remove the colback={green!50!white}
statement from the definition of uncheckedstyle
.
In the very end, a search-and-replace
of all uctheorem
occurrences by theorem
would be the best way, in my point of view, but that is a matter of taste, of course.
Another option is to use a 'real' tcolorbox
environment which allows local specification of options, which is not possible with the tcbtheorem
environments.
\documentclass[10pt]{article}
\usepackage[english]{babel}
\usepackage{amssymb,amsmath,amsthm,amsfonts}
\usepackage{xcolor}
\usepackage[most]{tcolorbox}
\tcbset{%
checkedstyle/.style={breakable,enhanced, sharp corners,colback={yellow!50!white}},
uncheckedstyle/.style={checkedstyle,colback={green!50!white}}
}
\newtcbtheorem{theorem}{Theorem}{checkedstyle}{theo}
\newtcbtheorem{uctheorem}{Theorem}{uncheckedstyle}{theo}
\begin{document}
\section{Introduction}
\begin{theorem}{My theorem}{foo}
A theorem.
\end{theorem}
\begin{uctheorem}{My other theorem}{foobar}
An unchecked theorem
\end{uctheorem}
\end{document}