Take the 2-minute tour ×
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.

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?

share|improve this question
    
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. –  David Carlisle Apr 27 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? –  Esteban Crespi Apr 27 at 22:17
1  
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. –  David Carlisle Apr 27 at 22:29

1 Answer 1

up vote 2 down vote accepted

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, in order to move a float to a previous page you need to make sure the environment is seen by TeX in the source file before the page is shipped out. TeX does not hold the whole document in memory, or even read the whole input file, it reads the file line by line and ships out pages as soon as possible.

share|improve this answer

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.