2

I want to get the current location of my text

my mwe follow as:

\documentclass{article}
\usepackage{tikz}
\makeatletter
\def\getx{\tikz[remember picture]\node{\the\pgf@x};}
\makeatother
\begin{document}
one \getx two

one \getx two \end{document}

but the result is all 0.0pt, what should I do?

ljguo
  • 1,213
  • 1
  • 4
  • 12

1 Answers1

1

You can modify your code to have the definition like this:

\makeatletter
\def\getx{\begin{tikzpicture}[overlay,remember picture]
\node at (current page.north west){};
\node at (current page.south east){};
    \node (A){\xdef\myx{\the\dimexpr\paperwidth-\pgf@x}};
    \end{tikzpicture}}
\makeatother

This way the coordinates will be absolute according to the page dimensions.

koleygr
  • 20,105