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.

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!

share|improve this question
    
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 Aug 25 '12 at 19:48
    
@Noah Thanks for sharing that. Yes, I believe this is a common issue for plenty of LaTeX users. –  AD. Aug 26 '12 at 7:21

2 Answers 2

up vote 16 down vote accepted

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.

share|improve this answer
    
@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! –  AD. Sep 17 '10 at 9:42
1  
@AD. If [H] placed the table on a new page, you did something wrong. Perhaps you forgot to load the float package? –  Konrad Rudolph Sep 17 '10 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. –  barbara beeton Sep 17 '10 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? –  Konrad Rudolph Sep 17 '10 at 16:31
    
i've skimmed enough of the float package documentation (texdoc float) to determine that some internal macros are redefined. i don't have enough time to compare the code (or, more likely, run a debugging session on a small example) to determine the actual differences, but i do suspect that the effects are not quite identical with respect to penalties and spacing, which might be just enough to make a difference. still a puzzlement. –  barbara beeton Sep 17 '10 at 18:17

To quote the FAQ (http://www.tex.ac.uk/cgi-bin/texfaq2html?label=floats) "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.

share|improve this answer
    
@Ulrike Fischer: Thanks, I don't have enough rep to up vote your answer. But it was helpful! –  AD. Sep 17 '10 at 9:43
    
+1 Now, three year later, I have enough reputation to up vote. Thank you once more. –  AD. Sep 26 '13 at 20:13

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.