# Difference between setting parindent and hangindent

Is there a difference between setting

• \parindent to 1em

and to setting

• \parindent to 0em, \hangindent to 1em, and \hangafter to -1

that shows in practical use? The nodes created by TeX are different, but does that show in typesetting at one point? One difference that I see is that the hang* settings are paragraph-local, but I don't care about that because I create every paragraph using LuaTeX's tex.linebreak()

This question is specific about LuaTeX, but I guess the answer applies to all engines.

Sample code:

\documentclass{article}
\begin{document}
\linewidth 300pt

\newcommand\text{A wonderful serenity has taken possession of my entire soul, like
these sweet mornings of spring which I enjoy with my whole heart. I am
alone, and feel the charm of existence in this spot, which was created
for the bliss of souls like mine. I am so happy, my dear friend, so
absorbed in the exquisite sense of mere tranquil existence, that I
neglect my talents.}

\text

\hangindent=\parindent
\parindent 0pt
\hangafter=-1
\text

\end{document}

• +1 for not using @@@@ lipsum as your filler text. – David Carlisle May 2 '12 at 9:25

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:

\section{aaa}

\text


in the two cases.

The most important difference is that TeX remembers \parindent, but it resets \hangindent and \hangafter at the end of the paragraph.

\documentclass{article}

\begin{document}
\linewidth 100pt

\newcommand\texta{A wonderful serenity has taken possession of my entire soul, like
these sweet mornings of spring which I enjoy with my whole heart. I am
alone, and feel the charm of existence in this spot, which was created
for the bliss of souls like mine.}

\newcommand\textb{I am so happy, my dear friend, so
absorbed in the exquisite sense of mere tranquil existence, that I
neglect my talents.}

\texta

\textb

\hangindent=\parindent
\parindent 0pt
\hangafter=-1
\texta

\textb

\end{document}


The second \textb has no indentation. If you also leave a blank line after \hangafter=-1, you'll see that the second \texta is not indented, because of the resetting. Indeed a \par in vertical mode does almost nothing: what it does is resetting the paragraph shape parameters (\hangindent, \hangafter, \parshape, \looseness).

The behavior is identical in TeX, pdfTeX, XeTeX and LuaTeX.