It is possible to position the image without redefining the page geometry. Redefining the page geometry in general can give you problems.
First let us use some TikZ code to position a block at the top of the page. the block will be half an A4 size i.e., an A5 paper size. When we use an overlay as you see from the image below:
The MWE is shown below:
\documentclass[a4paper]{article}
\usepackage{tikz,lipsum}
\usepackage{hyperref}
\begin{document}
\thispagestyle{empty}
\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, inner sep=0pt, outer sep=0pt,anchor=north west]
\path[color=black,fill=purple]
(0,0) rectangle ++(\the\paperwidth,-0.5\paperheight);
\end{tikzpicture}
};
\end{tikzpicture}
\lipsum
\end{document}
Now of course this is not satisfactory as you want to position the text after the image or the TikZ picture. In order to achieve this you enclose the tikz picture in a \vbox
set at half-page height.
\documentclass[a4paper]{article}
\usepackage{tikz,lipsum}
\usepackage{hyperref}
\begin{document}
\vbox to 0.5\paperheight{\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, inner sep=0pt, outer sep=0pt,anchor=north west]
\path[color=black,fill=purple]
(0,0) rectangle ++(\the\paperwidth,-0.5\paperheight);
\end{tikzpicture}%
};%
\end{tikzpicture}}
\section{Test}
\lipsum
\end{document}
If you replace the code in the node with an includegraphics
command, your image should be imported at the top of the page with no problems.
It is also possible to do the same without any tikZ code. I will post this a bit later if this is what you are after.
As pdf uses different parameters for paperheight
and paperwidth
, I normally use the package hyperref
to ensure they are corrected. If you do not want to load it you can use:
\newcommand*{\fixpdflayout}{%
\pdfpageheight=\the\paperheight
\pdfpagewidth=\the\paperwidth
\ifxetex\else
\ifdim\pdfvorigin=0pt\pdfvorigin=1in\fi
\ifdim\pdfhorigin=0pt\pdfhorigin=1in\fi
\fi}
Best Answer
The best strategy is
Choose the paper format you'll be using more frequently at install time (TeX Live allows to choose between Letter paper and A4, and probably also MiKTeX).
For the documents where a different paper size is needed, write
With this call,
geometry
will only do the required steps for announcing the desired paper format to the output driver.The default paper size can be changed, in TeX Live, via
tlmgr
:(with superuser privileges). The GUI front-ends to
tlmgr
also offer this command through one of the menus.