[texhax] Displaying the \current value of \prevgraf in the log file

Paul Isambert zappathustra at free.fr
Mon Nov 14 09:14:46 CET 2011

Le 13/11/2011 20:01, Philip TAYLOR a écrit :
> Paul Isambert wrote:
>> I don't know about \vadjust injection, but \showlists doesn mention
>> prevgraf. For instance "abc\par\showlists\bye" produces:
>> ### vertical mode entered at line 0
>> ### current page:
>> ... blah blah ...
>> total height 10.0
>> goal height 643.20255
>> prevdepth 0.0, prevgraf 1 line
> Oh ... I tried something similar, and saw
> prevdepth but no prevgraf -- let me try
> your example and see how it differs ...
> Yes, you're quite right : \showlists after
> a non-empty paragraph and a \par does indeed
> show the current value of \prevgraf.  Unfortunately
> it doesn't help me to find the value at a \vadjust !

Where in the \vadjust?

abc\par abc\vadjust{\showlists}\bye            % No prevgraf
abc\par abc\vadjust{abc\showlists}\bye       % No prevgraf
abc\par abc\vadjust{abc\par\showlists}\bye % Prevgraf, but of course, of 
the first paragraph in the \vadjust

But I suppose you're interested in the the first line?
Apparently, \showlists displays prevgraf when non-zero, i.e. only in 
vmode after a paragraph (which is also how I understand the code from 

So, at the beginning of a \vadjust (i.e. before a paragraph), even if 
you retrieved \prevgraf, it would be 0, as it is in horizontal mode or 
in vertical mode in an empty list. Your problem is thus rather to make 
\prevgraf survive a little bit longer; apart from hacking \par to 
something like \def\par{\endgraf\mycount=\prevgraf}, I can't see a 
solution. Unless you're willing to go LuaTeX, in which case the \par 
hack can be made a little bit more elegant (and less dangerous) with:

function (h)
   tex.count.mycount = tex.nest[tex.nest.ptr].prevgraf
   return h


More information about the texhax mailing list