Is there any command to get current position in text?
What do I mean:
\the\currentposition
text text text text \newline
\the\currentposition
text text text text \newline
\the\currentposition
Output:
0pt
text text text text
12pt
text text text text
24pt
Or even better – how to get actual (x,y) position of some text or enviroment (i.e. top left corner of column or block) in the list?
Best Answer
pdfTeX in PDF mode provide
\pdfsavepos
, which stores the current position that can be written to the.aux
file and used the next TeX run. Also XeTeX and LuaTeX provide this features. There are some limitations:Graphics state changes, that do not use the pdfTeX interfaces (
\pdfsetmatrix
,\pdfsave
,\pdfrestore
) interfere with the position recording.Absolute values are not well defined, thus relative values are preferred.
Package
zref-savepos
of projectzref
provides an interface to the positioning feature:Result after two compile runs: