Given the following code:
\documentclass{article}
\begin{document}
\setbox0=\hbox{hello \fbox{other [.] text} world.}
\box0
\end{document}
I can use zref-savepos to determine the location of the dot inside the box:
\documentclass{article}
\usepackage{zref-savepos}
\begin{document}
\setbox0=\hbox{\zsavepos{leftmostpoint}hello \fbox{other [.\zsavepos{dotpoint}] text} world.}
\box0
\the\dimexpr\zposx{dotpoint}sp-\zposx{leftmostpoint}sp\relax
\end{document}
But:
- It requires the box to be shipped out
- It needs another compilation pass
Question: is there a way to compute the location of the dot in the box, without shipout?
I know that there is \wd, \ht and \dp for boxes, but nothing more.
Motivation: I want to be able to implement something similar to tikzmark for Asymptote (How can I make arrow from parts of a formula in Asymptote? (or: measure the width of a label, get anchor around a label)). For that, Asymptote uses a bidirectional pipe to measure the width, height and depth of the boxes, but I also want custom anchor inside the box.
\predisplaysizecan be abused to interesting effect, but if the boxes are nested then it's not useful.) – user202729 Feb 02 '24 at 09:02