# Amsthm, Tcolorbox, and lists

In trying to debug a (bigger) indentation problem I have with lists, I came to this MWE. I cannot understand why the definition's caption appear inside the box, and in the same line as the first item in the list.

\documentclass[12pt]{amsbook}

\usepackage{tcolorbox}

\theoremstyle{remark}
\newtheorem{definition}{Definition}

\newtcolorbox{dcbtheorem}[1][]{#1}

\begin{document}

\begin{definition}
\begin{dcbtheorem}
One line

Another line

Yet, another one, why is Definition'' below?

\begin{enumerate}[label={[\roman*]}]
\item First line
\item Second line
\item Third line
\item Fourth line
\item Fifth line
\item Sixth line
\end{enumerate}
\end{dcbtheorem}
\end{definition}

\end{document}


• Why "Definition" is in that particular location, I can't say, but the way definition is defined expects some text (or something) to continue on the same line as the heading. Try inserting \leavevmode immediately after \begin{definition} and see if that interrupts the "misreading". – barbara beeton Jun 4 '20 at 1:51
• Thanks, Barbara, that was exactly what I needed! – Martin Argerami Jun 4 '20 at 2:25

I haven't tried to debug this, but really, that's not necessary.

You're using amsbook, so amsthm is the default. The definition of all theorem-class objects, including definition, assumes that the next input (other than an [<optional note>]) will be text, and that will be set as text on the same line as the heading.

In your example, the next thing after \begin{definition} is \begin{dcbtheorem}, which I wouldn't expect to do anything predictable.

The obvious thing to do here is get onto another line, either by adding text and a paragraph break, or explicitly break to a new line, leaving only the heading. The recommended method for that is to insert \leavevmode immediately after \begin{definition}.

I guess you want to use the method described in section 17.4 of the manual of tcolorbox.

\documentclass[12pt]{amsbook}
\usepackage{enumitem}
\usepackage{tcolorbox}

\tcbuselibrary{theorems}

\theoremstyle{remark}
\newtheorem{definition}{Definition}

\tcolorboxenvironment{definition}{
% options
}

\begin{document}

\begin{definition}
One line

Another line

Yet, another one, why is Definition'' below?

\begin{enumerate}[label={[\roman*]}]
\item First line
\item Second line
\item Third line
\item Fourth line
\item Fifth line
\item Sixth line
\end{enumerate}
\end{definition}

\end{document}


Why do you get that funny output? Because definition and dcbtheorem conflict in their usage of \everypar.

As for the question why definition appears where it appears: when one compiles your code, one gets errors. To repair them, one need at least to load the enumitem package. Once one starts guessing one cannot be sure to provide the correct explanation.

However, none of these problems arise if you make use of the theorems library. Here is one way in which you can use it.

\documentclass[12pt]{amsbook}

\usepackage[theorems]{tcolorbox}
\usepackage{cleveref}
\usepackage{enumitem}
\tcbset{
defstyle/.style={fonttitle=\bfseries\upshape, fontupper=\slshape,
arc=0mm, colback=blue!5!white,colframe=blue!75!black},
theostyle/.style={fonttitle=\bfseries\upshape, fontupper=\slshape,
colback=red!10!white,colframe=red!75!black},
}
\newtcbtheorem[number within=section,crefname={definition}{definitions}]%
{Definition}{Definition}{defstyle}{def}
\begin{document}

\section{Some section}

\begin{Definition}{Mice}{mice}
One line: mice are mice.

Another line: and not ducks.

Yet, another one: certainly not squirrels.

\begin{enumerate}[label={[\roman*]}]
\item First line
\item Second line
\item Third line
\item Fourth line
\item Fifth line
\item Sixth line
\end{enumerate}
\end{Definition}
\end{document}


defstyle is just copied from p. 370 of the manual v4.30. You can change it to your needs. The main point is that if one follows the manual, everything works as expected.

• It doesn't produce errors neither on my installation, nor on latex4technics.com. I'm aware of the tcolorbox theorem environments. I went I different (hackish) route because I want the numbering of such theorems to be coherent with the regular amsthm environments: say, I want Definition to be tcolorbox but Remark be regular amsthm, and the numbering to be continuous. I didn't find a natural way to do it (not saying there isn't), and so I hacked into \theorem so that it doesn't print the number nor the name, which I print in the tcolorbox. It's working fine, but it ruined my list alignment. – Martin Argerami Jun 4 '20 at 2:17
• I still don't know why it ruined the list alignment, but inserting \leavevmode as Barbara suggested solves my problem completely. – Martin Argerami Jun 4 '20 at 2:26
• @MartinArgerami On my updated TeXLive 2020 installation I get ! Missing number, treated as zero. <to be read again> \c@* l.20 \begin{enumerate}[label={[\roman* ]}] when I compile your code. I will leave my answer for all those who get the same error. – user194703 Jun 4 '20 at 2:36
• My bad, I removed enumiten (because it's not related to my problem) and forgot to remove the custom label. – Martin Argerami Jun 4 '20 at 2:42