33

I am still struggling with enumitem. I don't understand the horizontal spacing parameters at all. I have indeed read the documentation, and numerous answers to numerous questions, but despite all that I just don't get it! I have absolutely no idea what labelindent=* or labelindent=! are supposed to do. Could someone please explain in simple terms what the five parameters are and what these * and ! options do?

In particular, I want the second line of my list here to stack under the first line rather than start slightly over to the left. Here is my attempt to do that, but as you can see it's not working. (Incidentally, I am explicitly setting labelindent=0pt because it is globally set to \parindent for normal use in this document.)

\documentclass[12pt, a4paper, oneside, fleqn]{report}

\usepackage{enumitem}
\setlist[description]{leftmargin=\parindent,labelindent=\parindent,itemsep=1pt,parsep=0pt,topsep=0pt}

\begin{document}

\chapter*{Symbols list}

\begin{description}[labelindent=0pt,labelwidth=0.7cm,leftmargin=0.7cm]
%
\item[x] Text text text text more words. Here is a full sentence to use up some space. And yet another sentence. blah blah blah
\item[y] Text text text text more words. Here is a full sentence to use up some space. And yet another sentence. blah blah blah
\item[z] Text text text text more words. Here is a full sentence to use up some space. And yet another sentence. blah blah blah

\end{description}   

\end{document}

dodgy list

Update

