pre everydisplay hook feature request
Hi luatex developers, I want to ask your opinion about new hook (token list) "\everypredisplay". This should work just before $$ (display start) while math group is not started. There is \everydisplay but it works immediately after math mode start. Why one would need it? Now there is now how to control spaces between to equations. Lets say journal requires spaces around displays (and in display inner lines) and text 6pt. I can do with tex macros by hooking into every latex display environment and putting some code right before $$. In that code I add \par; then I do manipulations of \abovedisplayskip by checking \lastskip; and controling \panalty by looking at \prevgraf. Finaly I add \noindent to remove empty boxes. Everything is perfect while I do not get plain display makros $$ a+b $$. Manualy to retype them is not an option. So the hook of \everypredisplay where \par could work would be very useful. What do you think? I'm using luatex 1.09.2.
On 2/4/2019 3:22 PM, Linas Stonys wrote:
Hi luatex developers, I want to ask your opinion about new hook (token list) "\everypredisplay". This should work just before $$ (display start) while math group is not started. There is \everydisplay but it works immediately after math mode start. Why one would need it? Now there is now how to control spaces between to equations. Lets say journal requires spaces around displays (and in display inner lines) and text 6pt.
I can do with tex macros by hooking into every latex display environment and putting some code right before $$. In that code I add \par; then I do manipulations of \abovedisplayskip by checking \lastskip; and controling \panalty by looking at \prevgraf. Finaly I add \noindent to remove empty boxes.
Everything is perfect while I do not get plain display makros $$ a+b $$. Manualy to retype them is not an option. So the hook of \everypredisplay where \par could work would be very useful.
What do you think? you can use the builder callbacks to implement a before_display handler so there is no need to add something (like expanding a token list)
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
you can use the builder callbacks to implement a before_display handler so there is no need to add something (like expanding a token list)
Amazing things can by done within lua node processing. I could find these places and remove the empty lines and edit the skips. But lua processing will cost more time than primitives. And it will be easy to trace the tex side. "before_display" seems to be hooked some where at \everydisplay place because the lastskip is already gone. Check the example: \documentclass{article} \directlua{ local function fix_display_glue(extrainfo) if extrainfo == "before_display" then print ("lastskip", tex.lastskip.width) end end luatexbase.add_to_callback('buildpage_filter', fix_display_glue, 'fix display glue') } \begin{document} \showthe\lastskip \directlua{print ("lastskip", tex.lastskip.width)} $$ equation+\$ $$ \showthe\lastskip \directlua{print ("lastskip", tex.lastskip.width)} $$ equation+\$ $$ \end{document} output is:
0.0pt. lastskip 0 lastskip 0 ..... ..... 6.0pt plus 3.0pt minus 3.0pt. lastskip 393216 lastskip 0
On 2/5/2019 10:04 AM, Linas Stonys wrote:
you can use the builder callbacks to implement a before_display handler so there is no need to add something (like expanding a token list)
Amazing things can by done within lua node processing. I could find these places and remove the empty lines and edit the skips. But lua processing will cost more time than primitives. And it will be easy to trace the tex side.
adding extra token registers related primitives that then need to be checked and add code (and cache misses) also costs ... the hook you mention is just one of dozens that can be added because some package needs them (i can think of some for context) ... basically you then end up with a token list expanded before and after each callback point because your case is just one of the many it's what we explcititly didn't want to do: add more and more such things (esp because they don't solve timing issues) things like tracing ... if your callback just print back to tex something \the\myfoo and then you're still at the tex end the overhead of a callback that justs checks if it's at display start and only then do something is not that large (after all, after that some other work is done which also costs); i'm pretty sure that worse bottlenecks can be found; also, flexibility comes at a price
"before_display" seems to be hooked some where at \everydisplay place because the lastskip is already gone. Check the example:
vertical spacing is tricky anyway so you can probably best run over the list-so-far then and remove stuff if needed Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Linas Stonys