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}
list
environment to typeset thedescription
list. Let the environment take an option that takes the item with the maximum width. Use it to set the\labelwidth
at 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 thelist
environment positions the labels.enumitem
allows you to set parameters both globally (as in your MWE) and locally (as in\begin{description}[style=...]
)?\makeitem
should be\makelabel
.