5

I want to add a page-long table using:

 \begin{center}
        \begin{tabular}{| p{3cm} | p{3cm} | p{3cm} | p{4cm}|}
        %long table
        \end{tabular}
 \end{center}

However, this adds an unwanted blank page before the table. What can I do to fix it?

UPDATE: Here is the template:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{color}
\usepackage{courier}

\definecolor{Gray}{gray}{0.95}
\setlength\parindent{0pt} % Uncomment to remove all indentation from paragraphs


\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}



 \begin{document}

 \begin{center}
        \begin{tabular}{| p{3cm} | p{3cm} | p{3cm} | p{4cm}|}
        %long table
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
        1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline

        \end{tabular}
 \end{center}

 \end{document}
4
  • 3
    Please make your code snippet compilable that we can see the resulting blank page ...
    – Mensch
    Commented May 14, 2016 at 22:00
  • 2
    The problem could be occurring because of some code elements that occur before \begin{center}, because the center environment is -- contrary to your assertion -- taller than \pageheight, or because of something else entirely. We won't know which one, unless you post a fully compilable example.
    – Mico
    Commented May 14, 2016 at 22:04
  • The table is too large for the remaining space on the page, so LaTeX starts a new page in the hope it will fit. This doesn't work, of course, because the table is too large for the page itself.
    – cfr
    Commented May 14, 2016 at 23:31
  • @cfr so how can I split it?
    – CFLAGS
    Commented May 14, 2016 at 23:37

1 Answer 1

3

The table is too long to fit on a page. LaTeX sees how much space is left on the current page before typesetting the table and compares this with the size of the entire center environment. Because it obviously finds there isn't enough space, it starts a new page before attempting to typeset the material. Obviously this doesn't help as the material is too large for the page and not just the remaining space on this page. But LaTeX doesn't know that.

To automatically split the table between pages, we can use something like longtable.

We don't need the center environment in this case.

However, the table is also too wide for the page.

A good solution is probably to load geometry which will set slightly more sensible margins.

Then the table fits the width and longtable splits it over a page break:

split table

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{longtable,geometry}
\begin{document}
\begin{longtable}{| p{3cm} | p{3cm} | p{3cm} | p{4cm}|}
  %long table
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\ \hline
\end{longtable}
\end{document}

This is a fairly ugly way to format tables. I'd recommend looking at how publication quality tables are formatted and the guidelines in the booktabs manual. For example:

booktabs

improves things, although it could be further improved in light of the actual content of the table in the actual document. (E.g. the final column looks too wide here, but that is probably a result of the dummy content.)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{longtable,booktabs,geometry}
\begin{document}
\begin{longtable}{*{3}{p{3cm}}p{4cm}}
  \toprule\endhead
  \bottomrule\endfoot
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
  1000000 & 4x4 & T(t)=Tmax/t & finds the solution\\
\end{longtable}
\end{document}
1
  • Lovely answer! longtable saved my day! Thank you! Commented May 10, 2021 at 19:48

You must log in to answer this question.

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