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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 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
up vote 23 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:

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  
+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.
http://tex.stackexchange.com/questions/3189/why-is-my-table-displayed-at-the-top-of-the-page
tex.stackexchange.com
crawl=CC-MAIN-2016-07
84981
application/http; msgtype=response
sha1:VWHDJ4XZZIOIPRCPT7NFV2F2RAAHX6Z7
<urn:uuid:91db86aa-1f04-413f-a26d-c49b0c0a6c66>
2016-02-08T00:23:28Z
104.16.118.182
sha1:PXF5TJWBIK7SWR5LGRW7HCUMXBGHPEEL
<urn:uuid:286ecd05-035e-4db7-a73c-5b12980a06a4>
http://tex.stackexchange.com/questions/3189/why-is-my-table-displayed-at-the-top-of-the-page
response
<urn:uuid:44d878be-e765-421d-89fb-8cdfcf0a65d2>
robots: classic
hostname: ip-10-236-182-209.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2016-07
operator: CommonCrawl Admin
description: Wide crawl of the web for February 2016
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf