3

I am using TeXnicCenter with MiKTeX and the compiler that I am using is XeLaTeX to Pdf. I am having a problem with the placement of figures. That is, even when I use the \usepackage{float} and the placement specifier h, the figures tend to fly around. Even though, I am using the correct code, it doesn't work. It works in TeXStudio but not in TeXnicCenter. Does anybody have a solution?

Mensch
  • 65,388
snakey
  • 41
  • I'm not sure what exactly you mean by figures tending to fly around. :-) However, since you mention you're using the float package, you could use its [H] location specifier to force LaTeX to place the float right where it's encountered. The only exception occurs if there's not enough space left on the current page to insert the float; in such cases the float will be placed at the top of the following page, and there will be a gap at the bottom of the page where the [H] float specifier was encountered. In general, it's therefore best to leave float placement to LaTeX until the very end. – Mico Jun 17 '13 at 13:02
  • 1

1 Answers1

3

I think we have seen many answers concerning figure placements, you may want to use the search function. But since you asked a particular question....

The float package provides the option to not float floating-environments at all. but the optional parameter is not h, it is H

\begin{figure}[H]
...
\end{figure}

I strongly recommend you not to use this often. Floating environments like figure and table move in the text specifically to increase readability and to avoid large white gaps in your document.

Of course I understand that especially in technical documents you want to keep figures close to the text where they are described. For me a combination of

\begin{figure}[!htb] works well for most figures. Further I use the placeins package. It has a command \FloatBarrier which forces figures and tables to appear at the point of the command at the latest. I use this when I want to keep figures within a certain section. You can also load \usepackage[section]{placeins} if you walways want to keep figures in their section. I found, however, that the odd \FloatBarrier command works better for me rather then having a rigorous restriction to sections.

Martin H
  • 18,164