I just got this question answered:
xetex - Centering full-page Tikz image on page without margins with xelatex? - TeX - LaTeX
... and all works there.
However, here is my problem - I basically have a document whose normal pages are A4, whereas these SVG->tikz images are supposed to be A5. So, I try to:
- define the document as A4;
- use the trick from Change paper size in mid-document with setting
\pdfpagewidth/height; to switch the necessary pages to A5
... however, but that seems to mess up the page calculation Tikz uses.
Here is a MWE (same as in first link, changed so it includes the tikz image instead):
test.tex
\documentclass[12pt,a4paper]{article}
\usepackage[pass]{geometry}
% %\usepackage{hyperref}
\usepackage{tikz}
\begin{document}
% \thispagestyle{empty}
\pdfpagewidth=148mm \pdfpageheight=210mm
\input{testin.tex}
\end{document}
testin.tex
\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}
Here is a little experiment with these files I did; when it says (clear state), means I've removed the .aux beforehand:
- With
\documentclass[12pt,a5paper]{article}; without\pdfpagewidth/heightsetting- xelatex first pass (clear state), .aux:
\relax \pgfsyspdfmark {pgfid2}{5924114}{69025514} \pgfsyspdfmark {pgfid1}{5891346}{29900006} - xelatex second pass, (page OK), .aux:
\relax \pgfsyspdfmark {pgfid2}{32768}{39125508} \pgfsyspdfmark {pgfid1}{5891346}{29900006}
- xelatex first pass (clear state), .aux:
- With
\documentclass[12pt,a4paper]{article}; without\pdfpagewidth/heightsetting- xelatex first pass (clear state), .aux:
\relax \pgfsyspdfmark {pgfid2}{7955730}{101470942} \pgfsyspdfmark {pgfid1}{7922962}{46122720} - xelatex second pass, (img aligned, but page is bigger; as expected), .aux:
\relax \pgfsyspdfmark {pgfid2}{32768}{55348222} \pgfsyspdfmark {pgfid1}{7922962}{46122720}
- xelatex first pass (clear state), .aux:
- With
\documentclass[12pt,a4paper]{article}; WITH\pdfpagewidth/heightsetting; no clear state- xelatex first pass (continued from previous a4paper - page is OK!), .aux:
\relax \pgfsyspdfmark {pgfid2}{32768}{39125508} \pgfsyspdfmark {pgfid1}{7922962}{29900006} - xelatex second pass (image goes out of page), .aux:
\relax \pgfsyspdfmark {pgfid2}{32768}{55348222} \pgfsyspdfmark {pgfid1}{7922962}{29900006}
- xelatex first pass (continued from previous a4paper - page is OK!), .aux:
- With
\documentclass[12pt,a4paper]{article}; WITH\pdfpagewidth/heightsetting- xelatex first pass (clear state; first pass img not even visible), .aux:
\relax \pgfsyspdfmark {pgfid2}{7955730}{85248228} \pgfsyspdfmark {pgfid1}{7922962}{29900006} - xelatex second pass (image goes out of page), .aux:
\relax \pgfsyspdfmark {pgfid2}{32768}{55348222} \pgfsyspdfmark {pgfid1}{7922962}{29900006}
- xelatex first pass (clear state; first pass img not even visible), .aux:
The only thing I can conclude from this experiment, is that the page is OK, when the .aux file (after the xelatex run) contains:
\relax
\pgfsyspdfmark {pgfid2}{32768}{39125508}
\pgfsyspdfmark {pgfid1}{7922962}{29900006}
... so apparently, it is possible to position the image correctly, even if documentclass is A4 page, and I switch "manually" to A5 using \pdfpagewidth/height; just don't know how to do this correctly :)
So, is there a way to write the .tex, so I can position the A5 tikz box all over the page, which is manually switched to A5 ?
(NB: I'd like to keep all this as tikz/latex code, I'm not too keen on exporting individual PDFs and including them with say pdfpages or the like).
Many thanks in advance for any answers,
Cheers!

