# Annoying space before first item in an enumeration that starts a theorem-like environment

In a theorem-like environment that begins with a (parenthesized) enumeration, how can the horizontal extra space before the item be eliminated but:

• without destroying correct indentation of the body of the items, including lines after the first one in an item; and

• without requiring no blank line before the body of the first item; and

• without unduly shrinking the space between the first item's label and its body text?

In the output from the source below, the first red arrow marks where the extra unwanted horizontal space appears.

As we can see in "1.3 Examples", the attempt to eliminate the extra horizontal space of the first item destroys the uniform horizontal indentation of the first item. In "1.4 Examples", the body of the first item begins a separate paragraph after its label. In "1.5 Examples", the latter issue is avoided by eliminating the blank line in the source, but there is too little space between the first item's label and its body text.

\documentclass{article}
\usepackage[left=1.2in,right=1.2in,top=1in,bottom=1in]{geometry}

\newcommand{\sometxt}{%
Some text begins this. The identity is $\sin^2(\theta) + \cos^2(\theta) = 1$ %
and in very simple terms $(a + b)^2 \neq a^2 + b^2$.%
On the other hand, we do have the basic law of powers that $(a b)^2 = a^2 b^{2}$.
}

\usepackage{enumitem}
\usepackage{mathtools,amsthm,thmtools}

\newlist{pexenum}{enumerate}{1}
\setlist[pexenum,1]{label= \upshape(\arabic*)}

\swapnumbers

\declaretheorem[name=Theorem,numberwithin=section]{theorem}

\declaretheoremstyle[
spaceabove=12pt,spacebelow=12pt
]{exstyle}

\declaretheorem[
style=exstyle, numberlike=theorem,
]
{examples}

\begin{document}

\section{The  section}

\noindent This is OK with text within the environment precedes the enumeration:

\begin{examples}
Text before the enumeration.
\begin{pexenum}
\item

\sometxt
\setcounter{pexenumi}{9}
\item \sometxt
\end{pexenum}
\end{examples}

\noindent \textbf{The problem}, when \emph{no} text precedes enumeration---too much horizontal space before 1st label:
\begin{examples}
\begin{pexenum}
\item

\sometxt
\setcounter{pexenumi}{9}
\item \sometxt
\end{pexenum}
\end{examples}

\noindent  Attempted fix---\verb!leftmargin=*! etc.. \emph{Wrong}---entire 1st item exdented:

% From https://tex.stackexchange.com/a/17487/13492:
\begin{examples}
\begin{pexenum}[leftmargin=*]
\item

\sometxt
\end{pexenum}\vspace*{-2\partopsep}
\begin{pexenum}[resume]
\setcounter{pexenumi}{9}
\item \sometxt
\end{pexenum}
\end{examples}

\noindent  Attempted fix---use \verb!\fixitem!.. \emph{Wrong}---1st item body begins new paragraph after item label:

% From https://tex.stackexchange.com/a/17500/13492:
\newcommand*\fixitem{\item[]%
\refstepcounter{pexenumi}\hskip-\leftmargin\labelpexenumi\hskip0.5\labelsep}

\begin{examples}
\begin{pexenum}
\fixitem % The blank line before the item's text is deliberate!

\sometxt
\item \sometxt
\setcounter{pexenumi}{9}
\item \sometxt
\end{pexenum}
\end{examples}

\noindent  Attempted fix---use \verb!\fixitem!.---no blank line. This works, but \emph{awkward} having to avoid the blank line:

\begin{examples}
\begin{pexenum}
\fixitem
%
\sometxt
\item \sometxt
\setcounter{pexenumi}{9}
\item \sometxt
\end{pexenum}
\end{examples}

\end{document} Edit: The @label method shown in https://tex.stackexchange.com/a/17465/13492 seems to work!

Related:

The question is similar to that of Annoying space before the first item in an enumeration which starts a theorem, except that now:

• the enumeration is done with parenthesized numbers (which may affect spacing); and
• each item has more than one line, whereas in the original question each item had a single line which obscured the shortcoming in the answers provided there.

The source shows just one method that tries to remove the unwanted horizontal space before the first item, but the other methods given in answers to Annoying space before the first item in an enumeration which starts a theorem suffer the same shortcoming.

Is it what you want?

\documentclass{article}

\newcommand{\sometxt}{%
Some text begins this. The identity is $\sin^2(\theta) + \cos^2(\theta) = 1$ %
and in very simple terms $(a + b)^2 \neq a^2 + b^2$.%
On the other hand, we do have the basic law of powers that $(a b)^2 = a^2 b^{2}$.
}

\usepackage{enumitem}
\usepackage{mathtools,amsthm,thmtools}

\newlist{pexenum}{enumerate}{1}
\setlist[pexenum,1]{label= \upshape(\arabic*), wide=0pt, leftmargin=*}

\swapnumbers

\declaretheorem[name=Theorem,numberwithin=section]{theorem}

\declaretheoremstyle[
spaceabove=12pt,spacebelow=12pt
]{exstyle}

\declaretheorem[
style=exstyle, numberlike=theorem,
]
{examples}

\begin{document}

\section{The section}

\begin{examples}
Text before the enumeration.
\begin{pexenum}
\item \sometxt
\item \sometxt
\end{pexenum}
\end{examples}

\begin{examples}
\begin{pexenum}
\item \sometxt
\item \sometxt
\end{pexenum}
\end{examples}

\begin{examples}
\begin{pexenum}[leftmargin=*]
\item \sometxt
\end{pexenum}\vspace*{-2\partopsep}
\begin{pexenum}[resume]
\item \sometxt
\end{pexenum}
\end{examples}

