47

I figure this must be a common issue but I could not find a solution.

Here is my code:

\documentclass{article}
\begin{document}

    Text: This text should be above the table, but it is not.
    \begin{table}
        Table: This table should be below the text, but it is not.  
    \end{table} 

\end{document}

Why is the table at the top? Thanks!

2
  • 1
    This is the absolute worst thing about LaTeX. Why is [h!] even an option if it just ignores it?! This afternoon I had a report that ended with a half a page of slack, but LaTeX insisted on sticking my table at the top of the page regardless of [h!] and all the extra room. Thanks for asking, the float package suggested here fixed everything!
    – Noah
    Commented Aug 25, 2012 at 19:48
  • @Noah Thanks for sharing that. Yes, I believe this is a common issue for plenty of LaTeX users. Commented Aug 26, 2012 at 7:21

3 Answers 3

73

table is a floating environment. TeX has special rules for placing floats so that they cause minimal disruption of the surrounding text.

You can give LaTeX hints of how to place your floats. For example, to make LaTeX try to place it where you inserted it, specify the option h (for “here”):

\begin{table}[h]
    Table: This table should be below the text, but it is not.  
\end{table} 

Note that this won’t always work because LaTeX still tries to make the text look nice. Your hint is only that: a hint, not a definite command.

You can force LateX to obey your command to place a floating environment HERE by loading the package float and specifying the option H (capital letter!):

\begin{table}[H]
    Table: This table should be below the text, but it is not.  
\end{table} 

But notice that this can lead to an ugly layout.

7
  • @Konrad Rudolph♦: Thanks, I don't have enough rep to up vote your answer. But it was helpful! [h] worked fine for me but [H] was not very good at all - the table were placed on a new page - so you were right, I got a pretty ugly layout! Commented Sep 17, 2010 at 9:42
  • 2
    @AD. If [H] placed the table on a new page, you did something wrong. Perhaps you forgot to load the float package? Commented Sep 17, 2010 at 11:45
  • even if you use [H], if there isn't enough room left on the page for the table, it can go to the next page. i can't explain why [h] might fit it in, but [H] won't. Commented Sep 17, 2010 at 15:14
  • @barbara: That’s my point though: there might not be enough room, but then neither should [h] work. Or is that a mistake and [h] actually works in cases where [H] doesn’t? Commented Sep 17, 2010 at 16:31
  • 5
    +1 Now, three year later, I have enough reputation to up vote. Thank you once more. Commented Sep 26, 2013 at 20:12
14

To quote the FAQ:

Tables and figures have a tendency to surprise, by floating away from where they were specified to appear....

Read the FAQ to learn how to control the placement of your tables.

2
  • @Ulrike Fischer: Thanks, I don't have enough rep to up vote your answer. But it was helpful! Commented Sep 17, 2010 at 9:43
  • 6
    +1 Now, three year later, I have enough reputation to up vote. Thank you once more. Commented Sep 26, 2013 at 20:13
0

[h] is definitely working out. Please try it. After using this, you can keep the table beneath the sentence/paragraph.

You must log in to answer this question.

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