# Placing the floats in the current page or in the previous page

I would like the floats to appear, if possible in the top (or bottom) of the same page where they are defined, or in the bottom of the previous page otherwise (or wherever it fits as near as possible if it doesn't fit in the previous page).

The problem is that LaTeX sends usually the figure to the top of the next page, instead of placing it in the top or bottom of the current page, in the next example I would prefer that LaTeX placed the figure in the first page, even if the place where it is defined is sent to the second page.

\documentclass{article}
\usepackage[a6paper]{geometry}
\usepackage{lipsum}
\begin{document}
First: \lipsum[1]
\begin{figure}[tb]
\begin{tabular}{l|l}
\hline
a & b \\ c & d \\ e & f \\ g & h \\
\hline
\end{tabular}
\caption{some figure}
\end{figure}
Second: \lipsum[2]
\end{document}


What I am looking for is somewhat for the opposite of the package flafter: make figures appear either in the current page or before. Is there a way to enforce this behaviour?

• floats can not go backwards, once a page is output it has gone from TeX's memory, a float found on the next page can not affect it. Apr 27, 2014 at 22:10
• I didn't know. But can it be given more priority'' than normal text? in the sense that the text is pushed to next page to leave place for the float? Apr 27, 2014 at 22:17
• but unless you move the float back in the source file the page is output before tex even knows there is a float. Once the float is seen then it can affect the page breaking on that page. TeX does not hold the document in memory it tries to hold not much more than one page at a time. Apr 27, 2014 at 22:29