TransWikia.com

Why is my table displayed at the top of the page?

TeX - LaTeX Asked by AD. on April 23, 2021

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!

3 Answers

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.

Correct answer by Konrad Rudolph on April 23, 2021

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.

Answered by Ulrike Fischer on April 23, 2021

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

Answered by Akshaya Simha on April 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP