# Balancing vertical spacing between images or boxes in a page

I've have a series group made of text and of images (1 to 6 images per group). I would like the vertical spacing between images to be well balanced in a page.

Here is a minimal working example (for illustrative purposes here, real images are replaced with a black box and page frames are displayed):

https://fr.sharelatex.com/project/5860184917ccee00403ef8ca

\documentclass[DIV=12,paper=a4,10pt,notitlepage]{report}
\usepackage[
showframe,
paperwidth=210mm,
paperheight=297mm,
top=27.5mm,
bottom=27.5mm,
inner=20mm,
outer=20mm,
marginparsep=7mm,
marginparwidth=48mm,
]{geometry}

\usepackage{blindtext}

\begin{document}

\section{Section}
\blindtext[5]
\vfill
\makebox[\textwidth]{
\centering
\rule{8cm}{5cm}
}
\vfill

\clearpage
\section{Section}
\blindtext[5]
\vfill
\makebox[\textwidth]{
\centering
\rule{8cm}{5cm}
}
\vfill

\vfill
\makebox[\textwidth]{
\centering
\rule{8cm}{5cm}
}
\vfill

\vfill
\makebox[\textwidth]{
\centering
\rule{8cm}{5cm}
}
\vfill

\clearpage
\section{Section}
\blindtext[5]
\vfill
\makebox[\textwidth]{
\centering
\rule{8cm}{5cm}
}
\vfill

\vfill
\makebox[\textwidth]{
\centering
\rule{8cm}{5cm}
}
\vfill

\vfill
\makebox[\textwidth]{
\centering
\rule{8cm}{2cm}
}
\vfill

\vfill
\makebox[\textwidth]{
\centering
\rule{8cm}{5cm}
}
\vfill
\end{document}


Typical cases:

• 1st case: looks good ! Picture seems to have equal amount of free space above it (up to bottom of the text) and below (down to bottom of the page)

• 2nd case: 1st picture is missing some vertical spacing below, 2nd image is missing space at the top, 3rd image looks good

• 3rd case: same as previous case and 3rd and 4th images look good

The real document is about 450 pages with 200 different sections (groups) where the length of the text varies as well as the number of images.

apart from the vertical space, each image gave

Overfull \hbox (15.0pt too wide) in paragraph at lines 70--74


due to the paragraph indentation.

also \centering does nothing inside \makebox (as it is horizontal mode).

However normally space is discarded at a page break, but here it appears that you want to keep it so you can use \vspace*

\documentclass[DIV=12,paper=a4,10pt,notitlepage]{report}
\usepackage[
showframe,
paperwidth=210mm,
paperheight=297mm,
top=27.5mm,
bottom=27.5mm,
inner=20mm,
outer=20mm,
marginparsep=7mm,
marginparwidth=48mm,
]{geometry}

\usepackage{blindtext}

\begin{document}

\section{Section}
\blindtext[5]

\nopagebreak
\vspace*{\fill}
\noindent\makebox[\textwidth]{
\rule{8cm}{5cm}
}

\nopagebreak
\vspace*{\fill}

\clearpage
\section{Section}
\blindtext[5]

\nopagebreak
\vspace*{\fill}
\noindent\makebox[\textwidth]{
\rule{8cm}{5cm}
}

\nopagebreak
\vspace*{\fill}

\pagebreak[0]

\vspace*{\fill}
\noindent\makebox[\textwidth]{
\rule{8cm}{5cm}
}

\nopagebreak
\vspace*{\fill}

\pagebreak[0]

\vspace*{\fill}
\noindent\makebox[\textwidth]{
\rule{8cm}{5cm}
}

\vspace*{\fill}

\clearpage
\section{Section}
\blindtext[5]

\nopagebreak
\vspace*{\fill}
\noindent\makebox[\textwidth]{
\rule{8cm}{5cm}
}

\nopagebreak
\vspace*{\fill}

\pagebreak[0]

\vspace*{\fill}
\noindent\makebox[\textwidth]{
\rule{8cm}{5cm}
}

\nopagebreak
\vspace*{\fill}

\pagebreak[0]

\vspace*{\fill}
\noindent\makebox[\textwidth]{
\rule{8cm}{2cm}
}

\nopagebreak
\vspace*{\fill}

\pagebreak[0]

\vspace*{\fill}
\noindent\makebox[\textwidth]{
\rule{8cm}{5cm}
}

\nopagebreak
\vspace*{\fill}

\end{document}

• Thanks David ! It works. However in some cases (e.g., long introducing paragraph + single image alone on a page) spacing at page breaks still doesn't work. I'm not able to reproduce them in a minimal working example, so I will try to first solve this before coming back. – Derek Jan 2 '17 at 8:01