# What does the \the\everypar do?

If you test the following minimal it does not produce an error. What does it actually do?

\the\everypar
\bye


Why doesn't it produce an error as one would expect?

-
The default value of \everypar is empty. It's a token list internal register. –  egreg Nov 6 '11 at 15:22
@MarcoDaniel Since you were the fastest don't you want to put that as an answer? –  Yiannis Lazarides Nov 6 '11 at 15:29
@YiannisLazarides: I deleted my comment. The honor goes to 40k egreg ;-) –  Marco Daniel Nov 6 '11 at 15:45

\everypar is a token list register, so its value is assigned by

\everypar={<tokens>}


Its default value in Plain TeX is empty.

What's for? Its contents is delivered into the token list TeX is reading when it switches from vertical to horizontal mode. This happens when TeX, in vertical mode, sees a horizontal command, for instance a character to be typeset or \indent or \noindent.

At that time the horizontal command is set aside; before examining it again, TeX contributes \parskip glue to the vertical list and goes into horizontal mode; now it delivers the contents of \everypar as if \the\everypar was implicit and reexamines the horizontal command that forced the switch to horizontal mode. However the switching to horizontal mode caused by a horizontal command other than \noindent causes TeX to insert an empty box of width \parindent before the contents of \everypar.

One can use \everypar to perform automatically some job at paragraph start, for example to number them.

LaTeX exploits heavily this mechanism, so it's not recommended to play with it when the job involves lists. An example is the declaration

\everypar{\@nodocument}


that is in force until \begin{document} is processed; \@nodocument issues the error message Missing \begin{document} in order to warn the user that text starting a paragraph has been found in the preamble.

As all token registers, its value can be augmented by

\everypar=\expandafter{\the\everypar<tokens>}


since \the\everypar will deliver the current register's contents.

-
I want to add, there are other tokens like \everymath, \everycr, \everydisplay, \everyvbox, \everyhbox –  Marco Daniel Nov 6 '11 at 16:37
@egreg Great answer thanks. –  Yiannis Lazarides Nov 6 '11 at 19:06