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
Add
a5paper
to documentclass options, and replaceletterpaper
witha5paper
: