5

How do I vertically center a table in the remaining part of a page? Specifically, I want to put a large table on a single page but I also want to have a subsection title line at the top. However, using the below code

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}

\begin{document}
\subsection{Title}
\begin{figure}[p]\centering\begin{tabular}{c}
test\\
\end{tabular}\end{figure}
\end{document}

puts the table vertically centered, but on a new page.

Of course, others may want to have several paragraphs followed by a single float centered vertically in the remaining area of the page. So one wonders if there is a way to easily accomplish this?

6
  • the [p] option for figure always goes to a new page, and doesn't allow anything else on that page. [b] will move the float to the bottom of the page, so that's not what you want either. in this case, you should probably try using just \begin{center} ... \end{center} and not treat it as a float at all, but add vertical space manually as necessary. Apr 15, 2013 at 12:38
  • What about \vfill\begin{figure}\centering ... \end{figure}\vfill or am I missing something? Apr 15, 2013 at 12:50
  • That does not work (for me). It puts the table at the top with the subsection title following right after. Apr 15, 2013 at 13:04
  • 1
    Have you tried replacing \vfill with \vspace*{\fill}?
    – AndreasT
    Apr 15, 2013 at 13:22
  • That actually does the same as \vfill, at least for me. Apr 15, 2013 at 13:24

1 Answer 1

7

A float environment is hardly warranted here, since you seem to require a specific location for your tabular environment. Why not just do the following?

See this for more details on what floats are used for.

enter image description here

\documentclass{article}

\usepackage{caption}
\usepackage{lipsum}

\begin{document}

\section{Foobar}

Please refer to Table~\ref{fig:mytable} for more details.

\lipsum[1]

\vspace*{\fill}
{
\centering
\begin{tabular}{c|c|c|c} 
  28 & 1 & (1)(28) & 28 \\
  27 & 0 & (0)(27) &  0 \\
  26 & 1 & (1)(26) & 26 \\
  25 & 2 & (2)(25) & 50 \\
  24 & 3 & (3)(24) & 72 \\
\end{tabular}
\captionof{table}{A magnificent table}
\label{fig:mytable}
}
\vspace*{\fill}
\clearpage

\end{document}
1
  • two problems here: if any text comes after this, it will be centered unless \centering is turned off or "buried" in a group; also, if the following text, or the first paragraph, would fit on the page, it will go on the same page. it would be good to add \clearpage or \newpage after the second fill. Apr 15, 2013 at 17:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .