In the post How to suppress vertical space between theorem heads and enumitem environments? David Carlisle suggested a piece of code that helps suppressing vertical space between theorem heads and an enumerate environments. The code worked well, but I recently realized there is now additional vertical space inserted between enumerate environments when they are nested. How can this be avoided (without losing the feature of having vertical space suppressed after theorem heads)?
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{enumitem}
\usepackage{amsthm}
\newtheoremstyle{mythmstyle}%
{0.5em}% space above
{0.5em}% space below
{}% body font
{}% indent amount
{\sffamily\bfseries}% head font
{}% punctuation after head
{\newline}% space after head
{\thmname{#1}\ \thmnumber{#2}\ \thmnote{(#3)}}% head spec
\theoremstyle{mythmstyle}
\newtheorem{theorem}{Theorem}
% list settings
\setlist{% general list settings (enumitem's itemize, enumerate, and description)
align=left,% left-aligned enumerate
labelsep=*,% align all item bodies vertically
leftmargin=*,% no left indent
topsep=1mm,% space before enumerate
itemsep=0mm% space between enumerate items
}
\setlist[enumerate,1]{label=\alph*)}% enumerate label on level 1
\setlist[enumerate,2]{label=\roman*)}% enumerate label on level 2
% vertical spacing after theorem heads (suggested by David Carlisle)
\makeatletter
\def\enumfix{%
\if@inlabel
\noindent\par\nobreak\vskip-\parskip\vskip-\baselineskip\hrule\@height\z@
\fi}
\let\oldenumerate\enumerate
\def\enumerate{\enumfix\oldenumerate}
\makeatother
\begin{document}
\begin{theorem}% perfectly fine with David's solution: no vertical space
\begin{enumerate}
\item Foo
\item Bar
\end{enumerate}
\end{theorem}
\bigskip
\begin{enumerate}
\item Foobar
\item \begin{enumerate}% vertically not correctly aligned; comment out David's code above to see how it should look like
\item Foo
\item Bar
\end{enumerate}
\end{enumerate}
\end{document}
tenumerateinstead ofenumerateinside theorems (one easily tends to forget that); 2) The nesting is not trivial anymore (using the next enumerate inside tenumerate creates 'a) a)' by default for example); 3) some scientific journals have good templates where this problem does not appear (how do they solve it?). Hmmm... – Marius Hofert Jun 15 '12 at 21:023ptin the argument to\preto, if you feel it necessary. – egreg Jun 15 '12 at 21:573ptto0.3emwhich also nicely scales with font size. – Marius Hofert Jun 15 '12 at 22:45