How to set leftmargin of description to width of a particular label in enumitem?

I'd like to make a timeline with a description environment.

If I use the following:

\documentclass{article}
\usepackage{enumitem}

\begin{document}

\begin{description}[leftmargin=*,label=0000]
\item[1987]Something really exciting happened in that year, but I’m not sure exactly what.
\item[1990]Bar
\end{description}

\end{document}


I get an error:

ERROR: Missing control sequence inserted.

--- TeX said ---
<inserted text>
\inaccessible
l.7 \begin{description}[leftmargin=*]


It seems that label=0000 doesn't work for description environments?

If I simply put leftmargin=2.8em (for this particular case), then I get what I want: the second line of the first item lines up with the first line:

But obviously I'd prefer to achieve this by giving the label to be measured dynamically.

• Nov 21, 2017 at 19:17

Here are two ways:

\documentclass{article}
\usepackage{enumitem}
\usepackage{calc}

\begin{document}

\begin{description}[labelwidth =\widthof{\bfseries9999}, leftmargin = !]
\item[1987]Something really exciting happened in that year, but I’m not sure exactly what.
\item[1990]Bar
\end{description}
\bigskip

\begin{enumerate}[wide = 0pt, widest = {\bfseries9999}, leftmargin =*, font = \bfseries]
\item[1987]Something really exciting happened in that year, but I’m not sure exactly what.
\item[1990]Bar
\end{enumerate}

\end{document}


• This is great; it works and measures the argument as desired. I'd like to understand better what's going on if possible. First, I think it can be simpler: \begin{description}[noitemsep,labelwidth=widthof{\bfseries9999},leftmargin=!] seems to work. Secondly, any clue why setting labelwidth works but setting label gives an error? Is it a bug in enumitem? Nov 21, 2017 at 21:15
• Thanks for your remark. You're right: leftmargin=! works (and it is indeed simpler). I thought I has tried it , but it didn't work for some reason. As I tested several other possibilities, I probably forgot this one. I've modified the code. For your second question, I don't quite understand what you mean with ‘setting label’, for a description environment? Nov 21, 2017 at 21:24
• Answer accepted, thanks. I mean, why does setting label=0000 in the optional parameter to \begin{description}, as I did in my question, give an error? Nov 21, 2017 at 21:25
• Probably because there can be no more or less standard pre-defined label for a description environment as there is for enumerate or itemize. I even tried widest= (which can be a string), but it doesn't work either. Nov 21, 2017 at 21:29

You can use labeling:

\documentclass{article}
\usepackage{scrextend}
\setkomafont{labelinglabel}{\bfseries}

\begin{document}

\begin{labeling}{9999}
\item[1987]Something really exciting happened in that year, but I’m not sure exactly what.
\item[1990]Bar
\end{labeling}

\end{document}


If you already use a KOMA-Script class, you can and should omit package scrextend:

\documentclass{scrartcl}
\setkomafont{labelinglabel}{\bfseries}

\begin{document}

\begin{labeling}{9999}
\item[1987]Something really exciting happened in that year, but I’m not sure exactly what.
\item[1990]Bar
\end{labeling}

\end{document}


• Thanks very much for this; this looks like a decent answer, but I'm going to prefer the one that uses enumitem which I'm already using (and I'm not using KOMA-Script for this document; maybe II should be!). Nov 21, 2017 at 21:12
• Thanks for the reminder; I've upvoted both answers, as they're both good! Nov 22, 2017 at 13:09