9

In enumitem manual, I can't find a clear explanation of the difference between the usage of exclamation mark and asterisk for leftmargin, itemindent, labelsep, labelwidth, and labelindent.

For example, what is the difference between setting labelsep=*

enter image description here

and labelsep=!?

enter image description here

\documentclass{article}
\usepackage{enumitem}

\newcommand\litem[1]{\item{\bfseries#1.\space}}

\begin{document}

\begin{enumerate}[label=(\alph*),labelsep=!]
 \litem{Term one} First term description.
 \litem{Term two} Second term description.
\end{enumerate}

\end{document}
2
  • Could you explain what was left unclear by the explanation on page 7 of the manual? I found it rather comprehensive.
    – schtandard
    Commented May 14, 2019 at 21:17
  • 5
    @schtandard If it's very clear to you, post an answer that doesn't quote the text of the documentation, but instead explains it in another way (perhaps with some examples.) This would be a really useful answer, I suspect.
    – Alan Munn
    Commented May 14, 2019 at 21:21

1 Answer 1

17

As explained in the enumitem documentation, the horizontal spacing in lists is composed of the parameters leftmargin, itemindent, labelsep, labelwidth and labelindent as follows:

indentation in lists

That is to say:

  1. The values obey the relation

    leftmargin = labelindent + labelwidth + labelsep - itemindent
    
  2. The right edge of the \item label will be indented by labelindent + labelwidth.

  3. The first line of the Text of the \item will be indented by leftmargin + itemindent.

  4. Subsequent lines will be indented by leftmargin.

As you can see, there are five parameters but they are not all independent. Given any four of them you can calculate the fifth, which is where the ! and * values to these options come in.


Why have this redundancy at all? Well, in standard LaTeX, the parameter labelindent does not exist; it is introduced by enumitem. The author of the package felt that it might be useful to be able to directly set the indentation of the list label instead of having to calculate the other values manually in order to achieve the desired indentation.

By default, the new parameter labelindent is always calculated from the others. If you want to directly set labelindent, you will have to tell enumitem which parameter it should calculate instead. That is what the ! value is for.

* does exactly the same thing, but it also first sets labelwidth. This is useful because the right edge of the label is indented by labelindent + labelwidth, so the left edge of the label will only be indented by exactly labelindent if the width of the label actually is labelwidth. enumitem tries to guess the width of the widest possible label by measuring the width of the label with value

  • 0 if label is set using \arabic*,
  • viii if label is set using \roman*,
  • m if label is set using \alph* and
  • similarly for the uppercase versions.

So, if you set label=(\alph*), enumitem will measure the width of (m) and set labelwidth to this value. You can change this behavior using the widest option.

Note that this means that labelwidth=! and labelwidth=* do exactly the same thing.


Okay, so let's have a look at an example. enumitem acknowledges that the behavior of these values may be confusing and provides \DrawEnumitemLabel to visualize the current values, which I will use below. It

[...] draws 4 rules from top to bottom, labelindent, labelwidth, labelsep, itemindent (thin if positive, thick if negative); the leftmargin is marked with two vertical rules.

\documentclass{article}

\usepackage{enumitem}

\parindent=0pt
\newcommand*\printvalue[1]{\texttt{\string #1} : \the #1}

\begin{document}

% set some defaults:
\setlist{
        label=(\alph*),
        leftmargin=50pt,
        itemindent=10pt,
        labelsep=5pt,
        labelwidth=25pt,
        labelindent=10pt,
    }

By default, my definition of \verb|labelindent| is just ignored and it is calculated from the other values:
\begin{enumerate}
    \DrawEnumitemLabel
    \item \printvalue\leftmargin
    \item \printvalue\itemindent
    \item \printvalue\labelsep
    \item \printvalue\labelwidth
    \item \printvalue\labelindent
\end{enumerate}

I can change that using the \verb|!| value.
For example, I can instead calculate \verb|labelsep| from the other values:
\begin{enumerate}[labelindent=10pt, labelsep=!]
    \DrawEnumitemLabel
    \item \printvalue\leftmargin
    \item \printvalue\itemindent
    \item \printvalue\labelsep
    \item \printvalue\labelwidth
    \item \printvalue\labelindent
\end{enumerate}

The \verb|*| value does exactly the same, only it also set the value of \verb|labelwidth| first.
It tries to guess the widest possible label (\textsl{0} for \verb|\arabic*|, \textsl{viii} for \verb|\roman*|, \textsl{m} for \verb|\alph*|):
\begin{enumerate}[labelindent=10pt, labelsep=*]
    \DrawEnumitemLabel
    \item \printvalue\leftmargin
    \item \printvalue\itemindent
    \item \printvalue\labelsep
    \item \printvalue\labelwidth
    \item \printvalue\labelindent
\end{enumerate}

\end{document}

MWE output

6
  • 3
    +1 Great answer!
    – Alan Munn
    Commented May 14, 2019 at 22:50
  • 1
    This encyclopedic and informative answer is what I am looking for. Many thanks for your great explanation.
    – Diaa
    Commented May 14, 2019 at 23:09
  • Thanks! This is amost exact answer I want! Here I have some small questions: if I use * in labelsep, then enumitem will ignore what I set in labelwidth and just use the guessed widest width, and if I set !, enumitem will use the length I set in labelwidth?
    – Syvshc
    Commented Dec 5, 2021 at 2:32
  • In v3.7, the command \DrawEnumitemLabel's performance changes, now it can show all 5 lengths, and changes thin and thick's situation. Maybe you can update the figure to make it more clear :)
    – Syvshc
    Commented Dec 5, 2021 at 2:37
  • 1
    @Syvshc Thanks for the note on the changed \DrawEnumitemLabel. Regarding your question: Yes, exactly. The default values for list layouts will depend on your document class (and font settings).
    – schtandard
    Commented Dec 7, 2021 at 12:17

You must log in to answer this question.

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