3

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.

2
  • I cannot answer, but am interested in replies. Might make a difference if you use lualatex? Also might make a difference if the box does not contain anything that might flow to the next page.
    – rallg
    Jan 29 at 17:25
  • Possible resource: tex.stackexchange.com/questions/642642/…. (\predisplaysize can be abused to interesting effect, but if the boxes are nested then it's not useful.)
    – user202729
    Feb 2 at 9:02

0

You must log in to answer this question.

Browse other questions tagged .