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.

Using \clearpage or \newpage will work sometimes or will ensure that the figure stays in the same section, but I cannot always get the heading of a subsection and the introduction to it to appear before a data table/graphic etc. Is there any particular package or formatting that should be included to ensure that the order I write it in will be the same it is compiled in?

share|improve this question
    
I'm not quite sure what you want: Maybe tex.stackexchange.com/questions/279/…? –  Caramdir Mar 15 '11 at 17:53
    
Welcome to tex.sx! This question might be of interest to you. –  lockstep Mar 15 '11 at 17:54
    
@Caramdir: I can get the tables, etc in the same section however can't ensure that If I write the section heading and maybe an intro to the table before I write the table in the tex doc that it will appear before the table in the compiled pdf. Getting them into the same section isn't the problem. –  user4245 Mar 15 '11 at 18:00

2 Answers 2

You can use the flafter package, which ensures that a floating object only appears after its definition in the code.

share|improve this answer

It sounds like you are forcing LaTeX to place floats (figures and tables) when you should be using its own float-placing algorithms. Use an optional argument to make recommendations to that algorithm.

\begin{figure}[h] % to place "here"
% stuff ...
\end{figure}

You can also use t for "top of the next page", b for "bottom of the next page, or p for "on a separate page of floats only". You can give preferences like [ht] for "here, but if not possible on the top of the next page." You can use an exclamation point to make more urgent recommendations.

See also `h' float specifier changed to `ht' warning when not attempting to specify a float, in which Stefan gives a good answer describing float placement in general.

share|improve this answer
    
Thanks for responding quickly. I have used htbp and while it moves the table or figure to a different place on the page, it does not fix the problem of getting my heading above the figure. In some cases, it pushes it to the next page or just leaves it where it is. For example: I'm using the code \subsection{Data 1:Flipped Magnetic Field} \begin{table}[htbp] and the table appears before the subsection heading. The location of this is near the end of a page. –  user4245 Mar 15 '11 at 18:08
3  
@katrijnn, putting a float immediately after a (sub)section heading effectively leaves the heading "adrift". if you add the text of the paragraph that follows the heading before the floating object, that almost always works better. (this is most effective if the text of the paragraph is rather short.) –  barbara beeton Mar 15 '11 at 18:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.