tags:

views:

131

answers:

2

Hi,

I wonder how to place several tables consecutively in Latex?

The page with the text right before the first table has a little space but not enough for the first table, so the first table is to be placed on the top of the next page, although I use "\begin{table}[!h]" for it.

The second table does not fit into the place in the rest of the page of the first table, so I think I might use longtable for it to span the rest of the page and the top of the next page. Similarly, I use longtable for the third table.

The latex code is as follows:

... % some text  

\begin{table}[!h]  
\caption{Table 1. \label{tab:1}}  
\begin{center}  
\begin{tabular}{c c}  
...  
\end{tabular}  
\end{center}  
\end{table}     

\begin{center}  
\begin{longtable}{ c c }  
\caption{Table 2. \label{tab:2}}\\   
...  
\end{longtable}  
\end{center}  

\begin{center}  
\begin{longtable}{ c c }  
\caption{Table 3. \label{tab:3}}\\   
...  
\end{longtable}  
\end{center}  

... % some text

In the compiled pdf file it turns out that the order of the tables is messed up. The first table is placed behind the second and third one, and the second one spans the page with text before the tables and the next page with the third one following it.

I would like to know how I can make the three tables appear consecutively in order, and there are no space left blank between them and between the text and the tables?

Or if what I hope is not possible, what is the best strategy then?

Thanks and regards!


EDIT:

Removing [!h] does not make improvement, the first table is still behind the second and the third.


EDIT:

As suggested by one of the following replies, using [H] works for me. Out of curiousity, what is the difference between the effects of [H] and [!h]?

+3  A: 

Try to remove [!h]

The thing is that \begin{table} ... \end{table} defines a floating insertion. This insertion appears on one of the following pages. \begin{longtable} defines non-floating table. Longtable appears immediately.

You should to remove \begin{table} ... \end{table} to make first table appears immediatly. [!h] does not make table to be non-floation.

Alexey Malistov
Thanks, Alexey! But removing [!h] does not make improvement, the first table is still behind the second and the third.
Tim
What Alexey is saying is that you need to remove `\begin{table}` and `\end{table}`. LaTeX renders those as **floats**: large objects which it is free to position (within reason) wherever looks best. The inner `\begin{tabular}...\end{tabular}` or `\begin{longtable}...\end{longtable}` produce the actual table. If you just have those directly in the document, they'll effectively be treated as one giant letter, and will be guaranteed to go one after the other (you may need to force line breaks with `\\`).
Antal S-Z
+1  A: 

I forget if it's the array or float package that gives you [H], but this has always worked for me:

\begin{table}[H]
...
\end{table}
Mica
Thanks Mica! It works for me too. Out of curiousity, what is the difference between the effects of [H] and [!h]?
Tim
I am not quite sure, Tim. I think technically [!h] still has the possibility to float, while [H] is registered as not floating at all.
Mica