[Tex/LaTex] Centering full-page Tikz image on page without margins with xelatex

positioningtikz-pgfxetex

I'm trying to export some full-page SVG images via inkscape2tikz, and then trying to include these tikz-code images in a Latex document; but there seems to be a slight problem with xelatex.

After checking

… I came up with the following MWE:

\documentclass[12pt,a5paper]{article}

\usepackage{tikz}

\begin{document}

\thispagestyle{empty}

\definecolor{cff0000}{RGB}{255,0,0}


\begin{tikzpicture}[overlay,remember picture,anchor=north west,inner sep=0pt, outer sep=0pt]

\node at (current page.north west) {%

  \begin{tikzpicture}[overlay,remember picture,y=0.80pt,x=0.80pt,yscale=-1, inner sep=0pt, outer sep=0pt,anchor=north west]

    \begin{scope}[shift={(0,0.34461553)}]% layer1

      % rect3016
      \path[color=black,fill=cff0000,line width=0.800pt,rounded corners=0.0000cm]
        (0.0000,-0.3446) rectangle (524.4094,743.7499);

    \end{scope}

  \end{tikzpicture}

};

\end{tikzpicture}

\end{document}

Now, if I build this with pdflatex:

  • after first build, the rectangle is positioned wrong – but
  • after second build, the rectangle is correctly positioned

But, if I build with xelatex:

  • after first build, the rectangle is positioned way out
  • after second build, the rectangle is positioned differently, but still wrong.

Here is what xelatex produces after multiple runs (kinda hard to see here, but download the image to see the positioning of the red rectangle vs. the white background):

xelatex rectangle fail

Obviously, I'd like to have the red rectangle centered on page (or aligned at top left corner, doesn't matter) – so that the red rectangle takes up most of the page.

Any ideas on how to do that?

Many thanks in advance for any answers,
Cheers!

Best Answer

Add \usepackage[pass]{geometry} to your preamble: this will pass the drivers the correct page size.