I am using TeX Live 2023 downloaded from the site on WSL2 Ubuntu 22.04. Using XeTeX to generate PDF documents.
xetex -v is XeTeX 3.141592653-2.6-0.999995 (TeX Live 2023).
As part of planning to work on custom page size, utilize full paper width and intension to use TikZ package, I started with simple LaTeX document. Contrary to documented behavior of anchor (origin) for "tikzpicture" being south-west (bottom left), I am getting a different behavior. I have provided 4 .tex files I tried on my system, all with minor differences.
In each of the following, I am trying to print two rectangular boxes with some text below it within tikzpicture environment. I would like to use full page hence margin is set to 0 and one of the box is expected to start at position (0,0) ie. from the edges of a paper. I am also using \begin{scope} ... \end{scope} to use relative coordinates within the tikzpicture environment.
For each file, I run xetex command thrice to ensure that "remember picture" and "overlay" works as expected.
- (1)
tikz-default-notworking.tex: This file contains +ve Y coordinate. Output is not as expected, 1st box is partially visible and 2nd box is not visible at all.
\documentclass{article}
\usepackage{tikz}
\usepackage[margin=0mm, paperwidth=210mm, paperheight=297mm]{geometry} % Adjust size as needed
\pagestyle{empty} % Removes page numbers and headers
\begin{document}
\begin{tikzpicture}[remember picture, overlay]
\begin{scope}[shift={(0cm, 0cm)}] % Positioned partway down the page
% Draw a rectangle
\draw (0,0) rectangle ++(4cm,1cm); % Moves downward within the scope
% Place text below the rectangle
\node at (2cm, 1.5cm) {Below First rectangle}; % Further down (more negative Y)
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay]
\begin{scope}[shift={(5cm, 5cm)}] % Positioned partway down the page
% Draw a rectangle
\draw (0,0) rectangle ++(4cm,2cm); % Moves downward within the scope
% Place text below the rectangle
\node at (2cm, 3cm) {Below Second rectangle}; % Further down (more negative Y)
\end{scope}
\end{tikzpicture}
\end{document}
- (2)
tikz-explicit-yscale.tex: Similar to (1)tikz-default-notworking.texbut this file use "yscale=-1" intikzpicture. Now, boxes are printed assuming anchor as north-west, not south-west. Moreover, it starts from some margin on left and top.
\documentclass{article}
\usepackage{tikz}
\usepackage[margin=0mm, paperwidth=210mm, paperheight=297mm]{geometry} % Adjust size as needed
\pagestyle{empty} % Removes page numbers and headers
\begin{document}
\begin{tikzpicture}[remember picture, overlay, yscale=-1]
\begin{scope}[shift={(0cm, 0cm)}] % Positioned partway down the page
% Draw a rectangle
\draw (0,0) rectangle ++(4cm,1cm); % Moves downward within the scope
% Place text below the rectangle
\node at (2cm, 1.5cm) {Below First rectangle}; % Further down (more negative Y)
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay, yscale=-1]
\begin{scope}[shift={(5cm, 5cm)}] % Positioned partway down the page
% Draw a rectangle
\draw (0,0) rectangle ++(4cm,2cm); % Moves downward within the scope
% Place text below the rectangle
\node at (2cm, 3cm) {Below Second rectangle}; % Further down (more negative Y)
\end{scope}
\end{tikzpicture}
\end{document}
- (3)
tikz-default-as-north-west.tex: Similar to (1)tikz-default-notworking.texbut this file use -ve Y coordinate instead of "yscale=-1". This file produces exactly same as output like "yscale=-1" ie. anchor is treated as north-west and (0,0) starts with some margin on left and top.
\documentclass{article}
\usepackage{tikz}
\usepackage[margin=0mm, paperwidth=210mm, paperheight=297mm]{geometry} % Adjust size as needed
\pagestyle{empty} % Removes page numbers and headers
\begin{document}
\begin{tikzpicture}[remember picture, overlay]
\begin{scope}[shift={(0cm, 0cm)}] % Positioned partway down the page
% Draw a rectangle
\draw (0,0) rectangle ++(4cm,-1cm); % Moves downward within the scope
% Place text below the rectangle
\node at (2cm, -1.5cm) {Below First rectangle}; % Further down (more negative Y)
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay]
\begin{scope}[shift={(5cm, -5cm)}] % Positioned partway down the page
% Draw a rectangle
\draw (0,0) rectangle ++(4cm,-2cm); % Moves downward within the scope
% Place text below the rectangle
\node at (2cm, -3cm) {Below Second rectangle}; % Further down (more negative Y)
\end{scope}
\end{tikzpicture}
\end{document}
- (4)
tikz-explicit-south-west.tex: This file explicitly setstikzpictureanchor to south-west and maintains same coordinates as (1)tikz-default-notworking.tex. This time, output is correctly produced as expected, boxes are rendered at the bottom left. Moreover, this time, (0,0) starts with bottom-left corner of a page, without any margin.
\documentclass{article}
\usepackage{tikz}
\usepackage[margin=0mm, paperwidth=210mm, paperheight=297mm]{geometry} % Adjust size as needed
\pagestyle{empty} % Removes page numbers and headers
\begin{document}
\begin{tikzpicture}[remember picture, overlay, shift={(current page.south west)}]
\begin{scope}[shift={(0cm, 0cm)}] % Positioned partway down the page
% Draw a rectangle
\draw (0,0) rectangle ++(4cm,1cm); % Moves downward within the scope
% Place text below the rectangle
\node at (2cm, 1.5cm) {Below First rectangle}; % Further down (more negative Y)
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay, shift={(current page.south west)}]
\begin{scope}[shift={(5cm, 5cm)}] % Positioned partway down the page
% Draw a rectangle
\draw (0,0) rectangle ++(4cm,2cm); % Moves downward within the scope
% Place text below the rectangle
\node at (2cm, 3cm) {Below Second rectangle}; % Further down (more negative Y)
\end{scope}
\end{tikzpicture}
\end{document}
I fail to understand why default anchor behavior is different on my system, and why (0,0) leaves a margin in case default anchor is "north-west" but works as expected when "anchor = south-west" is explicitly set. If stack exchange permits uploading .tex and .pdf files, I will upload those as well.

tikzwill think.tikzwill always treat the bottom left corner of your current input location as (0,0). Any shifts you set will be followed as: positive x to the right and positive y to top, vice versa. Take a look this post: https://tex.stackexchange.com/a/642203/267375 – Tom Feb 16 '24 at 21:17