[Tex/LaTex] Making table fill the page vertically

spacingtables

I have several tables in my document that are just a bit too small to fill the entire page, vertically.

I'd like to stretch the table, either by adding empty lines at the bottom, or by stretching the lineskip, so that the table fills the text area.

How would I go about this?

\documentclass{scrbook} % because that is what I use

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tabularx}

\usepackage{showframe}
\usepackage{lipsum}

\begin{document}

\begin{table*}
\begin{tabularx}{\linewidth}{|X|X|}
\hline
\textbf{Column A} & \textbf{Column B}\\
\hline
\lipsum[1] & \lipsum[2] \\
\hline
\end{tabularx}
\end{table*}

\end{document}

I want the red-marked whitespace to disappear, i.e. the table borders to match the textarea borders.

enter image description here

Note that this is contrived. In the real document, this is about sidewaystable – making the non-textarea height much more disruptive for the overall layout, and removing the option of simply having surrounding text take up the whitespace.

Best Answer

A solution, where the caption is put inside the tables (example tables taken from the answers of David Carlisle and DevSolar):

\documentclass[captions=tableheading]{scrbook}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tabularx}
\usepackage{rotating}

\usepackage[vlines]{tabularht}

\usepackage{showframe}
\usepackage{lipsum}   

\newdimen\orgtextwidth
\setlength{\orgtextwidth}{\textwidth}

\begin{document}

\makeatletter

\begin{table*}
\begin{tabularhtx}{\textheight}{\linewidth}{|X|X|}
\noalign{%
  \caption{This is an example}%
}
\hline
\interrowfill
\textbf{Column A} & \textbf{Column B}\\
\interrowfill
\hline
\interrowfill
\lipsum[2] & \lipsum[2]\\
\interrowfill
\hline
\end{tabularhtx}
\end{table*}

\begin{table*}
\centering
\begin{tabularht}{\textheight}{|l|}
\multicolumn{1}{@{}c@{}}{%
  \hbox to 0pt{%
    \hss
    \centerline{%
      \parbox{\linewidth}{%
       \caption{This is an example}%
      }%
    }%  
    \hss
  }%
}\\ 
\hline
\interrowfill
\textbf{Col.}\\
\interrowfill  
\hline
\interrowfill
abc\\
\interrowfill
def\\
\interrowfill
ghi\\
\interrowfill
\hline
\end{tabularht}
\end{table*}   

\clearpage

\begin{sidewaystable*}
\begin{tabularhtx}{\orgtextwidth}{\linewidth}{|X|X|}
\hline
\noalign{\captionabove{This is an example}}
\hline
\interrowfill
\textbf{Column A} & \textbf{Column B}\\
\interrowfill
\hline
\interrowfill
\lipsum[2] & \lipsum[2]\\
\interrowfill
\hline
\end{tabularhtx}
\end{sidewaystable*}
\end{document}

Remarks:

  • The horizontal position inside \noalign is the left border of the tabular. Because the width of the tabular is not known here, a proper centering is only possible, if the table spans the full width.

  • KOMA-Script option captions=tableheadings added to get the correct spacing for the table captions.

  • Inside sidewaystable* \captionabove is used, because KOMA-Script fails to see that this is also a table.

Related Question