4

This should be a simple one, hopefully.

I like to align the label of the items in my enumerate environment with the left margin. I can do this with the option [labelsep = *] from the enumitem package. See the MWE below.

But when I have >9 items in my list, the labels are still left aligned with the second digit of the numeral. What I want is to left align the labels of my items according to the widest label in my list, so that no label ever bleeds into the margin.

I have tried playing with the option labelwidth, but it has no effect (presumably because I have set labelsep = *?

\documentclass{article}

\usepackage{lipsum, showframe}
\usepackage{enumitem}
    \setlist[enumerate, 1]% global settings for the first level in enumerate environments
        {%
            leftmargin = \parindent, % item text indentation
            labelsep = * % item label at margin
        }

\begin{document}

\lipsum[4]

\begin{enumerate}

    \item \lipsum[4]
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item

\end{enumerate}
\lipsum[4]

\end{document}

Output of MWE


EDIT

The same question has been asked in How to make enumerate items align at left margin?, but all the answers are 13 years old, and don't reflect the current status of the enumitem package.

In the documentation to the current version (3.9) of enumitem, a solution to this problem seems to be presented at the bottom of page 11, where a command \EnumitemId is explained, referencing the stackexchange question linked above. But the explanation in the documentation is incomplete, ending with "Then just use the key widestlabel", without explaining how it should be used, and with no example.

1

2 Answers 2

3

Set the following:

  • leftmargin = \parindent

    Ensures that the contents of each item uses \parindent as its indentation.

  • align = left

    Places each label inside a box that is left-aligned.

  • labelwidth = \parindent

    Ensures that the label is contained within a fixed-width box.

  • labelsep = 0pt

    Removes the gap between the label and the item content. Together with the fixed-width box for the left-aligned label, both the item numbers and the content are aligned horizontally across the page.

enter image description here

\documentclass{article}

\usepackage{lipsum, showframe}
\usepackage{enumitem}

\setlist[enumerate, 1]{% global settings for the first level in enumerate environments
  leftmargin = \parindent, % item text indentation
  align = left,
  labelwidth=\parindent,
  labelsep = 0pt
}

\begin{document}

\lipsum[4]

\begin{enumerate}

    \item \lipsum[4]
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item \lipsum[1][1]
    \item \lipsum[1][2]
    \item
    \item
    \item
    \item
    \item \lipsum[1][1]
\end{enumerate}

\lipsum[4]

\end{document}
2
  • If you want the labels to be right-aligned (like they usually are) and the left margin to still align with \parindent, you'll have to increase \parindent a little and use a non-zero labelwidth.
    – Werner
    Commented Jul 11 at 20:40
  • This is one good option, where the numbers in the labels are left aligned. But for now, I think I want to the numbers to be right aligned, keeping the single digits in the same position as the one digit in numbers >9. I think enumitem has a way of doing this, but I don't understand its implementation, see the update to my main question above. Once I know how to both left and right align the numbers, I can decide which one is more aesthetically pleasing.
    – Sverre
    Commented Jul 13 at 16:57
3

Add the option [widest=99] (or 999 etc as appropriate) directly to your 'enumerate' environment.

\documentclass{article}

\usepackage{lipsum, showframe}
\usepackage{enumitem}
    \setlist[enumerate, 1]% global settings for the first level in enumerate environments
        {%
            leftmargin = \parindent, % item text indentation
            labelsep = *, % item label at margin
            widest = 99
        }

\begin{document}

\lipsum[4][1-3]

\begin{enumerate}

    \item \lipsum[1][1-3]
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item

\end{enumerate}
\lipsum[4][1-3]

\end{document}

enter image description here

2
  • 1
    For example: \setlist[enumerate, 1]{leftmargin = *, widest=99 }
    – Zarko
    Commented Jul 11 at 21:51
  • This works, but it would be nice to have it automated, so that enumitem itself could keep track of what the widest label was, without needing the user to manually check every list and insert the appropriate width. See the update to my question above.
    – Sverre
    Commented Jul 13 at 16:51

You must log in to answer this question.

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