# Insert image in latex [duplicate]

Possible Duplicate:
Force figure placement in text

Hi! I'm trying to insert an image in latex with some text around:

Here is our image:
\begin{figure}[h!]
\centering
\includegraphics[width=0.5\textwidth]{idefA0.jpg}
\caption{IDEF0}
\end{figure}
Here is some text!


I'd like to insert image and 'Here is some image' on the same page, but when i'm trying to compile pdf I get: Warning! !h changed to !ht and places an image on the next page, and here is some text goes right after Here is some image

-

## marked as duplicate by Jake, lockstep, Caramdir, Seamus, Stefan Kottwitz♦Mar 24 '11 at 18:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

The float package with the [H] placement option should help: tex.stackexchange.com/questions/8625/… – Jake Mar 24 '11 at 16:24
no, it doesn't help, i've already tryied all flags=\ – user4418 Mar 24 '11 at 16:29
In that case, can you please post a full minimal example, including the preamble (so starting from \documentclass) that shows the described behaviour? – Jake Mar 24 '11 at 16:30
You can edit your original question to include the preamble. Note that, in order to use the [H] option to place the image, you need to add the line \usepackage{float} to your preamble. – Jake Mar 24 '11 at 16:38
@Jake,Stefan: I'm actually in favor for closing it as duplicate of Force figure placement in text. It is basically the same. Ok, here the main point is the placement of some text relative to the float and the other question is about placing the float at a certain position, which isn't 100% the same. Anyway, the answer(s) there answer this question as well. (I'm just added an answer by myself to remind people that figure can also include text.) – Martin Scharrer Mar 24 '11 at 17:02

## 1 Answer

Note that you can place text (and any other material in general) into the figure environment together with the actual image.

So you could write:

\begin{figure}[h!]
Here is our image:
\centering
\includegraphics[width=0.5\textwidth]{idefA0.jpg}
\caption{IDEF0}
\end{figure}


You have to check the spacing between the text and image by yourself, e.g. by adding a \par\medskip between them.

If you want to place your image in a certain position in your text you shouldn't use a floating environment (or you can use the [H] option as Jake mentioned).

You can write (using the caption package):

Here is our image:
\begin{center}
\includegraphics[width=0.5\textwidth]{idefA0.jpg}
\captionof{figure}{IDEF0}
\end{center}

-