[Tex/LaTex] How to set leftmargin of description to width of a particular label in enumitem

descriptionenumitem

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:

What I'd like to get

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

Best Answer

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} 

enter image description here

Related Question