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}

다른 솔루션이 필요했고 하나를 찾았습니다. \hoffset및 치수를 초기 값으로 반환하겠습니다. 하지만 TikZ3가 계산에 명확하게 사용하고 있으므로 \voffset모든 환경에서만 가능합니다 . 다음의 스타일을 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에서는 작동하므로 더 많은 일이 진행되고 있다고 생각합니다 . 예상 결과(왼쪽 그림)와 실제 출력 (오른쪽 그림)을 쉽게 비교할 수 있습니다. 내 대답은 하위 질문을 여는 것입니다. TikZ3에서 이 문제를 어떻게 해결할 수 있나요?pdflatexlualatexxelatex

예시 2

관련 정보