1

The ordinary use of the enumerate environment is like this:

Text above.
\begin{enumerate}
\item Now is the time for all good men. Now is the time for all
  good men. Now is the time for all good men. Now is the time for all
  good men. Now is the time for all good men. Now is the time for all
  good men. Now is the time for all good men. Now is the time for all
  good men.
\item Now is the time for all good men.
\end{enumerate}
Text below.

which produces output like this:

Text above.
  (1) Now is the time for all good men. Now is the time for all
      good men. Now is the time for all good men. Now is the time for all
      good men. Now is the time for all good men. Now is the time for all
      good men. Now is the time for all good men. Now is the time for all
      good men.
  (2) Now is the time for all good men.
Text below.

However, if I use custom labels on the \item, the labels are placed with their right ends at the same location as the standard labels would be, which gives poor results if the labels are of any length, shoving the left end of the label toward the margin:

Text above.
\begin{enumerate}
\item[elephant] Now is the time for all good men. Now is the time for all
  good men. Now is the time for all good men. Now is the time for all
  good men. Now is the time for all good men. Now is the time for all
  good men. Now is the time for all good men. Now is the time for all
  good men.
\item Now is the time for all good men.
\end{enumerate}
Text below.
Text above.
elephant Now is the time for all good men. Now is the time for all
      good men. Now is the time for all good men. Now is the time for all
      good men. Now is the time for all good men. Now is the time for all
      good men. Now is the time for all good men. Now is the time for all
      good men.
  (2) Now is the time for all good men.
Text below.

Is there a good/simple way to put a custom label on an item and align the left end of the label where the left end of a standard label would be (shoving the item text to the right as needed)?

Text above.
  elephant Now is the time for all good men. Now is the time for all
      ...
  (2) Now is the time for all good men.
Text below.
2
  • Please confirm that you use the enumerate package.
    – Mico
    Oct 16, 2023 at 22:56
  • Micro: I use a largely default LaTeX installation on Linux. It provides an enumerate environment, which is what I'm using here. I have no idea what "package" might be providing it.
    – Dale
    Oct 20, 2023 at 16:00

2 Answers 2

1

enumitem provides the sameline style option (style=sameline) that accommodates for this layout. Some additional margin adjustments may be necessary, as is done in the example below.

enter image description here

\documentclass{article}

\usepackage{enumitem}

\setlength{\parindent}{0pt}% Just for this example

\begin{document}

Text above.
% Default layout
\begin{enumerate}[label=(\arabic*)]
  \item Now is the time for all good men. Now is the time for all
    good men. Now is the time for all good men. Now is the time for all
    good men. Now is the time for all good men. Now is the time for all
    good men. Now is the time for all good men. Now is the time for all
    good men.
  \item Now is the time for all good men.
\end{enumerate}
Text below.

\hrulefill

Text above.
% Updated layout
\begin{enumerate}[label=(\arabic*),align=left,labelindent=0.7em,leftmargin=*,style=sameline]
  \item[elephant]
    Now is the time for all good men. Now is the time for all
    good men. Now is the time for all good men. Now is the time for all
    good men. Now is the time for all good men. Now is the time for all
    good men. Now is the time for all good men. Now is the time for all
    good men.
  \item Now is the time for all good men.
\end{enumerate}
Text below.

\end{document}

You can create a new list to capture this style:

\newlist{mylist}{enumerate}{1}% mylist matches enumerate up to 1 level of enumeration
\setlist[mylist]{
  label=(\arabic*),
  align=left,
  labelindent=0.7em,
  leftmargin=*,
  style=sameline
}

This will allow you to use \begin{mylist}...\end{mylist} in your document.

2
  • This works for me, though I need to use labelindent=1.5em to get the same spacing as for baseline enumerate.
    – Dale
    Oct 17, 2023 at 20:29
  • I also added font=\upshape because enumitem lets the surrounding font type leak through to the labels, and (1) looks better in upright than italic.
    – Dale
    Oct 17, 2023 at 20:44
0

I have a crude solution using the hack of making the custom label empty (to suppress the standard label), putting the label at the start of the item body, and manually outdenting the label by 2 em:

Text above.
\begin{enumerate}
\item[\hbox{}] \hskip -2em elephant The text. Now is the time for all
  good men. Now is the time for all good men. Now is the time for all
  good men. Now is the time for all good men. Now is the time for all
  good men. Now is the time for all good men. Now is the time for all
  good men.
\item Now is the time for all good men.
\end{enumerate}
Text below.
Text above.
  elephant Now is the time for all good men. Now is the time for all
      ...
      good men.
  (2) Now is the time for all good men.
Text below.

You must log in to answer this question.

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