Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the following code an error

!h' float specifier changed to !ht`

I think because my tables span multiple pages. How can I get them to display properly one after the other?

\documentclass{article}
\begin{document}
\section{Database Design} 

\begin{table}[!h]
\centering
    \begin{tabular}{ | l |  l |}
    \hline
    Field & Type \\ \hline
    id & Primary key \\ \hline
    firstName & String \\ \hline
    lastName & String \\ \hline
    email & String \\ \hline
    password & String \\ \hline
    \end{tabular}
\caption{User2}
\end{table}

\begin{table}[!h]
\centering
    \begin{tabular}{ | l |  l |}
    \hline
    Field & Type \\ \hline
    id & Primary key \\ \hline
    firstName & String \\ \hline
    lastName & String \\ \hline
    email & String \\ \hline
    password & String \\ \hline
    \end{tabular}
\caption{User}
\end{table}

\begin{table}[!h]
\centering
    \begin{tabular}{ | l |  l |}
    \hline
    Field & Type \\ \hline
    id & Primary key \\ \hline
    title & String \\ \hline
    postedAt & Date\\ \hline
    email & String \\ \hline
    author & Foreign key from 'User' table\\ \hline
    tags & Foreign key from 'Tag' table\\ \hline
    \end{tabular}
\caption{Post}
\end{table}

\begin{table}[!h]
\centering
    \begin{tabular}{ | l |  l |}
    \hline
    Field & Type \\ \hline
    id & Primary key \\ \hline
    author& String \\ \hline
    content& String \\ \hline
    postedAt & Date\\ \hline 
    post& Foreign key from 'Post' table\\ \hline
    \end{tabular}
\caption{Comment}
\end{table}

\begin{table}[!h]
\centering
    \begin{tabular}{ | l |  l |}
    \hline
    Field & Type \\ \hline
    id & Primary key \\ \hline
    name & String
    \end{tabular}
\caption{Tag}
\end{table}

\begin{table}[!h]
\centering
    \begin{tabular}{ | l |  l |}
    \hline
    id & Primary key \\ \hline
    Field & Type \\ \hline
    post& Foreign key from 'PostTag' table\\ \hline
    tag& Foreign key from 'Tag' table\\ \hline
    \end{tabular}
\caption{PostTag}
\end{table}


\end{document}

share|improve this question
2  
    
What does "properly one after the other" mean to you? Do you mind any text in between them, or do you just want the tables without anything in between? –  Werner Apr 26 '12 at 6:21

2 Answers 2

up vote 4 down vote accepted

When TeX cannot put the table [h]ere because it is on a page break, it will always switch to something else.

For this case, I guess that a good option is loading a package

\usepackage{float}

and then using the [H] position specifier (capital 'H') (cannot be used with other ones, cannot be used with !):

\begin{table}[H]
...
\end{table}

This specifier means:

  • here and only here;

  • move to the next page if the table does not fit here, and leave the current page short.

Generally, using [H] is frowned upon, but when a whole section comprises more-or-less only tables, it seems a reasonable solution.

share|improve this answer

If you need to output the tables at a particular place, without any other things sneaking in between them, do not use floats then.

Captions can be used even without floats, if one uses \captionof from the caption package. See also this question Label and caption without float

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.