7

I am considering a solution to the automatic grid typesetting problem though LuaTeX callbacks. The most relevant one seems to be append_to_vlist_filter. (vpack can also work, I support, but a less elegant solution)

However, it seems that it does work properly. The documents is quite vague on its return value.

function(<node> box, <string> locationcode, <number prevdepth>, <boolean> mirrored) 
    return list, prevdepth
end

It is ok to return nothing in which case you also need to flush the box or deal with it yourself. The prevdepth is also optional. Locations are box, alignment, equation, equation_number and post_linebreak

Below is a minimal example,

\documentclass{article}

\directlua{
  function apvlist(head)
    return head
  end
  luatexbase.add_to_callback("append_to_vlist_filter", apvlist, "apvlist")
}

\begin{document}
Test
\end{document}

I assumed that the return value list means the head of a node list. In the simple example, the original box is returned as the head of a single node list. Yet, when compiled there's no page output.

What does the document mean by flush the box or deal with it yourself?

  • ltj-direction.lua from the luatexja package has an example of the use of this callback. – Ulrike Fischer Mar 11 '17 at 17:19
4

I'd found the same example as Ulrike in luatexja, and so I think the identity function is something like

\documentclass{article}

\directlua{
  function apvlist(head,c,p,b)
    print('adding ' .. type(head) .. ' in context ' .. c)
    node.write(head)
    return nil
  end
  luatexbase.add_to_callback("append_to_vlist_filter", apvlist, "apvlist")
}

\begin{document}
Test
\end{document}

which typesets Test and echoes

adding userdata in context post_linebreak
adding userdata in context box
adding userdata in context box
adding userdata in context box
adding userdata in context box
adding userdata in context box

But the details are still a bit vague.

  • I tried this on a longer example (the MWE at this question), and unfortunately this doesn't appear to be the identity function exactly. Still a mystery… – ShreevatsaR Aug 13 '17 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.