4

I found Description list with right alignment of labels while looking for a solution for my own problem. I tried to modify the above solution, but there are a few ugly things I don't know what to do about.

  1. Using noitemsep to remove the space between the items results in different spacing between lines in labelboxes and labelboxes to each other.
  2. If the text in the labelbox is too long and therefore a line break needed, then the second line of the text belonging to the label starts after the labelbox, not in the second line.

enter image description here

Here is the corresponding code:

\documentclass{article}  
\usepackage{enumitem}  
\SetLabelAlign{parright}{\parbox[t]{\labelwidth}{\raggedleft#1}}
\setlist[description]{style=multiline,leftmargin=3.5cm, align=parright,noitemsep}

\begin{document}

\begin{description}
  \item[here is a long long label] text
  \item[here is a long long label]  and here a long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
\end{description}

\end{document}

What can/should I do?

  • Why do you want to use noitemsep if you want spacing between the items? – Peter Grill Mar 27 '12 at 16:19
  • I dont want to have space between items, but rather, if there is one, to be identical. Like in the picture: the space between the first and the second labelbox is smaller then the space between the two lines inside of the labelbox. And, the big space in the second textbox is annoying me. – gregmic Mar 27 '12 at 16:29
4

Here is:

\documentclass{article}  
\usepackage{enumitem}  
\SetLabelAlign{parright}{\strut\smash{\parbox[t]{\labelwidth}{\raggedleft#1}}}
\setlist[description]{style=multiline,leftmargin=3.5cm, align=parright,noitemsep}

\begin{document}

\begin{description}
  \item[here is a long long label] text\\\mbox{}
  \item[here is a long long label]  and here a long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
\end{description}

\end{document}

Note (1) I've added a \smash to the label, and (2) I've added an empty line by hand to the first item, to avoid the problem shown in the manual related to multiline labels.

  • ok, but if you add these lines: >> \item[short] short text \\\mbox{} \item[short] short text \\\mbox{} << there will be again a blank line between these lines. – gregmic Mar 27 '12 at 18:35
  • Of course, you should add a blank line only if the label has more lines than the item body. – Javier Bezos Mar 28 '12 at 12:09
0

This is my solution I'm using right now:

\setlist[description]{style=multiline,leftmargin=3.7cm,parsep=6px}

then using a description list, and, if the label is too long, I'm just filling the textbox with \\ \hspace*{\fill}, works pretty fine for me :-)

0

and with a possible pagebreak

\documentclass{article}  
\usepackage{ltablex}% available from http://www.ctan.org/tex-archive/macros/latex/contrib/ltablex
\renewcommand*{\arraystretch}{1.2}
\begin{document}

\noindent
\begin{tabularx}{\linewidth}{@{} >{\bfseries\raggedleft}p{0.25\linewidth} X @{}}
here is a long long label & text \\
here is a long long label & and here a long long long long long long long long long
long long long long long long long long long long long long long long long long long 
long long long long text\\
\pagebreak
here is a long long label & and here a long long long long long long long long long 
long long long long long long long long long long long long long long long long long 
long long long long text
\end{tabularx}

\end{document}
  • well, the problem is, that the text could also be as long as half of a page, and so leaving a lot of free and unused space, as I can't have a page break in a pbox... – gregmic Mar 27 '12 at 17:29
  • if you have not too many of thos description list, it can be done by hand ... – user2478 Mar 27 '12 at 17:31
  • I got 18-30 of those, with each 13 items, and one of these items contains of a really long text, like I said, half a page. And the problem with such a long pbox is, that I can't have a pagebreak in it... – gregmic Mar 27 '12 at 17:50
  • you can insert it by hand with `\parfillskip=0pt\` in a tabular line – user2478 Mar 27 '12 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.