我想获取文本的当前位置
我的母亲如下:
\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}
但结果全是0.0pt,怎么办?
答案1
您可以修改代码以获得如下定义:
\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
这样,坐标将根据页面尺寸绝对确定。