# Change theorem color using theorem notes in the amsthm package

When defining a new theorem style in the amsthm package, you can specify what's called (according to http://web.mat.bham.ac.uk/R.W.Kaye/latex/thm.pdf) a custom head specification. In there, you can use "#3" to print to screen something specified by the argument. In my case I want to use the argument as a switch. More specifically, I'm writing a document with a series of Math problems and want an easy way to see which have already been done by my students. I want to implement it using newthmstyle so that it would work like this:

\begin{problem}
blah blah
\end{problem} %prints a regular problem

\begin{problem}[done]
blah blah
\end{problem} %prints a problem, which colors the "problem 5:" part green


I know how to do the coloring, it's been tested and it works. I can't figure out how to get the switch to work. If it's considerably easier, it may be a number, instead of "done" that does the switching.

I suppose there needs to be a way to do this, but I'm not proficient enough in Latex's semantics to get it working. I tried some things with the if statements but to no avail. Any ideas?

• Welcome to TeX.SE! Could you add a complete but minimal working example (MWE) of what you tried so far. It makes it much more easier to help you! Dec 16, 2018 at 15:43
• the reference you link looks good, but you may want to also check out the "official" amsthm documentation (amsthdoc.pdf, on ctan), which was thoroughly revamped last year. (although it doesn't answer this particular question.) Dec 23, 2018 at 2:06

With \ifstrequal from etoolbox you can test #3 to get the desired problem head color.

\documentclass{article}
\usepackage{amsmath, amsthm}
\usepackage{etoolbox}
\usepackage{xcolor}

\newtheoremstyle{mystyle}% Name of the style
{\topsep}% Space above
{\topsep}% Space below
{}% Body font
{0pt}% Indent amount
{}% Punctuation after theorem head (in this case empty because defined in the head spec)
\theoremstyle{mystyle}
\newtheorem{problem}{Problem}

\begin{document}
\begin{problem}
blah blah
\end{problem} %prints a regular problem

\begin{problem}[done]
blah blah
\end{problem} %prints a problem, which colors the "problem 5:" part green

\begin{problem}
blah blah
\end{problem} %prints a regular problem

\begin{problem}[done]
blah blah
\end{problem} %prints a problem, which colors the "problem 5:" part green
\end{document}


• Why \parsep at the top and \topsep at the bottom? I believe it should be \topsep for both. Dec 21, 2018 at 22:34
• @egreg Corrected! Dec 22, 2018 at 6:00