I'm trying a simple page with an image in the top of it as a header and an square image centered in the rest of the page.
I would like the images to fill the full page width. After trying some aproaches, I have decided to use subfigures (from subcaption package) because although I'm talking about a single square image centered in the page, in the future i will need to create some image matrices, something like that:
Coming back to my single square image centered in page template, I have set some latex lengths to 0 cm:
\setlength{\parindent}{0cm}
\setlength{\parskip}{0cm}
\setlength{\headheight}{0pt}
\setlength{\skip\footins}{0pt}
\setlength{\headsep}{0.0pt}
\setlength{\topskip}{0.0pt}
\setlength{\footskip}{0.0pt}
And using geometry package, I have defined the page as follows:
\geometry{
layoutheight = 21 cm,
layoutwidth = 29.7 cm,
layouthoffset = 0cm,
layoutvoffset = 0cm,
left=0cm,
right=0cm,
top=0cm,
bottom=0cm
}
then, my code:
\begin{document}
\begin{figure}[H]
\includegraphics[width=21cm,height=2.1cm]{\headerImage}
\begin{subfigure}{21cm}
\vspace*{3.3cm}\hspace*{0.0cm}\includegraphics[width=21cm,keepaspectratio]{0}
\end{subfigure}
\end{figure}
\end{document}
Of course, I've defined \headerImage and \graphicspath correctly.
When render, I can read the next message:
Overfull \vbox (154.68237pt too high) has occurred while \output is active
And the result is a pdf file with two pages, first of them completly white, and the next one with my header and my image perfectly centered, and both images fill the complete page width.
The second page is perfect.
Doing some calculations, 21cm (square image) + 2.1cm (header image) + 3.3cm (vspace) = 26,4 cm
Why is the first empty page added to the document?, How can I avoid the Overfull \vbox eror?
I'm not sure, but perhaps there is some other latex length that i don't know that should be set to 0??
Thank you very much in advance.
Edited:
Here is my code:
\documentclass{article}
\newcommand{\imagesPath}{/home/projects/latex-templates/images/}
\newcommand{\headerImage}{/home/projects/latex-templates/images/HEADERf.jpg}
%%% REQUIRED PACKAGES %%%
\usepackage{graphicx}
\usepackage[paperwidth=21 cm,paperheight=29.7 cm]{geometry}
\usepackage{color}
\usepackage{xcolor}
\usepackage{xstring}
\usepackage{calc}
\usepackage{fp}
\usepackage{float}
\usepackage{subcaption}
\usepackage{printlen}
\usepackage{import}
\graphicspath{{\imagesPath}}
%%% REDEFINED LATEX LENGTHS %%%
\setlength{\parindent}{0cm}
\setlength{\parskip}{0cm}
\setlength{\headheight}{0pt}
\setlength{\skip\footins}{0pt}
\setlength{\headsep}{0.0pt}
\setlength{\topskip}{0.0pt}
\setlength{\footskip}{0.0pt}
\setlength{\baselineskip}{0.0pt}
\setlength{\abovecaptionskip}{0.0pt}
\setlength{\belowcaptionskip}{0.0pt}
\geometry{
layoutheight = 21 cm,
layoutwidth = 29.7 cm,
layouthoffset = 0cm,
layoutvoffset = 0cm,
left=0cm,
right=0cm,
top=0cm,
bottom=0cm,
showcrop=false,
showframe=false,
}
\graphicspath{{\imagesPath}}
%%% BACKGROUND COLOR %%%
\definecolor{backgroundcolor}{HTML}{FFFFFF}
%%% DOCUMENT DEFINITION %%%
\pagenumbering{gobble}
\pagecolor{backgroundcolor}
\message{INIT DOCUMENT}
\begin{document}
\begin{figure}[H]
\includegraphics[width=21cm,height=2.165cm]{\headerImage}\\
\begin{subfigure}{21cm}
\vspace{3.2675cm}\hspace*{0.0cm}\includegraphics[width=21cm,keepaspectratio]{0}
\end{subfigure}
\end{figure}
\end{document}
And here is the result:
As you can see, there are two pages in the result pdf file. The second one is perfect, but without the first one! I'm sure this first empty page appears due to the: ` Overfull \vbox (154.68237pt too high) has occurred while \output is active
What can I do to avoid this first empty page appears
width=\linewidth
and remove theheight
options of the images. If you need some less that the text width, use fractions of this relative length as.45\linewidth
, not absolute lengths as12cm
. This will work always, even if you change the margins.keepaspectratio
have sense only when you set bothwidth
andheight
. When you fix only one, there are not enough information of how not keep the aspect/ratio. Right?figure
orsubfigure
here it just complicates the markup for no gain.