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.

I think the answer to this question should be positive but I just couldn't find it answered elsewhere: Are multiple consecutive \par's the same as a single \par? For example, is \par\par the same as just \par?

More generally, since an empty line is equivalent to a \par: Is any finite sequence of consecutive \par's and empty lines (or any mixture of them) equivalent to a single \par (or a single empty line)?

I know this question might seem trivial, but I do want to know it for defining macros. Any help appreciated!

share|improve this question
add comment

2 Answers 2

up vote 13 down vote accepted

After \par, TeX is in vertical mode. Then page 283 of the TeXbook, second bullet, explains that

The primitive \par command has no effect when TeX is in vertical mode, except that the page builder is exercised in case something is present on the contribution list, and the paragraph shape parameters are cleared.

“Exercising the page builder” is explained on page 281:

TeX periodically takes material that has been put on the main vertical list and moves it from the “contribution list” to the “current page.” At such times the output routine might be invoked. We shall say that TeX exercises the page builder whenever it tries to empty the current contribution list. The concept of contribution list exists only in the outermost vertical mode, so nothing happens when TeX exercises the page builder in internal vertical mode.

The paragraph shape parameters are any value given to \parshape, \hangindent or \hangafter.

So no, you don't have to worry much about having consecutive \par tokens unless you have redefined \par. Two consecutive blank lines count for two \par tokens, as the following Plain TeX example shows:

\def\par{X\endgraf}
a


b
\bye

that produces

enter image description here

share|improve this answer
5  
since latex does redefine \par, there are some (unusual) situations in which there is a difference. one such is in the verbatim environment, where two blank lines (= two \pars) appear in the output as two blank lines, not one. –  barbara beeton May 20 at 14:26
    
Thank you for the answer. Then to summarize, can I say that, as long as I didn't redefine \par, any finite sequence of consecutive \par's and empty lines (or any mixture thereof) is equivalent to a single \par (or a single empty line) (with only unusual exceptions such as in the \verbatim environment as suggested by @barbarabeeton )? –  Fang Jing May 20 at 14:35
2  
@FangJing Yes, unless you're doing strange things in the output routine. In LaTeX's verbatim \par is essentially \leavevmode\endgraf (where \endgraf is a duplicate of the primitive \par). –  egreg May 20 at 14:37
add comment

The quoted text (in egreg's answer) is about the tex primitive, but a blank line really is a \par token which can be redefined at any time (and is quite often redefined in latex). So whether consecutive \par are equivalent to one depends on the definition. At the start of any list (or list defined environment such as center) for example you can have 1 or 2 or 1000 \par but don't push your luck further than that:

\documentclass{article}

\begin{document}

\def\cpar{\par\par\par\par\par\par\par\par\par\par
\par\par\par\par\par\par\par\par\par\par
\par\par\par\par\par\par\par\par\par\par
\par\par\par\par\par\par\par\par\par\par
\par\par\par\par\par\par\par\par\par\par
\par\par\par\par\par\par\par\par\par\par
\par\par\par\par\par\par\par\par\par\par
\par\par\par\par\par\par\par\par\par\par
\par\par\par\par\par\par\par\par\par\par
\par\par\par\par\par\par\par\par\par\par}

\begin{center}
\par
\end{center}

\begin{center}
\cpar\cpar\cpar\cpar\cpar\cpar\cpar\cpar\cpar\cpar
\end{center}

\begin{center}
\cpar\cpar\cpar\cpar\cpar\cpar\cpar\cpar\cpar\cpar
\par% straw camel back....
\end{center}


\end{document}
share|improve this answer
    
This is cheating! –  egreg May 20 at 15:15
    
@egreg I may possibly have looked at the code first to find a nice example. –  David Carlisle May 20 at 15:18
3  
That's cheating twice! –  egreg May 20 at 15:21
    
@egreg no that's a receipt for great examples –  Frank Mittelbach May 21 at 8:33
    
maybe you should update your answer as "the quoted text" is where? In egreg's answer I presume but that is not so clear .. –  Frank Mittelbach May 21 at 8:35
show 1 more 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.