1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TikZ 内からの \zsavepos

Last updated at Posted at 2017-11-08

TikZ の \node 内で \zsavepos を行った場合,

  • pdfTeX, LuaTeX : \node の出力位置を正しく取得できる。
  • XeTeX, pLaTeX+dvipdfmx : \node の出力位置を正しく取得できない。(常にtikzpictureの原点座標になる模様)

これは PGF のドライバファイルに起因する問題?

検証

TeX Live 2017 の最新版で検証。
各々2回コンパイルするものとします。

pdfLaTeX

ソース

\documentclass[pdftex]{article}
\usepackage{tikz}
\usepackage{zref-savepos}
\begin{document}
\begin{tikzpicture}
\node[draw,circle] at (0,0) {\zsavepos{A}};
\node[draw,circle] at (1,1) {\zsavepos{B}};
\node[draw,circle] at (3,3) {\zsavepos{C}};
\end{tikzpicture}

\typeout{(\zposx{A},\zposy{A})}
\typeout{(\zposx{B},\zposy{B})}
\typeout{(\zposx{C},\zposy{C})}

\typeout{(\the\numexpr\zposx{B}-\zposx{A}\relax,\the\numexpr\zposy{B}-\zposy{A}\relax)}%% A→B
\typeout{(\the\numexpr\zposx{C}-\zposx{B}\relax,\the\numexpr\zposy{C}-\zposy{B}\relax)}%% B→C
%%%% ⇒ 後者は前者の2倍のベクトルのはず

\end{document}

出力結果(OK)

(10104593,37973387)
(11969272,39838066)
(15698630,43567424)
(1864679,1864679)
(3729358,3729358)

LuaLaTeX

ソース

\documentclass[luatex]{article}
(以下同じ)

出力結果(OK)

(10104593,37973387)
(11969272,39838066)
(15698630,43567424)
(1864679,1864679)
(3729358,3729358)

XeLaTeX

ソース

\documentclass[xetex]{article}
(以下同じ)

出力結果(NG)

(10104593,37973387)
(10104593,37973387)
(10104593,37973387)
(0,0)
(0,0)

pLaTeX + dvipdfmx

ソース

\documentclass[dvipdfmx]{article}
(以下同じ)

出力結果(NG)

(10104593,36831094)
(10104593,36831094)
(10104593,36831094)
(0,0)
(0,0)
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?