
給出以下程式碼:
\documentclass{article}
\begin{document}
\setbox0=\hbox{hello \fbox{other [.] text} world.}
\box0
\end{document}
我可以使用 zref-savepos 來確定框內點的位置:
\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}
但:
- 需要將盒子運出
- 它需要另一個編譯過程
問題:有沒有一種方法可以計算盒子中點的位置,而無需發貨?
我知道盒子有\wd
,\ht
和\dp
,但僅此而已。
動機:我希望能夠為 Asymptote 實現類似於 tikzmark 的東西(如何從 Asymptote 中的部分公式製作箭頭? (或:測量標籤的寬度,在標籤周圍定位))。為此,Asymptote 使用雙向管道來測量框架的寬度、高度和深度,但我也希望在框內自訂錨點。