TikZ3 での絶対位置指定

TikZ3 での絶対位置指定

解決策も提出しますので、この質問に費やす時間と労力を節約してください。

私の問題はこれです。TikZ2 を TikZ3 にアップグレードした後、絶対位置決めが機能しなくなるケースがあります。これは、ページの上部に四角形が表示されることを期待していたコードです (左の画像) が、異なるものが表示されました (右の画像)。TikZ3 でこれを修正するにはどうすればよいですか?

%! pdflatex or xelatex or lualatex
%! bug0002-problem.tex
%! running it twice
\documentclass[a4paper]{article}
\pagestyle{empty}
\addtolength{\hoffset}{-1in}
\addtolength{\voffset}{-1in}
\usepackage{tikz} % version 3
\begin{document}
\begin{tikzpicture}[remember picture, overlay]
\node[minimum width=4cm, minimum height=4cm, draw, fill=orange, anchor=north] at (current page.north) {Hello World!};
\end{tikzpicture}
\end{document}

例1

答え1

TikZ3 のすべての新機能を見たときにどれほど嬉しかったか、そして (私にとって) 重要な機能が時々正常に動作しなくなったときにどれほど残念だったかを明確に表現する必要はないと思います。

私の最初の解決策は、コード自体から明らかです。\addtolength{\hoffset}{-1in}と をコメントアウトします\addtolength{\voffset}{-1in}。実際のプロジェクトでそれを追跡するのはそれほど簡単ではなく、ページミラーがずっと前に設定されたときには、このような解決策を使用することはできませんでした。これがコードです。

%! pdflatex or xelatex or lualatex
%! bug0002-solution-a.tex
%! running it twice
% This solution works in xelatex!
\documentclass[a4paper]{article}
\pagestyle{empty}
%\addtolength{\hoffset}{-1in}
%\addtolength{\voffset}{-1in}
\usepackage{tikz} % version 3
\begin{document}
\begin{tikzpicture}[remember picture, overlay]
\node[minimum width=4cm, minimum height=4cm, draw, fill=orange, anchor=north] at (current page.north) {Hello World!};
\end{tikzpicture}
\end{document}

別の解決策が必要でしたが、1つ見つけました。\hoffsetと の\voffset寸法を初期値に戻しましょう。ただし、TikZ3 は明らかに計算にそれらを使用しているため、すべての環境でのみ行います。のスタイルをtikzpicture使用して変更した次の例を試してみてください。\tikzsetevery picture

%! pdflatex or xelatex or lualatex
%! bug0002-solution-b.tex
%! running it twice
% This solution does not work in xelatex!
\documentclass[a4paper]{article}
\pagestyle{empty}
\addtolength{\hoffset}{-1in}
\addtolength{\voffset}{-1in}
\usepackage{tikz} % version 3
\begin{document}
\tikzset{every picture/.style={execute at begin picture={
   \hoffset=0pt
   \voffset=0pt
   }}} 
\begin{tikzpicture}[remember picture, overlay]
\node[minimum width=4cm, minimum height=4cm, draw, fill=orange, anchor=north] at (current page.north) {Hello World!};
\end{tikzpicture}
\end{document}

xelatexこのソリューションは では機能しませんが、 と では機能するため、他にもpdflatex何かが起こっていると思いますlualatex。 の予想される出力 (左の図) と実際の出力 (右の図) を簡単に比較できますxelatex。残念ながら、私の回答はサブ質問を開いてしまいます。TikZ3 でこれを修正するにはどうすればよいですか?

例2

関連情報