Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
5  
+1 for not using @@@@ lipsum as your filler text. –  David Carlisle May 2 '12 at 9:25
add comment

2 Answers

up vote 12 down vote accepted

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.

share|improve this answer
add comment

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}

enter image description here

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.