Help

How can I get my table or figure to stay where they are, instead of going to the next page?

Usually with \begin{figure} or \begin{table} i.e. floats, the default placement identifier is [btp], which means LaTeX is allowed to place the figure at the bottom of the page/column; top of the page/column; or if the float is quite tall (including the caption), all on its own on a float page without any text. This follows conventions of professional typesetting and publishing (i.e. what TeX was created for), where "floating materials" such as figures and tables are only allowed at those locations: they are deemed to interrupt the reading flow, if they were placed in the middle of a page.

We can still influence where we'd like the figure to appear, though. If you add [hbt!] after the \begin{figure}, like this:

\begin{figure}[hbt!]

this then tells LaTeX to place the image right here (as close to the position in the source code as possible); or if that's not possible (e.g. it's too large to fit on the current page) at the top of the next page, or bottom of the next page. The exclamation mark ! is important: it tells LaTeX "please really respect my choices here".

However, if your figure is quite tall and there is not enough space on the current page (e.g. if it's already near the end of the current page), then the figure will still be moved to the top of the next page. In this case you might try moving your \begin{figure}[hbt!]...\end{figure} code a few paragraphs earlier in the code, where there is still more available on the current page at that point.

If that still doesn't work, and your figures/tables have then floated on ahead to appear after the next \section heading, you may prefer them to still appear at the end of the current section. You may then issue a \clearpage before the next \section to insert a pagebreak, which will also output all floats in the queue, before the next \section heading is printed on a new page.

Alternatively, have a look at the placeins package, where you can add \FloatBarrier before the next \section—or automate this by using the section package option, i.e. write \usepackage[section]{placeins} in your preamble.