Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to customize enumitem so that labels and item-contents will be broken into paragraphs with negative (hanging) indent when they get too long for the designated space:

     label one                               content one                    |
     label two                               content two content two content|
                                                     two content two content|
                                                     two content two content|
                                                     two                    |
     label three label three label                                          |
           three label three label                                          |
           three                             content three                  |
     label four                              content four                   |

The following works for the "content"-part, but the labels aren't indented and the following label prints on top of the preceding line's.

The latter can be solved manually by adding \\ after "content three", but as I want to use this in a partly automated workflow, I'd appreciate a solution that doesn't require manual finishing.

Is there a way to achieve this with enumitem at all and if not, how could it be done otherwise?

\documentclass{article}


\usepackage[showframe]{geometry}
\usepackage{calc,enumitem}

\newlist{pardesc}{description}{1}
\setlist[pardesc]{%
nosep,
labelindent=2cm,
labelsep*=1cm,
labelwidth=.5\textwidth-1.5cm, %i.e. same with for both
leftmargin=\labelwidth+5cm, 
style=standard,
align=parleft,
}


\begin{document}

\begin{pardesc}
\item[label one] content one
\item[label two] content two content two content two content two content two content two content two 
\item[label three label three label three label three label three] content three
\item[label four] content four
\end{pardesc}

\end{document}  

Edit:

There will frequently be footnotes and pagebreaks in these list, so using tabular instead isn't a feasible solution.

share|improve this question

3 Answers 3

up vote 4 down vote accepted
+100

In the file enumitem.sty one def goes like this:

\def\enit@align@parleft{%
    \def\enit@align##1{%
         \nobreak
         \strut\smash{\parbox[t]\labelwidth{\raggedright##1}}}}

In your preamble you can try removing the \smash and put the \strut inside the \parbox. The \hangindent may satisfy your requirements, but you may want some variable length. Change the \parbox alignment to [b].

\makeatletter
\def\enit@align@parleft{%
    \def\enit@align##1{%
         \nobreak
         {\parbox[b]\labelwidth{\hangindent2.5em\raggedright##1\strut}}}}
\makeatother

I don't know if this interferes with any other features, it's only been tested on your example.

share|improve this answer

You can use a tabular and define new columns to simplify your job.

\newcolumntype{D}[1]{>{\bfseries\raggedright\hangindent1.5em\arraybackslash}p{#1}}
\newcolumntype{E}[1]{>{\raggedright\hangindent1.5em\arraybackslash}p{#1}}

Full code:

\documentclass{article}
\usepackage{array}
\newcolumntype{D}[1]{>{\bfseries\raggedright\hangindent1.5em\arraybackslash}p{#1}}
\newcolumntype{E}[1]{>{\raggedright\hangindent1.5em\arraybackslash}p{#1}}
\usepackage[showframe]{geometry}

\begin{document}
\noindent
\begin{tabular}{@{}D{.47\textwidth}E{.5\textwidth}@{}}
label one & content one \\
label two  &  content two content two content two content two content two content two content two  content two content two content two content two content two content two content two \\
label three label three label three label three label three & content three \\
label four & content four
\end{tabular}

\end{document}

enter image description here

share|improve this answer
    
Thanks for that, but tabular will not be feasible as there will be frequent pagebreaks and footnotes in these lists. –  Florian Nov 19 '13 at 11:18
1  
@Florian: use longtabu then (or equivalent) it provides the benefits of tabular while not suffering from footnotes or pagebreaks. –  Federico Nov 21 '13 at 7:32
    
@HarishKumar you meant "the latter"? b.t.w. I know that it is not supported but I still find it better for its support of X columns. Feel free to improve on my answer, anyway, if you have a better version. –  Federico Nov 25 '13 at 13:30
    
@Federico Oh sorry It should be: Better to use longtable than longtabu as the latter is not supported any more. :-) I will delete that comment before David sees it :-) –  Harish Kumar Nov 25 '13 at 13:32

With longtabu and a variation on Harish's answer, you obtain:

EDIT: edited to show compatibility with \pagebreak

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{array}
\usepackage{tabu, longtable}
\newcolumntype{D}[1]{>{\bfseries\raggedright\hangindent1.5em\arraybackslash}p{#1}}
\newcolumntype{E}[1]{>{\raggedright\hangindent1.5em\arraybackslash}p{#1}}
\tabulinesep=^1.5mm_1.5mm

\begin{document}

\noindent
{\centering
\begin{longtabu} to \linewidth {@{}D{.47\textwidth}  E{.5\textwidth}@{}}
\endhead
\endfoot
\endlastfoot

label one & content one \\ 
label two  &  content two content two content two content two content two content two content two  content two content two content two content two content two content two content two \\
label three label three label three label three label three & content three \\
label four & content four\footnotemark  \\ 
label one & content one \\ 
label two  &  content two content two content two content two content two content two content two  content two content two content two content two content two content two content two \\
label three label three label three label three label three & content three \\
label four & content four  \\ 
label one & content one \\ 
label two  &  content two content two content two content two content two content two content two  content two content two content two content two content two content two content two \\
label three label three label three label three label three & content three \\
label four & content four \\ 
label one & content one \\ 
label two  &  content two content two content two content two content two content two content two  content two content two content two content two content two content two content two \\
label three label three label three label three label three & content three \\
label four & content four  \\ 
label one & content one\footnotemark \\ 
label two  &  content two content two content two content two content two content two content two  content two content two content two content two content two content two content two \\
label three label three label three label three label three & content three \\
label four & content four  \\ 
label one & content one \\ 
label two  &  content two content two content two content two content two content two content two  content two content two content two content two content two content two content two \\
label three label three label three label three label three & content three \\
label four & content four  \\ 
label one & content one \\ 
\pagebreak
label two  &  content two content two content two content two content two content two content two  content two content two content two content two content two content two content two \\
label three label three label three label three label three & content three \\
label four & content four  \\ 
\end{longtabu}

\footnotetext[1]{text one}
\footnotetext[2]{text two}

\end{document}

That is a 3-page table with footnotes and a \pagebreak

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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