简单回答一下
- pgf/TiKZ 中有两个尺寸寄存器
\pgf@x
\pgf@y
分别用于保存当前的坐标,(类似你的\pgfgetlastxy
)但是“很遗憾”,他们的单位都是 pt,如:
\makeatletter
\begin{tikzpicture}
\path (1,1);
\node[above right] at (1,1) {(\the\pgf@x,\the\pgf@y)};
\end{tikzpicture}
\makeatother
得到
为此你需要将其转化为 cm, 可以定义一个命令
\def\pttocm#1{\pgfmathparse{#1/28.45274}\pgfmathresult}
将 pt 转化为 cm
一个完整的 mwe:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\def\pttocm#1{\pgfmathparse{#1/28.45274}\pgfmathresult}
\makeatletter
\begin{tikzpicture}
\path (1,1);
\node[above right] at (1,1) {(\pttocm{\the\pgf@x},\pttocm{\the\pgf@y})};
\end{tikzpicture}
\makeatother
\end{document}
- 此外,你的提问习惯不太好,希望你提问能够好好理解 mwe 一词,不然一大堆代码,没那么多人愿意帮你分析(个人观点)
问 例子中,如何显示出R点的坐标值是(2,2)?