[Tex/LaTex] Labels in the left margin

horizontal alignmentlists

I would like to produce a text with labels in the left margin, like a reference list. Labels may have different lengths. One way to do this is to define a negative \parindent, as follows:

\parindent-12mm
\makebox[12mm][l]{A} text text text   text text text text text   text text text text   text text  text    texttexttexttext  \par 
\makebox[12mm][l]{ABC} text text text   text text text text   text text text text   text text  text    texttexttexttext 

The purpose of the box is to make the text begin at the left edge of the text column. However, in this way the left edge of the text column won’t be straight, because Tex expands or shrinks spaces evenly along the entire line, including the box. Therefore (instead of the box) I would need, after the label, a command that moves to the left edge of the text column in the same way as a tab command. Is there such a command?

Best Answer

This is easy with the enumitem package. Just define

\SetLabelAlign{margin}{\llap{#1~~}}

and use it like

\begin{description}[align=margin,labelsep=0pt]
  \item[A] text text text
  \item[ABC] text text text
\end{description}

MWE

\documentclass{article}
\usepackage{enumitem}
\SetLabelAlign{margin}{\llap{#1~~}}
\usepackage{showframe} % just to show the margins
\begin{document}

\begin{description}[align=margin,labelsep=0pt]
  \item[A] text text text
  \item[ABC] text text text
\end{description}

\end{document} 

Output

enter image description here

Another solution is to define

\SetLabelAlign{margin}{\llap{\makebox[12mm][l]{#1}}}

In this way the result will be

enter image description here