# minipage 15.0pt too wide

Sometimes I have two (or more) figure environments which I want to layout on one page, and put a horizontal rule in the center. To acomplish this, I put a \vfill\hrule\vfill between the two environments. However, this only works if I create a minipage spanning the whole text-region of a page.

However, if I do this I get either a hbox or a vbox overflow, depending on the document class. For article it's a hbox overflow of 15pt, for phdthesis (a cls I grabbed of the web) it's a vbox overflow also of 15pt.

This is a minimal working example:

\documentclass{article}
\newlength{\minipagewidth}
\newlength{\minipageheight}

\begin{document}%
%results in:  Badbox, line 9: Overfull \hbox (15.0pt too wide) in paragraph at lines 9-26
\setlength{\minipagewidth}{\textwidth}%
\setlength{\minipageheight}{\textheight}%
\begin{minipage}[t][\minipageheight]{\minipagewidth}%
Top of the page

\vfill\hrule\vfill

Bottom of the page
\end{minipage}
% no vbox or hbox overflow:
\begin{minipage}[t][\minipageheight]{\minipagewidth}%
Top of the page

\vfill\hrule\vfill

Bottom of the page
\end{minipage}%
\end{document}


The second minipage results in no such warning, but I had to subtract 15pt from the width. Where does this 15pt come from? why is \textwidth wider than the textual area's width?

• \noindent\begin{minipage}{\textwidth} Feb 17, 2015 at 13:28

It's the default indentation. As far as LaTeX is concerned, a minipage is just like a big letter. So \begin{minipage} starts a paragraph, if not already inside one.

\noindent\begin{minipage}{\textwidth}


solves the issue.

About the height, I'm not sure what you really want to achieve.

For a full page float, you can do like

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum} % just for the example

\begin{document}

\lipsum[1-3]

\begin{figure}[p]
\centering
\begin{minipage}[c][\dimexpr\textheight-\baselineskip+\topskip\relax][s]{\textwidth}
\centering

\includegraphics[width=8cm]{example-image-a}

\caption{A caption to the first figure}

\vfill
\hrule
\vfill

\includegraphics[width=8cm]{example-image-b}

\caption{A caption to the second figure}

\end{minipage}

\end{figure}

\lipsum[4-10]

\end{document}

• I found it hard to create a minimal working example with the height, as I'm using a documentclass that is not well known. I think the overfull vbox may be because of a newline on top of the page due to lacking trailing %'s. Feb 17, 2015 at 13:34