12

Consider the following example:

\documentclass{article}
\newtheorem{Theorem}{Theorem}
\begin{document}
\begin{Theorem}
On the other hand, this one has only one claim.
\end{Theorem}
\begin{Theorem}
\begin{enumerate}
\item First claim
\item Second claim
\end{enumerate}
\end{Theorem}
\end{document}

Typesetting it results in:

enter image description here

Notice there is extra horizontal space before the first item in the list of the second theorem.

Is there a sensible way to get rid of that?

Ideally, the solution would work with amsthm, thmtools, enumitem.

N.B.: this is related to Is it possible to skip the first line in a theorem environment? but not quite the same.

5 Answers5

8

Two variants of a solution using the enumitem package. In the first case, two enumerate environments were used; the first one uses leftamargin=* to suppress the undesired horizontal space; the second enumerate uses resume to keep the numbering but preserves the standard value for \leftmargin; the vertical spacing between the two environments was also corrected. In the second case, the option leftmargin=* was also used, but this time only one enumerate environment was used so the horizontal space will be removed for all the items.

\documentclass{article}
\usepackage{enumitem}

\newtheorem{Theorem}{Theorem}

\begin{document}

\begin{Theorem}
   On the other hand, this one has only one claim.
\end{Theorem}

\begin{Theorem}
  \begin{enumerate}[leftmargin=*]
    \item First claim
  \end{enumerate}\vspace*{-2\partopsep}
  \begin{enumerate}[resume]
    \item Second claim
  \end{enumerate}
\end{Theorem}

\begin{Theorem}
   On the other hand, this one has only one claim.
\end{Theorem}

\begin{Theorem}
  \begin{enumerate}[leftmargin=*]
    \item First claim
    \item Second claim
  \end{enumerate}
\end{Theorem}

\end{document}

The result:

doncherry
  • 54,637
Gonzalo Medina
  • 505,128
5

