Re: Plain TeX: Aligning to an earlier centered line's ends

Norman Gray <[email protected]> Wed, 07 Jan 2026 14:31:58 +0000
Newsgroups gmane.comp.tex.texhax
Message-ID <[email protected]>
Suresh, hello.

On 7 Jan 2026, at 14:17, Suresh Govindachar via texhax wrote:

> How exactly to achieve this (create a hbox to the size of the centered line, center this hbox, insert the text inside this hbox with hss on the right for left-alignment and hss on the left for right alignment)?

What you say sounds plausible, but I imagine it could be made to work, especially if it can build on features in the ‘real’ use-case.

An alternative approach, which may be more straightforward, is to use \pdfsavepos, which stores the current position on the page, when it is invoked, and lets it be retrieved (\pdflastxpos and \pdflastypos) later.  That may go to the heart of your application by a direct route.

The primitive is described in a TUGboat article at [1], and there's another example of its use in my 'versonotes' package [2], which looks like it does something broadly similar to what you're aiming for here.

The primitive is mentioned as being part of pdfTeX, but I see [3] that it's a required part of any TeX engine that can support l3kernel, so it's presumably quite widespread now.

Have fun.  Best wishes,

Norman


[1] https://www.tug.org/TUGboat/tb30-1/tb94zyka.pdf
[2] https://www.ctan.org/tex-archive/macros/latex/contrib/versonotes
[3] https://ctan.org/tex-archive/macros/latex/required/l3kernel

-- 
Norman Gray  :  https://nxg.me.uk