# How to align description item labels on the right?

I have seen description-list-with-right-alignment-of-labels that explains, how to align description labels on the right. However the presented solution sets the lengths globally whereas I look for a local solution, meaning to specify the width for each environment separately. Is there a way telling each description environment what the broadest item is:

\documentclass{article}
\usepackage{enumitem}
\SetLabelAlign{parright}{\parbox[t]{\labelwidth}{\raggedleft#1}}

\setlist[description]{style=multiline,topsep=10pt,leftmargin=5cm,font=\textbf,align=parright}

\begin{document}

\begin{description}
\item[aaa] some text
\item[bbbbbb] some more text
\item[ccccccccc] and some text
\end{description}

\begin{description}
\item[aaaaaaa] some text
\item[bbbbbbbbbbbbbbb] some more text
\item[ccccccccccccccccccccccc] and some text
\end{description}

\end{document}

-
I don't have time to explain the exact details, so here's a short note. You can define an environment that uses the list environment to typeset the description list. Let the environment take an option that takes the item with the maximum width. Use it to set the \labelwidthat the start of the environment (using the style for the labels). You also have to redefine \makeitem, which should use the label, and set it in the right style, right justified in an \hbox to \labelwidth (or equivalent). It's not too much work, but keep track of how the list environment positions the labels. – Marc van Dongen Mar 2 '12 at 8:39
You are aware that enumitem allows you to set parameters both globally (as in your MWE) and locally (as in \begin{description}[style=...])? – DevSolar Mar 2 '12 at 8:40
Apologies: \makeitem should be \makelabel. – Marc van Dongen Mar 2 '12 at 9:01

You can use the \widthof{} from the calc package to compute the correct width for the labelwidth on a per description list to obtain:

The parameter passed to the \widthof{} should be the widest element in the description list and also note that since the label is set in bold font, we need to ensure that the measurements are done with \bfseries applied:

\documentclass{article}
\usepackage{calc}
\usepackage{enumitem}
\SetLabelAlign{parright}{\parbox[t]{\labelwidth}{\raggedleft#1}}

\begin{document}
\begin{description}[labelwidth=\widthof{\bfseries ccccccccc},align=parright]
\item[aaa]       some text
\item[bbbbbb]    some more text
\item[ccccccccc] and some text
\end{description}

\begin{description}[labelwidth=\widthof{\bfseries ccccccccccccccccccccccc},align=parright]
\item[aaaaaaa]                 some text
\item[bbbbbbbbbbbbbbb]         some more text
\item[ccccccccccccccccccccccc] and some text
\end{description}
\end{document}

-
Furthermore, if the label is always set to the widest one, then boxing it in a parbox is unnecesary - just use align=right. (And I added to the todo list a widest for description.) – Javier Bezos Mar 3 '12 at 9:20