You can use a \@labels trick (as in Phil Hirschhorn's answer to “Avoiding a line break at the beginning of an enumerate”). Here's the result:

Image of the result of the code

There are two ways you can use this. The first is by manually putting a \thmenumhspace after \begin{enumerate} inside a theorem:

\documentclass{article}
%\usepackage{amsthm,enumitem,thmtools}% works with or without
\newtheorem{Theorem}{Theorem}
\makeatletter
\newlength{\@thlabel@width}%
\newcommand{\thmenumhspace}{\settowidth{\@thlabel@width}{\itshape1.}\sbox{\@labels}{\unhbox\@labels\hspace{\dimexpr-\leftmargin+\labelsep+\@thlabel@width-\itemindent}}}
\makeatother
\begin{document}
\begin{Theorem}
1. First claim 2. Second claim.
\end{Theorem}
\begin{Theorem}
\begin{enumerate}\thmenumhspace
\item First claim
\item Second claim
\end{enumerate}
\end{Theorem}
\end{document}

With a little more work, this can be automated, hopefully without any side effects (this time, you need amsthm for it to work correctly):

\documentclass{article}
\usepackage{amsthm,enumitem,thmtools}% needs amsthm
\newtheorem{Theorem}{Theorem}
\makeatletter
\newcommand{\thmenumhspace}[1]{\sbox{\@labels}{\unhbox\@labels\hskip#1}}
\let\original@item\item
\newlength{\@thlabel@width}%
\newcommand{\RedefineItem}{%
  \settowidth{\@thlabel@width}{\itshape1.}%
  \def\item{\let\item\original@item\thmenumhspace{\dimexpr-\leftmargin+\labelsep+\@thlabel@width-\itemindent}\original@item}
}
\let\original@Theorem\Theorem
\def\Theorem{
   \@ifnextchar[{\Theorem@Opt}
                {\Theorem@NoOpt}
}
\def\Theorem@Opt[#1]{%
   \@ifnextchar\begin{\RedefineItem\original@Theorem[#1]}%
                     {\original@Theorem[#1]}%
}
\def\Theorem@NoOpt{%
   \@ifnextchar\begin{\RedefineItem\original@Theorem}%
                     {\original@Theorem}%
}
\makeatother
\begin{document}
\begin{Theorem}
1. First claim. 2. Second claim.
\end{Theorem}
\begin{Theorem}
\begin{enumerate}
  \item First claim
  \item Second claim
\end{enumerate}
\end{Theorem}
\begin{Theorem}
This one has two claims.
\begin{enumerate}
  \item First claim
  \item Second claim
\end{enumerate}
\end{Theorem}
\begin{Theorem}[Title]
\begin{enumerate}
  \item First claim
  \item Second claim
\end{enumerate}
\end{Theorem}
\begin{Theorem}[Title]
This one has two claims.
\begin{enumerate}
  \item First claim
  \item Second claim
\end{enumerate}
\end{Theorem}
\end{document}
  • From where comes the dimension -1em? To me it is not enough. How to determine the exactly value to use to have the same output as with no enumerate? – Sigur Apr 08 '15 at 17:52
  • @Sigur: I've edited the answer; it should now have the exact right amount of space whatever the settings are. – Philippe Goutet Apr 10 '15 at 16:00
  • I saw that you edited only the automated code. But I'm using the simplest one since I'm using it only once. I tried the same value as \baselineskip (in my case, 1.5em) and it looks right but I'm not sure. – Sigur Apr 10 '15 at 17:35
  • @Sigur: I've also adapted the manual code. The exact value cannot be 1.5em: it depends on the leftmargin, labelsep, itemindent and the size of the enumerate label. – Philippe Goutet Apr 10 '15 at 19:37
  • Nice! Since I'm using the label style (i) and so on in upright font, should I use \upshape(i) instead of \itshape1.? – Sigur Apr 10 '15 at 20:03
  • Hum, I've tested and it does not work with [label=\textup{(\roman*)}] from enumitem package. – Sigur Apr 10 '15 at 20:06
  • @Sigur: if I replace \itshape1. by \textup{(i)} in the definition of \thmenumhspace and then use \begin{enumerate}[label=\textup{(\roman*)}]\thmenumhspace, there's no spacing problem. – Philippe Goutet Apr 11 '15 at 03:25
  • Ow, sorry. I hadn't seen that you had replaced before each by after. Now it works well. Thanks so much. – Sigur Apr 11 '15 at 06:29
  • It does not work well with a0poster. I think that some font sizes or dimensions are affecting the computations. Any idea? – Sigur Jun 25 '16 at 18:46
  • @Sigur: I cannot reproduce your problem. When I change the document class to a0poster in the two codes I gave above, everything looks fine. – Philippe Goutet Jun 26 '16 at 07:26
  • Thanks for attention. I believe that problems come from [label=\textup{(\arabic*)}] option I'm using. I tried also to fix this in the \thmenumhspace definition but no progress. Also in the second item its label (2) is to much on left. – Sigur Jun 27 '16 at 17:50
  • @Sigur: for the first problem, try changing the beginning of \thmenumhspace to \settowidth{\@thlabel@width}{\textup{(1)}}; for the second problem, try using [label=\textup{(\arabic*)},leftmargin=2em]. – Philippe Goutet Jun 27 '16 at 20:43
2

You can hack a bit the first \item as follows:

\documentclass{article}
\newtheorem{Theorem}{Theorem}
\newcommand*\fixitem {\item[]%
  \refstepcounter{enumi}\hskip-\leftmargin\labelenumi\hskip\labelsep}
\begin{document}
\begin{Theorem}
On the other hand, this one has only one claim.
\end{Theorem}
\begin{Theorem}
\begin{enumerate}
\fixitem First claim
\item Second claim
\end{enumerate}
\end{Theorem}
\end{document}

and the result is:

result of tex run

1

I found this trick that might help:

\documentclass{article}
\newtheorem{Theorem}{Theorem}
\begin{document}
\begin{Theorem}
On the other hand, this one has only one claim.
\end{Theorem}
\begin{Theorem}
\mbox{}
\begin{itemize}    
\item[(i)] item one.    
\item[(ii)] item two.    
\item[(iii)]  item three.    
\end{itemize}
\end{Theorem}
\end{document}
dingo_d
  • 2,976
  • That is mentioned in the question I linked to, but does not do what I want because it starts a new line. I would like the list to start right beside the Theorem 2, but without the unnecessary space. – Mariano Suárez-Álvarez May 05 '11 at 09:41
  • 1
    How is it unnessary? That is the default space between items in a list, that has nothing to do with theorems. If you whant to be able to configure this, see the enumitem package – daleif May 05 '11 at 09:43
  • 1
    @daleif: well, I consider it unnecessary to add extra horizontal space between the end of the Theorem 2 text and the label of the first item in the list: it is inb that way that it is unnecessary! Also «see the enumitem package» does in no way help me... I have already seen it —I have been using for years now…— and I would not be asking if I knew how to achieve the effect I want to achieve. If you read the other answers, you'll notice that it is quite not a matter of using the please-mariano option to enumitem, too. – Mariano Suárez-Álvarez May 05 '11 at 17:01
  • @mariano ahh, then I misunderstood, I was thinking vertical – daleif May 05 '11 at 22:28
0

This is a non-answer whose purpose is to point out that some of the profered answers really gives correct marginal indentation of the enumerate items within a theorem.

Although I show the source and output from just one of the answers' methods,others give similar, undesirable indentation.

\documentclass{article}
%\usepackage{amsthm,thmtools}% works with or without

\usepackage{enumitem}

\newcommand{\sometext}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra sollicitudin.}

\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem} This is normal enumeration inside a theorem, which should be matched when no text precedes the enumeration: \begin{enumerate} \item \sometext \item \sometext \end{enumerate} \end{theorem}

Margination of the first item of next theorem does \emph{not} agree with the ``normal'' margination of the preceding Theorem 1.

\begin{theorem}\label{thm-2} \begin{enumerate}[leftmargin=*] \item \sometext \end{enumerate}\vspace*{-2\partopsep} \begin{enumerate}[resume] \item \sometext \end{enumerate} \end{theorem}

Margination of \emph{neither} item of the next theorem agrees with the ``normal'' margination of Theorem 1.

\begin{theorem} \begin{enumerate}[leftmargin=*] \item \sometext \item \sometext \end{enumerate} \end{theorem}

A theorem with no enumeration inside:

\begin{theorem} \sometext \end{theorem}

\end{document}

Now look at the items' indentation in the output, where the theorems that start directly with an enumerate do not have the same indentation as for a theorem that has text before the enumerate:

Wrong indentation when enumerate immediately follows theorem heading

The question becomes: When an enumerate immediate follows \begin{theorem}, ss there some way of:

  • eliminating the extra horizontal space between "Theorem" and the number of the first item; and yet
  • keep the same "normal" indentation of items as in a Theorem having some text before the enumerate?

avoiding the extra horizontal space between "Theorem" and the number of the first item

murray
  • 7,944
  • However, the @label trick does work -- even for theorem-like environments created using thmtools and for enumeration lists within them created using enumitem. – murray Mar 24 '21 at 20:00