0

Possible Duplicate:
Force figure placement in text

Quite new to LaTeX so I apologize if this is a rookie/obvious error. I'm trying to include some figures in a college report I'm doing. However, the figures keep popping up all over the place. My source looks something like this:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.Curabitur convallis 
augue et nisl eleifend vitae convallis massa ultricies. Cras iaculis sem nec
turpis euismod interdum. Vestibulum eget ligula metus, sit amet pulvinar lorem.

\begin{figure}
\begin{center}
\includegraphics[scale=1]{my_graphic}
\caption{My graphic}
\end{center}
\end{figure}

Sed vulputate ligula non quam congue consectetur. Ut erat massa, lacinia sed 
mattis vitae, pretium nec quam. Pellentesque faucibus hendrerit lacinia. Sed 
in massa erat. Praesent massa mauris, dapibus at euismod at, iaculis 
eleifend nulla.

However, instead of the graphic showing up between the two paragraphs when I build it, it pops up somewhere seemingly randomly nearby. Why is it not appearing between my two paragraphs like I have in my source? Urgently need help solving this, thanks.

1
  • 2
    This has been asked several times before. Please use the search function to find previous questions that might possibly answer your question before aksing.
    – Thorsten
    Mar 21, 2012 at 17:40

1 Answer 1

0

The idea of the figure environment is that it places the graphic in a float, i.e. LaTeX determines where best to place the graphic, so that it appears at a suitable position instead of potentially destroying your page layout. If you really want to avoid this, it is easiest to simply not use a figure environment (just the includegraphics command will place the graphic there) or add the option [!h] to the environment.

I'd recommend adding a caption and a reference to the picture instead:

As you can see in \ref{mygraphic} ....

\begin{figure}
\centering
\includegraphics[scale=1]{my_graphic}
\caption{My graphic}
\label{mygraphic}
\end{figure}

That way the graphic will be placed nicely and it's still clear where it fits in your text. See also Should I use center or centering for figures and tables?

3
  • Adding [!h] as a placement specifier can do more harm than good. Mar 21, 2012 at 17:51
  • 2
    Please no answers to a question which is clearly a duplicate. Also using center is clearly wrong. Use \centering instead. This is also mentioned several times on this site already. Mar 21, 2012 at 17:59
  • @Martin Scharrer: Thank you for pointing out the fact about the center environment! I was yet unaware of it and kept blaming the vertical space on figure.
    – Jonathan
    Mar 22, 2012 at 11:10

Not the answer you're looking for? Browse other questions tagged .