Enclose the section in question within a group.
\documentclass{article}
\usepackage{ngerman, blindtext}
\begin{document}
\begingroup
\section{Section with different settings}
\setlength{\parindent}{0cm}\setlength{\parskip}{4ex plus 0.3ex minus 0.1ex}
\blindtext\par\blindtext
\endgroup
%Here I would want to undo the setlength command from above and go back to default
\section{Section back to default settings}
\blindtext\par\blindtext
\end{document}
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.
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.
Best Answer
LaTeX list environments use
\parshape
(for which\hangafter
is a shorthand essentially) so the behaviour there is likely to be different.But perhaps the first difference to bite is that LaTeX's mechanism to suppress paragraph indentation after section headings (and after mid-paragraph display environments) removes the parindent node but won't see hangafter.
Compare:
in the two cases.