Search code examples
latextextext-formatting

LaTeX - Description list - Split the item across multiple lines


I have the following LaTeX file. Notice how the item on the description is very long ...foo....

\documentclass{article}
\begin{document}
\begin{description}

\item[foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo]
bar

\item[baz]
bang

\end{description}
\end{document}

It produces a file like this:

The foo is all on one line and will run off the edge. Is there anyway to split the description part across multiple lines so it doesn't run off the edge of the page? I want to be able to do this only in the preamble, since I can't edit the actual body of the document.


Solution

  • Changing the description environment in the preamble, using mdwlist: \usepackage{mdwlist}

    \renewenvironment{description}%
    {
    \begin{basedescript}{
    \desclabelstyle{\nextlinelabel}
    \renewcommand{\makelabel}[1]{%
    \parbox[b]{\textwidth}{\bfseries##1}%
    }%
    \desclabelwidth{2em}}}
    {
    \end{basedescript}
    }