LaTeX table positioning
At the beginning with the usepackage
definitions include:
\usepackage{placeins}
And before and after add:
\FloatBarrier
\begin{table}[h]
\begin{tabular}{llll}
....
\end{tabular}
\end{table}
\FloatBarrier
This places the table exactly where you want in the text.
Here's an easy solution, from Wikibooks:
The placeins package provides the command \FloatBarrier, which can be used to prevent floats from being moved over it.
I just put \FloatBarrier
before and after every table.
After doing some more googling I came across the float package which lets you prevent LaTeX from repositioning the tables.
In the preamble:
\usepackage{float}
Then for each table you can use the H
placement option (e.g. \begin{table}[H]
) to make sure it doesn't get repositioned.
Table Positioning
Available Parameters
A table can easily be placed with the following parameters:
h
Place the float here, i.e., approximately at the same point it occurs in the source text (however, not exactly at the spot)t
Position at the top of the page.b
Position at the bottom of the page.p
Put on a special page for floats only.!
Override internal parameters LaTeX uses for determining "good" float positions.H
Places the float at precisely the location in the LATEX code. Requires the float package. This is somewhat equivalent toh!
.
If you want to make use of H
(or h!
) for an exact positioning, make sure you got the float
package correctly set up in the preamble:
\usepackage{float}
\restylefloat{table}
Example
If you want to place the table at the same page, either at the exact place or at least at the top of the page (what fits best for the latex engine), use the parameters h
and t
like this:
\begin{table}[ht]
table content ...
\end{table}
Sources: Overleaf.com