[Tex/LaTex] Using \hangindent within enumerate

#enumerateindentationlistsparagraphs

I would like to have a hanging indent within the paragraph of an enumerate item. I have the following:

\begin{document}
\begin{enumerate}
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus id diam id ante ullamcorper vestibulum eu non nisl. Curabitur interdum laoreet massa, eu eleifend risus placerat nec. Suspendisse potenti.

    Mauris nunc risus, congue id sollicitudin id, sagittis quis elit. Proin blandit, orci vitae vehicula faucibus, est leo facilisis ante, quis venenatis mi dolor ut tellus.
    \item Integer aliquam mollis lacus, in fermentum tellus pharetra eget. Donec suscipit condimentum tincidunt. Mauris odio felis, ultricies non lobortis non, suscipit in magna.

    Nam venenatis dolor turpis. Mauris fermentum, est ac dapibus accumsan, lorem orci vulputate nunc, quis laoreet augue elit pulvinar dui. Curabitur eu enim quis dolor interdum vehicula eget vitae ipsum.
\end{enumerate}
\end{document}

This outputs:

I would like for it to output:

However, \hangindent does not seem to work within the \item of an enumerate environment because \item uses \parshape, which overrides \hangindent.

How can I achieve this?

Best Answer

Your diagnosis is correct: \parshape, which is issued by \item, overrides any \hangindent setting. You can use the enumitem package; adjust 1em to what you prefer.

\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}

\begin{document}

\lipsum*[2]
\begin{enumerate}[
  leftmargin=\dimexpr\leftmargini+1em\relax,
  labelindent=-1em,
  listparindent=-1em,
  itemindent=-1em
]
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus id diam id 
ante ullamcorper vestibulum eu non nisl. Curabitur interdum laoreet massa, eu eleifend 
risus placerat nec. Suspendisse potenti.

Mauris nunc risus, congue id sollicitudin id, sagittis quis elit. Proin blandit, orci 
vitae vehicula faucibus, est leo facilisis ante, quis venenatis mi dolor ut tellus.

\item Integer aliquam mollis lacus, in fermentum tellus pharetra eget. Donec suscipit 
condimentum tincidunt. Mauris odio felis, ultricies non lobortis non, suscipit in magna.

Nam venenatis dolor turpis. Mauris fermentum, est ac dapibus accumsan, lorem orci 
vulputate nunc, quis laoreet augue elit pulvinar dui. Curabitur eu enim quis dolor 
interdum vehicula eget vitae ipsum.
\end{enumerate}

\begin{enumerate}
\item Test
\end{enumerate}

\end{document}

I added another enumerate environment in order to show that the label placement is the same and a \lipsum paragraph for showing the global aspect.

enter image description here

If you need it in nested lists, I suggest to define a new environment:

\makeatletter
\newenvironment{enumeratehang}
  {\enumerate[
    leftmargin=\dimexpr\csname leftmargin\romannumeral\@enumdepth\endcsname+1em\relax,
    labelindent=-1em,
    listparindent=-1em,
    itemindent=-1em
   ]}
  {\endenumerate}
\makeatother

This will allow you to use \begin{enumeratehang} and will work also nested with other enumeratehang (or also enumerate) environments.

For nested environments, we have to use the correct left margin; the counter \@enumdepth stores the nesting level, so \romannumeral\@enumdepth will produce i, ii, iii, and so on; thus the \csname construction will give \leftmargini, \leftmarginii and so on, which are the length parameters where LaTeX stores the left margin at the various nesting levels. To those we add 1em, consistent with the simple example given at the beginning.

Related Question