sometimes im in trouble with my images. Because if there is no space on one page, the images is getting printed on the next page. Thats fine, but if I write a text after the image on the pdf the text is before the image.

Something like this:

\begin{figure}[htb]
\centering
\includegraphics*[width=1\textwidth]{myimage.pdf}
\caption{\em Description}
\label{fig:myimage}
\end{figure}
\hspace{0pt}
\\
MyText. But this text appears sometimes before the image and not after how it should be.

I saw this question. People are explaining h,t,b but its not helping me. How can I solve this problem? Thank you

Edit: I could solve this problem with adding a lot of new lines, something like this:

the figure is a floating environment which means that latex can move it to a suitable point in the document to achieve good page breaks as is traditional in publishing. If you do not want the figure to move the easiest thing is to load the float package and change htb to H which means PUT IT HERE then latex will not move it
–
David CarlisleOct 2 '12 at 12:08

@DavidCarlisle ah now I get it. So h != H, because I was trying h an it did not change anything. Basically "H" is always the best thing I can do right? Dont understand why would I use the other one, with htb Im just getting in trouble.
–
KlausOct 2 '12 at 12:14

3

Also, don't use \\ to force vertical white space and don't use the two letter font commands like \em which are only for compatibility with the pre-1993 LaTeX 2.09 system. It is best to avoid formatting command in captions at all, the class should determine the style used for captions (the caption package can help you define that)
–
David CarlisleOct 2 '12 at 12:15

3

No!!!! H is almost always a REALLY BAD IDEA (I was the first one to implement H so I can say that with some authority:-) figures are big unbreakable blobs and if you include one mid page with H then the only thing latex can do is leave that page short with a big white gap and move everything to the next page. Real printers would never do that that is why articles have figures as referenced items so that the printer can put them in a good place and the text can refer to it by reference.
–
David CarlisleOct 2 '12 at 12:17

1 Answer
1

If you really need to stop LaTeX moving the figure then use the float package and

\begin{figure}[H]

Note that using H is more or less equivalent to not using a figure at all and just placing the graphic and caption in a full width minipage. (The caption-of package will allow you to caption such non-floating environments).

However it is almost always better to allow the figure to move and use the \label\ref mechanism to refer to it by number in the text, that allows LaTeX to find much better page breaks. To achieve this do not use an optional argument at all, or if you want to allow figures mid-page if they will fit then use

\begin{figure}[htbp]

Always include at least p in such an optional argument otherwise you increase the chance that LaTeX can not find anywhere to place the figure. The full details of the figure placement (perhaps more details than you want initially) are in Frank Mittelbach's description.