5

I know that we can change the default color given in shadethm package using, for example, \definecolor{shadethmcolor}{HTML}{F7F8E0}. But if I want to use different colors for different environments in the above fashion, what should I do? For example, say I have:

\newshadetheorem{env1}
\newshadetheorem{env2}
\definecolor{shadethmcolor}{HTML}{F7F8E0}

and I want that color only for the first enviroment, and a second color for the other.

1 Answer 1

7

Here's one possibility:

\documentclass{article} 
\usepackage{xcolor}
\usepackage{xparse}
\usepackage{shadethm}

\newshadetheorem{env1}{Theorem}
\newshadetheorem{env2}{Lemma}
\newshadetheorem{env3}{Proposition}

\NewDocumentEnvironment{lemma}{o}
  {\definecolor{shadethmcolor}{RGB}{244,156,124}%
    \IfNoValueTF{#1}
      {\begin{env2}}
      {\begin{env2}[#1]}
  }
  {\end{env2}}
\NewDocumentEnvironment{proposition}{o}
  {\definecolor{shadethmcolor}{HTML}{F7F8E0}%
    \IfNoValueTF{#1}
      {\begin{env3}}
      {\begin{env3}[#1]}
  }
  {\end{env3}}

\begin{document}

\begin{env1}
A test shaded theorem
\end{env1}

\begin{lemma}
A test shaded theorem
\end{lemma}

\begin{proposition}
A test shaded theorem
\end{proposition}

\end{document}

The result:

enter image description here

However, I'd like to suggest you a more versatile approach using either thmtools ot tcolorbox. Here's an example using thmtools interaction with shadethm:

\documentclass{article} 
\usepackage[dvipsnames]{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}

\definecolor{mycolor}{HTML}{F7F8E0}

\declaretheorem[shaded={bgcolor=Lavender}]{theorem}
\declaretheorem[shaded={bgcolor=mycolor}]{proposition}
\declaretheorem[shaded={bgcolor=green!80!black!30}]{lemma}

\begin{document}

\begin{theorem}
A test shaded theorem
\end{theorem}

\begin{lemma}
A test shaded theorem
\end{lemma}

\begin{proposition}
A test shaded theorem
\end{proposition}

\end{document}

enter image description here

2
  • This is very nice, thanks. And I actually found your second suggestion easier. But I'm having trouble with the numbering though. If I want some abbreviation together with it, say, I'd try \declaretheorem[shaded={bgcolor=mycolor}]{prop}{Proposition}[section], but it didn't work. Is there a way to go around this?
    – Ivo Terek
    Aug 27, 2015 at 19:03
  • 1
    @IvoTerek You're welcome. The syntax is \declaretheorem[shaded={bgcolor=mycolor},within=section,name=Proposition]{prop}. Aug 27, 2015 at 19:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .