Use the placement options: h, t, b and p. For example
\begin{figure}[htb]
causes LaTeX to try to fit the float “here”, or at the “top” of the current page (or the next page), or at the “bottom” of the current page (or the next page). If “p” is specified, it will allow the float to take a whole page to itself. You can’t specify only “h” as that is too restrictive, and LaTeX will automatically change it to “ht”. The default setting is “tbp”.
One of the reasons that the floats won’t go where you want them is that there are a lot of constraints on where they can go. The main ones are
CounterDefault
topnumbermaximum number of floats at top of page2
bottomnumbermaximum number of floats at bottom of page1
totalnumbermaximum number of floats on a page3
Command
\topfractionmaximum fraction of page for floats at top0.7
\bottomfractionmaximum fraction of page for floats at bottom0.3
\textfractionminimum fraction of page for text0.2
\floatpagefractionminimum fraction of floatpage that should have floats0.5
These can all be changed individually. But it is often easier to add ! before the placement options, thus forcing LaTeX to ignore most of these contraints. For example, I often use
\begin{figure}[!htb]
If you want to change the defaults, the following values give reasonable results:
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.85}
\renewcommand{\textfraction}{0.15}
\renewcommand{\floatpagefraction}{0.7}
The \clearpage command starts a new page and inserts all floats that have not yet appeared before continuing. This can leave a bad page break, so a useful alternative is to use the afterpage package, and then insert
\afterpage{\clearpage}
which will put all the floats at the end of the current page.
A very useful package is placeins. This provides the command \FloatBarrierwhich causes all unprocessed floats to be processed at that point, but does not start a new page unless it is necessary. To keep floats in the sections in which they were included, use
\usepackage[section]{placeins}
This silently puts a \FloatBarrier command before each section. There are other options explained in the placeins documentation.
Another useful package is flafter. This causes floats to always appear after their placement in the document.
If you really don’t want LaTeX to move your float at all, then use the float package with the command \restylefloat{figure} in the preamble. This allows you to specify [H] as the position parameter which means “Here and only Here”. However, this often gives bad page breaks.