For a poster, I would like to have an image fill the whole page. This image is supposed to be drawn within a tikz environment as my other content. However, graphicx seems to fail at rescaling when the image aspect ratio is much different fom the paper aspect ratio. My code reads:
\documentclass[]{extarticle}
\usepackage[a0paper,margin=0cm]{geometry}
\usepackage{tikz}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\begin{document}
\begin{tikzpicture}
% draw generic background
\draw[white,line width=0pt] (-.5\textwidth, -.5\textheight) rectangle (.5\textwidth, .5\textheight);
% draw image
\pgftext[center,at={\pgfpoint{0}{0}}]{\includegraphics[width=\textwidth,height=\textheight]{test.jpg}}
\end{tikzpicture}
\end{document}
I use the background to fill the whole page with a tikz environment so that (0,0) is at the center of the page and I can position other tikz objects as needed. As long as I use images which closely fit the page or if I use the command includegraphics[width=\textwidth,height=\textheight,keepaspectratio]
, the image gets scaled correctly. Otherwise, I get a blank first page and my content is on the second page. In other words, the image does not fit the page size, it is too large! How can I prevent this error from happening? Or is there even a better way to draw the image from within the tikz environment?
Best Answer
Here is a simple solution without
\pgftext
(don't mix pgf and TikZ) andmargin=0cm
, and using theremember picture
andoverlay
option, the specialcurrent page
node and\paperwidth
x\paperheight
: