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}
Best Answer
You can use the
\widthof{}
from thecalc
package to compute the correct width for thelabelwidth
on a perdescription
list to obtain:The parameter passed to the
\widthof{}
should be the widest element in thedescription
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: