1

I'm using the package ntheorem to define theorem-like environments and \tcolorboxenvironment (from the tcolorbox package) to frame them. I have a problem when I want to color the body of a theorem with \color: vertical spacing is added at the end, which is unwanted. This doesn't append if I don't frame the theorem with tcolorbox (or, of course, if I don't use \color).

Here is a MWE (see the extra space at the end of the first theorem):

\documentclass[10pt]{article}
\usepackage{lipsum}
\usepackage{xcolor, ntheorem, tcolorbox}
\pagestyle{empty}

\theoremheaderfont{\normalfont\slshape}
\theorembodyfont{\slshape}
\newtheorem*{Thm}{Theorem}

\tcolorboxenvironment{Thm}{left=2mm}

\begin{document}
\begin{Thm}
\color{red} 
\lipsum[2]
\end{Thm}

\begin{Thm}
\lipsum[2]
\end{Thm} 
\end{document}

Would you have any solution? (I don't want to define my theorems through the library theorems of tcolorbox.)

4
  • Why not using the theorem library of tcolorbox?
    – user31729
    Commented Feb 24, 2018 at 15:01
  • @ChristianHupfer Mainly because the arguments of the theorems are not the same as standard amsthm/ntheorem... and I get lost when switching between documents using theorems from tcolorbox and documents using ntheorem.
    – mathieu2l
    Commented Feb 24, 2018 at 15:05
  • 1
    I found ntheorem however never really convincing...
    – user31729
    Commented Feb 24, 2018 at 15:07
  • Well... to be honest I started using it just a few days ago. Until a few months ago, I used amsthm (sometimes with thmtools), then I tried tcolorbox
    – mathieu2l
    Commented Feb 24, 2018 at 15:17

2 Answers 2

2

I suggest to use colupper=red if all of the Thm environments should use this red color.

\documentclass[10pt]{article}
\usepackage{lipsum}
\usepackage{xcolor, ntheorem}
\usepackage[most]{tcolorbox}
\pagestyle{empty}

\theoremheaderfont{\normalfont\slshape}
\theorembodyfont{\slshape}
\newtheorem*{Thm}{Theorem}

\tcolorboxenvironment{Thm}{left=2mm,colupper=red}

\begin{document}
\begin{Thm}
\lipsum[2]
\end{Thm}

\end{document}
1
  • Works fine, as I intended in my document! I added a \normalcolor in the \theoremheaderfont, so that the header is not colored (which wasn't visible in my MWE...).
    – mathieu2l
    Commented Feb 24, 2018 at 15:24
2

Just use braces (because usually we use color like {\color{<color>} <content>}.

{\color{red}
\lipsum[2]}

or better

\textcolor{red}{\lipsum[2]}

enter image description here

1
  • It does work for the MWE... however, I initially intended (in my bigger document) to put the \color command inside the \theorembodyfont (so that it apply to all the Thm).
    – mathieu2l
    Commented Feb 24, 2018 at 15:09

You must log in to answer this question.

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