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 have 5 tables and a section after them. After creation of an output file I have two tables on one page, then a section and last 3 tables on next page.

What I want to achieve is to put tables and section below them.

\begin{table}[ht]\footnotesize
\centering
\begin{tabular}{|ll|}
......
\end{tabular}
\label{tab:result}
\end{table}

\section{Section below tables}
share|improve this question
add comment

4 Answers

up vote 21 down vote accepted

You can use the \FloatBarrier macro from the placeins package. This prevents floats from floating across the barrier. Alternatively, you can use the section option to that package to prevent floats from leaving the section.

share|improve this answer
    
I've used \usepackage[section]{placeins} and \FloatBarrier and tables are in fact above section. The side effect is that last 3 tables that have only one row each, take whole page... Do you have any idea how to avoid this? –  pixel Oct 29 '10 at 20:37
    
@pixel: You can try using \FloatBarrier in the places you don't want the floats to cross without using the [section] option. But without an example of what's going wrong, I can't really say. –  TH. Oct 30 '10 at 2:16
add comment

The easiest way is to use the placeins package:

\usepackage[section]{placeins}
share|improve this answer
add comment

or you can change \begin{table}[ht] to \begin{table}[H] and add \usepackage{float} to your preamble. the H means "absolutely do not float this, and put it right here."

share|improve this answer
    
I continue to be baffled why this option is popular. I guess people who like to write "Here are our results:" and want the table right there. But, still, it's a perfectly good solution in this case. –  Will Robertson Oct 29 '10 at 1:11
1  
@Will Robertson: My guess is people are so frustrated with LaTeX generally terrible float placement that they want to just say, "put it here, dammit!" One interface that I'd like is a way to say, "put this figure on page x", "put that figure on page x", "put this other figure on page y" and have LaTeX do exactly that: stack the first two figures on page x, and the third on page y. When I get into this position, I tend to move floats into their own files and then \input them and just move the location of the \input statement until LaTeX gives me what I want. It is suboptimal. –  TH. Oct 29 '10 at 3:37
1  
@TH., @Will Robertson: When I was still working with latex (a decade ago), float placement was also one of my major headaches always. The problem with [H] and [!h] was then that you end up having to add a gazillion of them just to prevent the float numbering from going out of order (table 5 appearing before table 4). A very nice feature in ConTeXt is that it automatically renumbers the floats in such a case. Is something like that also possible in latex these days? –  Taco Hoekwater Oct 29 '10 at 6:58
2  
@Taco: Not that I'm aware of, although Will would undoubtably know more. The LaTeX 2e kernel is perfectly willing to place figure 5 before figure 4 by default if one of them is a single column float and the other is a two column float. (In fact, a paper I was proof-reading for someone today had exactly this problem.) The fix is to use the fixltx2e package, but that just ensures the floats go in order; it doesn't renumber them if they're out of order. –  TH. Oct 29 '10 at 7:06
    
I agree, the H option is pretty brute force, however, I write tech doc in latex for my company (I'm pretty happy they use it!) but I always have a ton of floats, and apparently it's too much to ask the user to turn the page to look at a table or figure. My company hates the htbp and I am forced to use H. But it does exactly what it's supposed to, and is pretty reliable, even if it leaves some suboptimal layouts. –  Mica Oct 29 '10 at 19:40
show 1 more comment

If you're using memoir, it includes functionality from placeins. It allows you, for example, to do this:

\setFloatBlockFor{section}

which is equivalent to \usepackage[section]{placeins}

share|improve this answer
add comment

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.