# How can I make a graphic appear underneath the \subsection it is inserted under? [duplicate]

Possible Duplicate:
Keeping tables/figures close to where they are mentioned

I have a .tex document which generates a several paged .pdf document. I have inserted several images of charts / graphs into the document like this:

\section*{section header}

\begin{figure}[htbp]
\centering
\includegraphics{C:/Documents/Samples/image 1.png}
\caption{A caption}
\label{fig:reference}
\end{figure}


What this produces in my multi-paged document is that the image appears on its own page and the section header and sub section header appear after the image despite being inserted before the image in the .tex document.

When I test this out as in a sample document:

\documentclass{article}
\usepackage{graphicx}
\usepackage{grffile}
\begin{document}

\subsubsection*{(i)}

\begin{figure}[htbp]
\centering
\includegraphics{C:/Documents/Samples/image 1.png}
\caption{A caption}
\label{fig:reference}
\end{figure}
\end{document}


I do not get this problem. It only seems to occur in my multi-paged document when the image is inserted either side of pages that would otherwise be filled with text.

The images have been inserted using the Insert > Picture option in TeXnicCenter toolbar.

Is there a way to make the graphic appear after the relevant section and subsection and not on its own page before the section and subsection?

-

## marked as duplicate by Marco Daniel, lockstep, egreg, Gonzalo Medina, CaramdirSep 25 '11 at 19:57

The {figure} environment is floating, which means that TeX looks for the best possible placement in a typographical sense. So if you don’t want your image to float don’˝ put it in a float environment.
Use a {minipage} instead of {figure} and \captionof{figure}{<your caption text>} form the caption package.
@Aesir: Fine that it helps, but consider the linked/related question for other ways (e.g. float option [H] from float package) too … –  Tobi Sep 25 '11 at 14:03