[Tex/LaTex] Latex centering figures and tables when alone on a page

floatstablesvertical alignment

I have 4 tables that need to follow each other (they are in the appendix). Two fit on a single page together but there is plenty of space left (thought not enough for another table). I would like to vertically center these two tables so that they don't look weird. How can I do that?

Here is my code (I want the tables to vertically centered):

\documentclass[11pt,a4paper]{article}

\usepackage{float} % For H

\begin{document}

\begin{table}[H]
\centering
    \begin{tabular}{|c|c|}
    \hline
    8  &  4  \\ \hline  4  &  8  \\ \hline
    4  &  8  \\ \hline  8  &  4  \\ \hline
    8  &  8  \\ \hline  8  &  4  \\ \hline
    4  &  8  \\ \hline  4  &  8  \\ \hline
    8  &  4  \\ \hline  8  &  8  \\ \hline
    8  &  4  \\ \hline  4  &  8  \\ \hline
    4  &  8  \\ \hline  8  &  4  \\ \hline
    \end{tabular}
    \caption{Order = 1}
\end{table}

\begin{table}[H]
\centering
    \begin{tabular}{|c|c|}
    \hline
    8  &  4  \\ \hline  4  &  8  \\ \hline
    4  &  8  \\ \hline  8  &  4  \\ \hline
    8  &  8  \\ \hline  8  &  4  \\ \hline
    4  &  8  \\ \hline  4  &  8  \\ \hline
    8  &  4  \\ \hline  8  &  8  \\ \hline
    8  &  4  \\ \hline  4  &  8  \\ \hline
    4  &  8  \\ \hline  8  &  4  \\ \hline
    \end{tabular}
    \caption{Order = 2}
\end{table}

\begin{table}[H]
\centering
    \begin{tabular}{|c|c|}
    \hline
    8  &  4  \\ \hline  4  &  8  \\ \hline
    4  &  8  \\ \hline  8  &  4  \\ \hline
    8  &  8  \\ \hline  8  &  4  \\ \hline
    4  &  8  \\ \hline  4  &  8  \\ \hline
    8  &  4  \\ \hline  8  &  8  \\ \hline
    8  &  4  \\ \hline  4  &  8  \\ \hline
    4  &  8  \\ \hline  8  &  4  \\ \hline
    \end{tabular}
    \caption{Order = 3}
\end{table}

\begin{table}[H]
\centering
    \begin{tabular}{|c|c|}
    \hline
    8  &  4  \\ \hline  4  &  8  \\ \hline
    4  &  8  \\ \hline  8  &  4  \\ \hline
    8  &  8  \\ \hline  8  &  4  \\ \hline
    4  &  8  \\ \hline  4  &  8  \\ \hline
    8  &  4  \\ \hline  8  &  8  \\ \hline
    8  &  4  \\ \hline  4  &  8  \\ \hline
    4  &  8  \\ \hline  8  &  4  \\ \hline
    \end{tabular}
    \caption{Order = 4}
\end{table}

\end{document}

Best Answer

It's best not to use the [H] float placement here. Rather use a [p]age of floats setting. Additionally, if need be, you could use the afterpage package to flush any pending floats:

enter image description here

\documentclass{article}
\usepackage{graphicx,lipsum}
\usepackage{afterpage}
\begin{document}
\section{A section}
\lipsum[1-50]% A lot of text.

\begin{figure}[p]
  \centering
  \includegraphics[width=.5\textwidth]{example-image-a}
  \caption{Some figure.}

  \vspace{4\baselineskip}

  \includegraphics[width=.4\textwidth]{example-image-b}
  \caption{Some other figure.}
\end{figure}

\begin{figure}[p]
  \centering
  \includegraphics[width=.4\textwidth]{example-image-b}
  \caption{Some figure.}

  \vspace{4\baselineskip}

  \includegraphics[width=.5\textwidth]{example-image-a}
  \caption{Some other figure.}
\end{figure}
\afterpage{\clearpage}% Flush any pending floats after _this_ page.

\lipsum[1-50]% A lot of text.
\end{document}

While it may not be apparent in the image above, the floats were placed somewhere mid-page on the page preceding the placement. Also not that, for the sake of "keeping things together", the two figures were placed in a single float. That's fine, since the \caption for each separates them visually from the output, as well as the space between (which you can adjust).

The above approach also works with tables.

For a general discussion on float placement, see the FAQ How to influence the position of float environments like figure and table in LaTeX?.