Graphics, Figures & TablesShifting up a table (to fit it on a page)

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
davidec
Posts: 16
Joined: Thu Oct 22, 2009 6:18 pm

Shifting up a table (to fit it on a page)

Post by davidec »

I have a table which is slightly, but only slightly, longer than the page height. It is long enough to cover the page number at the bottom, but not long enough that I would see it sensible to break it over two pages and make it a "longtable".

Is there a way to shift it up by a couple of millimetres within that page in order to prevent it from covering the page number at the bottom? I tried a negative "vspace", but that one affects only the text around the table, not the table itself.

Here's an MWE of such a table (actually, this one covers the page number by quite a bit. In my case, it's much less).

Thanks in advance!

Code: Select all

\documentclass[letterpaper,12pt]{article}
\usepackage{lipsum}

\begin{document}

\newcommand{\loremipsum}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit.}

\lipsum[1-4]

\begin{table}
\caption{Some lorem ipsum} 
\begin{tabular}{p{45mm}p{45mm}p{45mm}}
\hline
 1 & 2 & 3  \\ \hline\hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\end{tabular}
\end{table}

\lipsum[1-4]

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Shifting up a table (to fit it on a page)

Post by gmedina »

Hi,

the following code illustrates a possible solution. Enclose the table inside a minipage, use the \captionof command (provided by the caption package) and then move the minipage up as much as you require:

Code: Select all

\documentclass{letterpaper,12pt]{article}
\usepackage{lipsum}
\usepackage{caption}

\begin{document}

\newcommand{\loremipsum}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit.}

\lipsum[1-4]

\begin{minipage}{\linewidth}
\vskip-50pt
\captionof{table}{Some lorem ipsum} 
\begin{tabular}{p{45mm}p{45mm}p{45mm}}
\hline
1 & 2 & 3  \\ \hline\hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\loremipsum & \loremipsum & \loremipsum  \\ \hline
\end{tabular}
\end{minipage}
\lipsum[1-4]

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
davidec
Posts: 16
Joined: Thu Oct 22, 2009 6:18 pm

Re: Shifting up a table (to fit it on a page)

Post by davidec »

Excellent, thank you very much! That solves the issue.
Post Reply