I've tried the solution that @Bernard has put in his answer, but it is not working for me. I'm updating my code, because my label text is quite wide (I didn't include it at first because I feel like my entire thesis will be published in tex.se before I submit ;-).

Here is Bernard's suggestion with the labelwidth extended to 2.1cm to accommodate the wide text, and labelindent=0pt, which is a setting I wanted:

\documentclass[12pt, a4paper, oneside, fleqn]{report}

\usepackage{enumitem}
\setlist[description]{leftmargin=\parindent,labelindent=\parindent,itemsep=1pt,parsep=0pt,topsep=0pt}

\usepackage[showframe, top=2.5cm, left=3.5cm, bottom=2.5cm, right=2.5cm, includehead]{geometry}
\geometry{headheight=28pt, headsep=18pt}

\begin{document}

\chapter*{Symbols list}

\begin{description}[labelindent=0em ,labelwidth=2.1cm, labelsep*=1em, leftmargin =!, style = standard]%

\item[$\mathbf{H}$] Forward model Jacobian matrix
\item[$\mathbf{MoistCov}$] Background error covariance matrix calculated from an ensemble of forecast states and using a new moisture control variable designed to eliminate increments in the stratosphere.

\end{description}   

\end{document}

Here's what it looks like: enter image description here

Here's what happens when in addition to that I comment out the \setlist command at the beginning, which is odd because there is clearly some interaction, though I don't know wny, because it looks like I should have overridden the horizontal settings. It looks like leftmargin=! is not calculating leftmargin from the other settings: commentout

  • Set itemindent to 0pt to get things to align. I always find the picture on page 5 the only way to really get to grips with this stuff. – cfr Jun 13 '14 at 23:30
  • @cfr thanks for the suggestion. That does align the two lines of the description, but now the label is off to the left and into the margin. I don't find the picture on p5 at all helpful - if I did, I wouldn't have needed to ask this question! – FionaSmith Jun 14 '14 at 19:42
18
+50

Enumitem introduces a new very useful length, labelsep*, such that labelsep* + itemindent = labelsep (see § 3.3 of the documentation). Setting labelindent + labelwidth + labelsep* = leftmargin gives what you want, while allowing label text to be longer than the default. If style=standard, a wider label changes the left margin of the list, while with style=sameline, it can go over the left margin:

\documentclass[12pt, a4paper, oneside, fleqn]{report}
\usepackage[showframe, nomarginpar]{geometry}

\usepackage{enumitem}

\begin{document}

\chapter*{Symbols list}

\begin{description}[labelindent=1em ,labelwidth=1.3cm, labelsep*=1em, leftmargin =!, style = standard]% 
\item[x text]Text text text text more words. Here is a full sentence to use up some space. And yet another sentence. blah blah blah
\item[y] Another text text text text more words. Here is a full sentence to use up some space. And yet another sentence. blah blah blah
\item[z] Text text text text more words. Here is a full sentence to use up some space. And yet another sentence. blah blah blah
\end{description}

\begin{description}[labelindent=1em ,labelwidth=1.2cm, labelsep*=1em, leftmargin =! , itemindent = 0pt, style = sameline]
\item[x text]Text text text text more words. Here is a full sentence to use up some space. And yet another sentence. blah blah blah
\item[y] Another text text text text more words. Here is a full sentence to use up some space. And yet another sentence. blah blah blah
\item[z] Text text text text more words. Here is a full sentence to use up some space. And yet another sentence. blah blah blah
\end{description}

\end{document}

enter image description here

To explain in more detail what happens, the label begins at label indent, the beginning of the lines that follow the label line is at leftmargin, which is equal to label indent + labelwidth +labelsep*. Setting the values of the first 3, and leftmargin=! make left margin be computed from the first three as indicated.

It works along the same lines for enumerate and itemize, except that label alignment in these cases is right, so that if label width is too small,the label can go into the (page) left margin. It behaves as a kind of \llap{label}.

Let me explain why your code does not work: the order in which you set the keys is important. Setting style=standard at the end, you overrode the previous values with those defined in standard style – just as the setlist{description}{…} values in the preamble can be overridden by the actual optional parameters in a description environment. If you change your code to the following, it works as you want:

\documentclass[12pt, a4paper, oneside, fleqn]{report}
\usepackage[utf8]{inputenc}

\usepackage{enumitem}

\usepackage[showframe, top=2.5cm, left=3.5cm, bottom=2.5cm, right=2.5cm, includehead]{geometry}
\geometry{headheight=28pt, headsep=18pt}

\begin{document}

\chapter*{Symbols list}

\begin{description}[style =standard, labelindent=0em , labelwidth=2cm, labelsep*=1em, leftmargin =!]%
\item[$\mathbf{H}$] Forward model Jacobian matrix
\item[$\mathbf{MoistCov}$] Background error covariance matrix calculated from an ensemble of forecast states and using a new moisture control variable designed to eliminate increments in the stratosphere.

\end{description}

\end{document} 

enter image description here

The leftmargin=! key means that left margin is computed from the other parameters as described in § 3.3, viz leftmargin=labelindent + labelwidth + labelsep*, which have all been chosen. Note that with almost the same keys, only deleting leftmargin=! gives a different result, as there must be a predefined value of leftmargin that is not overridden:

enter image description here

Writing parameterkey=! means that this parameter is computed in function of the others, whether you've set them explicitly or they're set by the environment, style, &. As far as I understand it, parameterkey=* means the same thing with the added feature that labelwidth is set to a conventional value (that of viii for a roman style enumeration for instance). I think it has a meaning for enumerate environments, although this is not very clear to me from the documentation.

  • Thanks. That works as you describe. But I still don't understand it. I get the same with labelsep rather than labelsep* but I guess it is because I set labelindent=0pt. I am still hoping for a slightly more complete answer that augments the diagrams that I don't fully understand, and that explains what the ! is all about as well. – FionaSmith Jun 14 '14 at 20:03
  • Also (you weren't to know this) I'd rather all of the items in the list had their descriptions at the same indent rather than the description being under the label if the label text is long-ish (it is a symbols list: none are that long. I thought maybe I could use widest but again I don't understand the documentation. Maybe I should just use a table instead! – FionaSmith Jun 14 '14 at 20:09
  • If you get the same with labelsep as with labelsep*, it's rather because itemindent=0pt`, since labelsep=labelsep* + itemindent. I completed my answer and solution to have a label indent while having all lines of the description indented by the same amount. – Bernard Jun 15 '14 at 0:57
  • Sorry I've been off and then busy at work. I've been trying to take the time to read the enumitem documentation again. I really would like to accept your answer because you have solved my specific problem, and your updates are certainly most helpful. The problem is that I still don't understand what foo=* and bar=! mean, and I am not sure what labelindent*=xyz would do. I was really hoping for a very comprehensive answer so I can do it myself next time. Would a bounty help...? – FionaSmith Jun 17 '14 at 20:14
  • Actually, apologies, but it's not working for me anyway. I'll update my question. – FionaSmith Jun 17 '14 at 20:41
24
\documentclass{article}
\usepackage{enumitem}
\usepackage{layouts}
\begin{document}
\listdiagram

\clearpage
\begin{enumerate}
\item The figure illustrates the layout of an \texttt{enumerate} list.
\currentlist
\listdesign
\end{enumerate}

\end{document}

enter image description here

enter image description here

  • 1
    Thanks Herbert, I am sure this is a diagram I am going to refer to again, it looks very useful. I am giving the bounty to Bernard, because he spent quite some time answering my multiple questions and added quite a lot of explanations. – FionaSmith Jun 19 '14 at 19:28
  • 6
    I wish this diagram was in the package's doc – Julien-L Dec 29 '14 at 7:58
  • Could you add an image for the case when align=left. Your picture is very nice! – Colas Aug 7 '18 at 12:50
  • That cannot be seen, because the text "Label" is wider than the in the image defined labelwidth. – user2478 Aug 7 '18 at 16:41
6

You can see from this question How to draw this lines with tikzmark a scheme shows the different horizontal lengths in the enumirate environment

enter image description here

5

This is to address your update to the question.

The order of options is important. In particular, later options override earlier ones. Now hidden in style=standard is itemindent=!. If there is a previous leftmargin=! this will be overridden by the itemindent=!.

Below are examples to compare. The third is the same as yours without the horizontal spacing parts of your \setlist[description]. Notice it produces the same output as with itemindent=! as with leftmargin=!,style=standard. The second has leftindent=! instead of itemindent=! and produces different spacing. Thus the sytle=standard is overriding the leftmargin=!.

Examples 4, 5 and 6 demonstrate the same behaviour now in the presence of your \setlist options.

Demonstration output

\documentclass[12pt, a4paper, oneside, fleqn]{report}

\usepackage{enumitem}
\setlist{itemsep=1pt,parsep=0pt,topsep=0pt}

\usepackage[showframe, top=2.5cm, left=3.5cm, bottom=2.5cm, right=2.5cm, includehead]{geometry}
\geometry{headheight=28pt, headsep=18pt}

\begin{document}

\chapter*{Symbols list}

\begin{description}[labelindent=0pt,labelwidth=2.1cm,labelsep*=1em,itemindent=!]
\item[$\mathbf{H}$] Forward model Jacobian matrix
\item[$\mathbf{MoistCov}$] Background error covariance matrix
  calculated from an ensemble of forecast states and using a new
  moisture control variable designed to eliminate increments in the
  stratosphere.
\end{description}

\begin{description}[labelindent=0pt,labelwidth=2.1cm,labelsep*=1em,leftmargin=!]
\item[$\mathbf{H}$] Forward model Jacobian matrix
\item[$\mathbf{MoistCov}$] Background error covariance matrix
  calculated from an ensemble of forecast states and using a new
  moisture control variable designed to eliminate increments in the
  stratosphere.
\end{description}

\begin{description}[labelindent=0em ,labelwidth=2.1cm, labelsep*=1em,
  leftmargin =!,style=standard]%
\item[$\mathbf{H}$] Forward model Jacobian matrix
\item[$\mathbf{MoistCov}$] Background error covariance matrix
  calculated from an ensemble of forecast states and using a new
  moisture control variable designed to eliminate increments in the
  stratosphere.
\end{description}

\setlist[description]{leftmargin=\parindent,labelindent=\parindent}
\begin{description}[labelindent=0pt,labelwidth=2.1cm,labelsep*=1em,itemindent=!]
\item[$\mathbf{H}$] Forward model Jacobian matrix
\item[$\mathbf{MoistCov}$] Background error covariance matrix
  calculated from an ensemble of forecast states and using a new
  moisture control variable designed to eliminate increments in the
  stratosphere.
\end{description}

\begin{description}[labelindent=0pt,labelwidth=2.1cm,labelsep*=1em,leftmargin=!]
\item[$\mathbf{H}$] Forward model Jacobian matrix
\item[$\mathbf{MoistCov}$] Background error covariance matrix
  calculated from an ensemble of forecast states and using a new
  moisture control variable designed to eliminate increments in the
  stratosphere.
\end{description}

\begin{description}[labelindent=0em ,labelwidth=2.1cm, labelsep*=1em,
  leftmargin =!,style=standard]%
\item[$\mathbf{H}$] Forward model Jacobian matrix
\item[$\mathbf{MoistCov}$] Background error covariance matrix
  calculated from an ensemble of forecast states and using a new
  moisture control variable designed to eliminate increments in the
  stratosphere.
\end{description}

\end{document}
  • Thanks Andrew, this is a very useful answer also and helped me to understand what is going on. I've given the bounty to Bernard though because he edited his answer several times to address my questions. – FionaSmith Jun 19 '14 at 19:30
  • @FionaSmith Glad it helped. No problem about the boundy, Bernards answer is good. – Andrew Swann Jun 20 '14 at 7:29
  • @Andrew Thank you for your answer. How do you incorporate those settings when defining a custom description environment in the preamble? I couldn't manage the second example. – blackened Sep 24 '15 at 20:43
  • @blackened You should just be able to use \setlist. Can you post the example code you have tried - it would have to be as a new question. – Andrew Swann Sep 25 '15 at 15:18
0

I've found the following diagram, from § 8.16 list of LaTeX2e unofficial reference manual (October 2018) to be very helpful:

enter image description here

where:

  • h0: \labelwidth
  • h1: \labelsep
  • h2: \listparindent
  • h3: \leftmargin
  • h4: \itemindent
  • h5: \rightmargin

The critical equality is that the right edge of the bracket for h1 is the same horizontal location as the right edge of the bracket for h4, implying that the left edge of the label box is located at:

h3+h4-(h0+h1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.