2

I was wondering what is the right way to include a long table in between pages?

I have a table that is an A4 page long, if I use \begin{table}[h] it pushes the table to the very end of the document, and if I use \begin{table}[h!] it forced some extra white space at some paragraphs.

Thanks for the help.

drhanlau
  • 277

1 Answers1

2

It is not very clear from your question what you are asking for. From what I gather from your question, you want to put a table in an independent page. The table is a page long. You do not want it on some fixed page, some approximate location will be just fine.

If the above is your scenario, then you need to use [!p] as your position specifier. Here, p means page of float and LaTeX will try to honor the placement with respect to actual place. By putting an ! before p you insist on this placement. This overrides internal parameters LaTeX uses for determining good float positions.

Please try the following code, check the output, and let us know whether it suits your purpose.

\documentclass{article}

\usepackage{lipsum}

\begin{document}

\section{One}

\lipsum[11]

\section{Two}

\lipsum[12]

\begin{table}[!p]
  \centering
  \begin{tabular}[c]{|c|c|p{0.75\textwidth}|l|}
    \hline
    1&1&\raggedright\lipsum[1]&One\\\hline
    2&2&\raggedright\lipsum[2]&Two\\\hline
    3&3&\raggedright\lipsum[3]&Three\\\hline
  \end{tabular}
  \caption{A table one page long}
  \label{tab:long}
\end{table}

\section{Three}

\lipsum[13]

\section{Four}

\lipsum[14]
\lipsum[15]
\lipsum[16]



\end{document}
Masroor
  • 17,842
  • Yes, that's exactly what I need. I need it to be as close as possible with the original text where I cited the table. If I use [h] it will go to the very end of the document which is like 10 pages away. – drhanlau Nov 06 '13 at 02:32
  • @cherhan Great. Glad of the of assistance. Now you can accept the answer :-) In most of the cases ! does the trick. I make it a rule to use !tbp for all my float location specifiers. – Masroor Nov 06 '13 at 02:34
  • what if it causes extra whitespace around paragraphs around the float? – drhanlau Nov 06 '13 at 03:00
  • @cherhan Not very clear. Are you talking about the spaces before and after the float? If that this the case this will help. – Masroor Nov 06 '13 at 03:04
  • I will try to create a MWE to show you. Just that some times, for example after section 2 (lipsum[12]) it might show a large white in order to push the table to another page. It's ok if you don't understand :) – drhanlau Nov 06 '13 at 04:41
  • @cherhan I do not see any such white space in my output. I refrain from attaching the output here since that will be trivial. And actual pagination will depend on many factors including default page size. And we must remember that ! actually asks LaTeX to ignore controlling parameters. You said that it is okay if I miss it. But I want to help, please let me know if I can improve the scenario in any way. – Masroor Nov 06 '13 at 06:45