Posicionamiento absoluto en TikZ3

Posicionamiento absoluto en TikZ3

También estoy enviando la solución. Por favor, ahorre tiempo y energía en esta pregunta.

Mi problema es este. El posicionamiento absoluto dejó de funcionar en algunos casos después de actualizar TikZ2 a TikZ3. Este es el código donde esperaba un cuadrado en la parte superior de la página (imagen de la izquierda), pero tengo algo diferente (imagen de la derecha). ¿Cómo podemos solucionarlo en 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}

Ejemplo 1

Respuesta1

Creo que no es necesario expresar explícitamente lo feliz que me sentí cuando vi todas las funciones nuevas en TikZ3 y lo infeliz que me sentí cuando la característica clave (para mí) dejó de funcionar correctamente de vez en cuando.

Mi primera solución es obvia por el código mismo: comentar \addtolength{\hoffset}{-1in}y \addtolength{\voffset}{-1in}. No fue tan sencillo rastrearlo en un proyecto real y no me fue posible usar dicha solución cuando la página reflejada se configuró hace mucho tiempo. Este es el código.

%! 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}

Necesitaba otra solución y encontré una: regresemos las dimensiones \hoffsety \voffseta sus valores iniciales, pero solo en todos los tikzpictureentornos, ya que TikZ3 claramente las usa para los cálculos. Pruebe este ejemplo donde utilicé \tikzsety modifiqué el estilo de every 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}

Creo que están sucediendo más cosas ya que esta solución no funciona en xelatex, pero sí en pdflatexy lualatex. Podemos comparar fácilmente el resultado esperado (imagen de la izquierda) y el resultado real xelatex(imagen de la derecha). Me temo que mi respuesta abre una subpregunta. ¿Cómo se puede arreglar eso en TikZ3?

ejemplo 2

información relacionada