Luatex manual mention save_pos (page 136) a subtype of whatsit node, Is there anyone who can give us a simple example of its use with lualatex.

  • 2
    it's the node from \savepos, which is the same as pdftex \pdfsavepos – David Carlisle Oct 21 at 20:06

save_pos is the whatsit that is inserted by \savepos (the LuaTeX name for \pdfsavepos.) Using it directly would be quite rare because you would normally just use \savepos in TeX code or, if you want to access the position though Lua, you just use pdf.getpos() with \latelua directly.

But you could use it to implement you own version on \pdfsavepos:

% plain TeX, but you can also add `\documentclass` etc. to make it LaTeX...

% Don't do this in regular code, just use `\savepos`.
  node.write(node.new("whatsit", "save_pos"))
% Write the coordinates of that point to the log file:
\write-1{The page starts at \the\lastxpos, \the\lastypos.}

The same example with pdf.getpos() and \latelua:

  texio.write_nl('log', ("The page starts at \csstring\%i, \csstring\%i."):format(pdf.getpos()))

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.