1

I use the enumitem package to customise description lists. Here a MWE printing some fictitious personal details:

\documentclass{article} 
\usepackage{enumitem}
\setlist[description]{leftmargin=5em, labelindent=0em, labelwidth=4.5em,
                      align=right}

\begin{document} 
\begin{description}
\item[Address]
3 Whole St, Wondertown WXY 2722
\item[Email]
aldo.thoughful@etheral.con
\item[Phone]
123 55 66 78
\item[Secondary Phone]
123 78 66 55
\item[Nationality]
Wonderland, Republic of Home and Mother Country
\item[Security Clearance]
National Clearance 13.2 with a very, very, very,
very, very, very, very, very, very, very, very,
very, very, very, very long explanation
\end{description}

\end{document}

The output looks basically like this:

    Address   3 Whole St, Wondertown WXY 2722
      Email   aldo.thoughful@etheral.con
      Phone   123 55 66 78
Secondary Phone 123 78 66 55
Nationality   Wonderland, Republic of Home and Mother Country
Security Clearance National Clearance 13.2 with a very, very, very,
              very, very, very, very, very, very, very, very, very,
              very, very, very long explanation

Some labels don't fit - of course in the \setlist[description] I could increase the necessary dimensions, but I'd rather not move the position of the label/text-separation. Instead I'd like the labels to wrap in the label area over multiple lines like this:

    Address   3 Whole St, Wondertown WXY 2722
      Email   aldo.thoughful@etheral.con
      Phone   123 55 66 78
  Secondary   123 78 66 55
      Phone
Nationality   Wonderland, Republic of Home and Mother Country
   Security   National Clearance 13.2 with a very, very, very,
  Clearance   very, very, very, very, very, very, very, very, very,
              very, very, very long explanation

Ideally the line breaks in the label would happen automatically on spaces. Is there a way to achieve this with enumitem or otherwise?

Note 1: I saw the stackexchange question "Force long text inside item to wrap", but I can't make it apply to my situation.

Note 2: I don't want to change the environment I use. tabular-like environments could certainly be a good fit, but the whole input texts are already set in description lists, so I want to keep it this way.

3

You can define a new style similar to multiline, but

  • you will have to setup a better labelwidth and
  • you will have to insert empty lines with \\~ if the description text is too short.

    \documentclass{article}
    \usepackage{enumitem,calc}
    
    \makeatletter 
    \def\enit@align@parright{%
      \def\enit@align##1{%
        \nobreak
        \strut\smash{\parbox[t]\labelwidth{\raggedleft##1}}}}
    
    \def\enit@style@multilineright{%
      \enit@align@parright
      \enit@calcset\labelindent\z@{0pt}%
      \enit@calcset\leftmargin\thr@@!}
    \makeatother    
    
    \setlist[description]{labelwidth=\widthof{\bfseries Nationality},
                          style=multilineright}
    
    \begin{document}
    \noindent xxxxxxx
    \begin{description}
    \item[Address]
    3 Whole St, Wondertown WXY 2722
    \item[Email]
    aldo.thoughful@etheral.con
    \item[Phone]
    123 55 66 78
    \item[Secondary Phone]
    123 78 66 55\\~
    \item[Nationality]
    Wonderland, Republic of Home and Mother Country
    \item[Security Clearance]
    National Clearance 13.2 with a very, very, very,
    very, very, very, very, very, very, very, very,
    very, very, very, very long explanation
    \end{description}
    
    \end{document}
    

enter image description here

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.