Reliably trapping end of paragraph / return to vertical mode

David Carlisle d.p.carlisle at
Thu Oct 3 00:24:37 CEST 2019

On Wed, 2 Oct 2019 at 22:14, Taylor, P <P.Taylor at> wrote:

> David Carlisle wrote:
> basically Phil you are doomed (unless you are tempted to try luatex which
> has more possibilities)
> you mention paragraphs ending with \par, \endgraf, a blank line or \vskip.
> blank lines and vskip are Ok really as they cause the \par token to be
> inserted, so if you have hooked some code into \par that will run.
> \endgraf or other commands let to the primitive are Ok if you give
> yourself access to the format early enough that you know that no one has
> taken  control.
> But there are two cases that you really can't easily  trap.
> In classic tex you can end a paragraph by ending a vbox, that does not
> insert a \par token: it just directly ends the paragraph with no
> macro-layer hook at all.
> In pdftex (and xetex) a paragraph can be ended with \primitive\par which
> is again pretty tricky to catch without breaking other uses of \primitive.
> partial paragraphs ended with $$ also make things interesting.
> Many thanks for your comments/analysis, David — much appreciated.  It
> would seem that you and I have reached the same (sad) conclusions, but you
> remind me that I have another obscure query — how (if at all) can I achieve
> the *intended *effect of :
> \def \par {\relax}
> \def \tmp {\let \foo = }
> \expandafter \tmp \primitive \par
> \message {\meaning \foo}
> \end
> That is, how can I \let a control sequence to a TeX primitive if that
> primitive has already been clobbered (e.g., overwritten by a macro) ?
> ** Phil.
\primitive isn't as useful as it could have been....

the safest way is to grab the saved primitive while building the format,
admittedly  not everyone has write access to the format sources but still...

In plain tex  if you start a file \let\endgraf\relax \let\par\relax  then I
don't think it is possible (in xetex or pdftex) to generate a token with
the primitive meaning of \par, the nearest you could do is
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the texhax mailing list