tikz:我如何找到“当前页面.西北”的值?

tikz:我如何找到“当前页面.西北”的值?

current page.north west有没有办法以某种方式知道等的确切值tikzpicture

我用它current page.north west来放置下面的节点,但我也想知道它的实际坐标。我该如何在文本中打印出来?

\node [color=white,anchor=center] at ($(current page.north west)+(1.4,-1.765)$) {Text for my node};

如果我尝试下面的操作,它会输出一个文字当前页面.西北作为文本而不是值。

\node [color=white,anchor=center] at ($(current page.north west)+(1.4,-1.765)$) {current page.north west};

答案1

根据 tikz 文档 P.260:

https://ctan.mirror.globo.tech/graphics/pgf/base/doc/pgfmanual.pdf

current page中的预定义节点tikz。此节点可用于访问当前页面。它是一个矩形节点,其西南锚点是页面的左下角,其东北锚点是页面的右上角。您可以引用它,就好像它是在当前图片以外的某个记忆图片中定义的一样。因此,通过为图片提供remember pictureoverlay选项,您可以在页面上绝对定位节点。

为了说明这一点,我使用了以下代码来指出当前页面的某些位置。我使用命令提取这些位置的坐标。然后使用和\pgfgetlastxy{\marcox}{\marcoy}输入坐标。提取的坐标结果取决于您插入环境的位置。在此示例中,环境插入在“text before tikz”之后。因此将把字母后的输入框的左下角视为原点。在此原点位置提取的坐标将为 (0pt,0pt)。其余提取的坐标将根据此原点位置。如果节点位于原点左侧,则 x 坐标将为负数。如果节点位于原点下方,则 y 坐标将为负数。\marcox\marcoytikzpicturetikzpicturetexttikzz

\documentclass[12pt]{article}
\usepackage{tikz}

\begin{document}
\Large
text before tikz\begin{tikzpicture}[remember picture,overlay,shift=(current page.south west)]

\draw [line width=2pt,purple,->] (3,26) -- (current page.north west);\pgfgetlastxy{\NWx}{\NWy}
\node at (current page.north west) [anchor=north west] {node (current page.north west)};
\node at (3,26) [line width=2pt,shape=rectangle,draw=purple,anchor=north west] {\NWx,\NWy};

\draw [line width=2pt,red,->] (18,10) -- (current page.east);\pgfgetlastxy{\eastx}{\easty}
\node at (current page.east) [anchor=south east] {node (current page.east)};
\node at (18,10) [line width=2pt,shape=rectangle,draw=red,anchor=north east] {\eastx,\easty};

\draw [line width=2pt,blue,->] (3,10) -- (current page.west);\pgfgetlastxy{\westx}{\westy}
\node at (current page.west) [anchor=south west] {node (current page.west)};
\node at (3,10) [line width=2pt,shape=rectangle,draw=blue,anchor=north west] {\westx,\westy};

\draw [line width=2pt,green,->] (3,5) -- (current page.south west);\pgfgetlastxy{\SWx}{\SWy}
\node at (current page.south west) [anchor=south west] {node (current page.south west)};
\node at (3,5) [line width=2pt,shape=rectangle,draw=green,anchor=south west] {\SWx,\SWy};

\draw [line width=2pt,orange,<-] (235.30008pt,656.56944pt) -- (8,21);\pgfgetlastxy{\originx}{\originy}
\node at (8,21) [line width=2pt,shape=rectangle,draw=orange,anchor=north] {\originx,\originy};
\end{tikzpicture} text after tikz

\end{document}

输出的 PDF 比我在此处写的更好地说明了结果。

在此处输入图片描述

相关内容