0

I have a description list with a label that does not a fit on one line. I want a line break in the label such that the second line of the label is not indented. I still want the body text to be indented. (To get the body text to start on a new line I use the hack ~\\—perhaps there is a better solution?)

\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}
\begin{document}
\begin{description}[style=unboxed]
    \item[
        This is a too long label.
        It would not be if I did not add this sentence.
        I do not want this line to be indented.
    ]~\\
    However, I want the body of the item to be, just as it is.
    \lipsum[1]
    \item[An item with a short label.]~\\
    This looks good.
    \lipsum[1]
\end{description}
\end{document}

enter image description here

1

This is not right - it produces overfull boxes. However, perhaps somebody else will find it a useful basis for a better solution.

\documentclass{article}
\usepackage{enumitem,calc}
\usepackage{lipsum}
\makeatletter
\SetLabelAlign{myparleft}{\parbox[t]\textwidth{#1\par\mbox{}}}
\makeatother
\begin{document}
\lipsum[1]
\begin{description}[align=myparleft]
    \item[%
        This is a too long label.
        It would not be if I did not add this sentence.
        I do not want this line to be indented.
    ]
    However, I want the body of the item to be, just as it is.
    \lipsum[1]
    \item[An item with a short label.]
    This looks good.
    \lipsum[1]
\end{description}
\end{document}

description

0

Building on cfr's answer, here are two solutions. However it requires manual setting the number of lines in the description.

\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}
\begin{document}
\begin{description}[style=unboxed]
    \item[\protect{%
        \parbox[t][2\baselineskip][t]{\textwidth}{%
            This is a too long label.
            It would not be if I did not add this sentence.
            I do not want this line to be indented.
        }
    }]
    Now this looks good,
    with the description wrapped in a parbox.
    \lipsum[75]
    \item[An item with a short label.]~\\
    This looks good.
    \lipsum[66]
    \item[\protect{%
        \begin{minipage}[t][2\baselineskip][t]{\textwidth}
            This is a too long label.
            It would not be if I did not add this sentence.
            I do not want this line to be indented.
        \end{minipage}
    }]
    And this looks good too,
    with the description wrapped in a minipage.
    \lipsum[75]
\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.