[Tex/LaTex] Section name appears after the wrong table


So I am writing a paper in document class article, and my section name (Appendix) appears after the wrong table.

More specifically, I have some tables in "Figures and Tables" section, and I have few more tables in Appendix section. As you can predict, there are no texts in these sections except those in tables. This is what is happening:

Preamble is

\usepackage{subcaption} \usepackage{float} 

\section{Figures and Tables}

Table 2 code is

\advance\hoffset by -2cm 
\advance\voffset by 1cm



Table 4 code is

\begin{tabular}{l  c  c  c  c }


And, table 5 code is

\begin{tabular}{l  c  c  c  c }


I want the "Appendix" to appear after table 4 but it appears after table 2. Table 2 is a landscape table (define in table_2.tex}.

When I change table 4 to landscape, then Appendix appears right after table 4 which is what I want. But I can not have table 4 in landscape as it is a long table.

Can anybody suggest how to fix it? I did try \pagebreak, \newpage and \vspace options but they didn't work. Thanks!

I used the float package, and I am used table environment with [H] option, some of the tables are still used with [htbp] option. Now Appendix appears after table 4 which is what I want. But there are two problems now. First, page after table 2 (the landscape one) is blank. And, table 4 (the one before the Appendix) is out of the page. It looks like float package has some effect here.

Best Answer

There are several methods to deal with float placement control, see the comments to the question, e.g.:

  • Comment of Ludovic C.: Package float with placement specifier H sets the floats right "here" without floating.
  • Comment of David Carlisle: \clearpage before \section{Appendix} forces the floats to be output and starts a new page.
  • My comment: \FloatBarrier of package placeins right before \section{Appendix} stops tables from floating past the appendix title.
  • If a section contains only floats without text, then floating is not really needed. The Float captions can be set without the floating environments (e.g., table) with \captionof{table} of package capt-of or the more powerful caption.