\end{document} Edit: I you prefer right-aligned labels in lists, you can use the widest key:

\documentclass{article}
\newcommand{\sometxt}{%
Some text begins this. The identity is $\sin²(θ) + \cos²(θ) = 1$ %
and in very simple terms $(a + b)² ≠ a² + b²$.%
On the other hand, we do have the basic law of powers that $(a b)² = a² b^{2}$.
}

\usepackage{enumitem}
\usepackage{mathtools,amsthm,thmtools}

\newlist{pexenum}{enumerate}{1}
\setlist[pexenum,1]{label= \upshape(\arabic*), widest=99, leftmargin=*}

\swapnumbers

\declaretheorem[name=Theorem,numberwithin=section]{theorem}

\declaretheoremstyle[
spaceabove=12pt,spacebelow=12pt
]{exstyle}

\declaretheorem[
style=exstyle, numberlike=theorem,
]
{examples}

\begin{document}

\section{The section}

\begin{examples}
Text before the enumeration.
\begin{pexenum}[start=9]
\item \sometxt
\item \sometxt
\end{pexenum}
\end{examples}

\begin{examples}
\begin{pexenum}
\item \sometxt
\item \sometxt
\end{pexenum}
\end{examples}

\begin{examples}
\begin{pexenum}[leftmargin=*]
\item \sometxt
\end{pexenum}\vspace*{-2\partopsep}
\begin{pexenum}[resume]
\item \sometxt
\end{pexenum}
\end{examples}

\end{document} Edit: I slighly modified the code for the hack:

   \begin{examples}
\begin{pexenum}
\item[(1)\phantom{0}\kern0.05em\stepcounter{pexenumi}]\hskip-0.55em\sometxt
\item \sometxt
\end{pexenum}
\end{example} • Unfortunately, NO! None of the numerical labels is properly indented so as to allow numbers higher than 9. In the first \begin{enumerate} add \item hello\item hello\item hello\item hello\item hello\item hello\item hello\item\sometxt. Then the numerical labels become left-aligned instead of the normal right-aligned; and the text of the first line of the 10th item is pushed rightwards away from alignment with all the other items' first lines (which is the same as the whole text of the other items). Mar 12, 2021 at 1:50
• I see better. What you want was not quite clear from your post. What would be the maximum value of the labels? Mar 12, 2021 at 10:03
• for my purposes, the default maximum of 2 digits is OK. Mar 14, 2021 at 18:41
• @murray: So it's covered by the key used in my edit: widest=99. Mar 14, 2021 at 19:58
• Both 1.2 Esamples and 1.3 Examples still have the unwanted extra space between "Examples." and "(1)" that I'm trying to eliminate. Mar 15, 2021 at 15:58

You can use the first key together with the tricks in this post.

\documentclass{article}

\newcommand{\sometxt}{%
Some text begins this. The identity is $\sin^2(\theta) + \cos^2(\theta) = 1$ %
and in very simple terms $(a + b)^2 \neq a^2 + b^2$.%
On the other hand, we do have the basic law of powers that $(a b)^2 = a^2 b^{2}$.
}

\usepackage{enumitem}
\usepackage{mathtools,amsthm,thmtools}

\newlist{pexenum}{enumerate}{1}
\setlist[pexenum,1]{label= \upshape(\arabic*)}

\swapnumbers

\declaretheorem[name=Theorem,numberwithin=section]{theorem}

\declaretheoremstyle[
spaceabove=12pt,spacebelow=12pt
]{exstyle}

\declaretheorem[
style=exstyle, numberlike=theorem,
]
{examples}

\newcommand*\myfirstitem{\item[]% based on https://tex.stackexchange.com/a/17500
\refstepcounter{pexenumi}\hskip-\leftmargin\labelpexenumi\hskip0.5\labelsep
\let\olditem\item
\def\item{\let\item\olditem}%
}

\begin{document}

\section{The  section}

\begin{examples}
Text before the enumeration.
\begin{pexenum}
\item \sometxt
\item \sometxt
\end{pexenum}
\end{examples}

\begin{examples}
\begin{pexenum}[first=\myfirstitem]
\item \sometxt
\item \sometxt
\end{pexenum}
\end{examples}

\begin{examples}
\begin{pexenum}[leftmargin=*]
\item \sometxt
\end{pexenum}\vspace*{-2\partopsep}
\begin{pexenum}[resume]
\item \sometxt
\end{pexenum}
\end{examples}

\end{document} • Seems to work perfectly. Limitation: In case of multiple kinds of enumerate environments defied like that for pexenum, we would need corresponding separate versions of myfirsstitem. Caution: would need some change in (unlikely) situation of more than 99 items! Mar 13, 2021 at 22:40
• There is a defect in this myfirst... method: A blank line between the \begin{pexenum}[first=\myfirstitem] and the first \item causes the body of the first item to begin a new paragraph. Ordinarily, blank lines between a \begin{enumerate} and the first \item cause no such behavior. Mar 16, 2021 at 19:00
• @murray This may be but I am not a fan of accepting and unaccepting games, so I wish you good luck with your query.
– user237299
Mar 16, 2021 at 19:04
• Sorry, no bad intentions. I discovered the defect later on when I tried it on another document. (The underlying hack you referenced does work, though, even with the blank line before the first item.) Mar 16, 2021 at 19:42
• It does not matter, I quit anyway because of these incidents. This site is not for me.
– user237299
Mar 16, 2021 at 19:44