Force figure placement in text

The short answer: use the “float” package and then the [H] option for your figure.

\usepackage{float}

...

\begin{figure}[H]
\centering
\includegraphics{slike/visina8}
\caption{Write some caption here}\label{visina8}
\end{figure}

The longer answer: The default behaviour of figures is to float, so that LaTeX can find the best way to arrange them in your document and make it look better. If you have a look, this is how books are often typeset. So, usually the best thing to do is just to let LaTeX do its work and don't try to force the placement of figures at specific locations. This also means that you should avoid using phrases such as “in the following figure:”, which requires the figure to be set a specific location, and use “in Figure~\ref{..}“ instead, taking advantage of LaTeX's cross-references.

If for some reason you really want some particular figure to be placed “HERE”, and not where LaTeX wants to put it, then use the [H] option of the “float” package which basically turns the floating figure into a regular non-float.

Also note that, if you don't want to add a caption to your figure, then you don't need to use the figure environment at all! You can use the \includegraphics command anywhere in your document to insert an image.


do not use a floating environment if you do not want it float.

\usepackage{caption}
...
\noindent%
\begin{minipage}{\linewidth}% to keep image and caption on one page
\makebox[\linewidth]{%        to center the image
  \includegraphics[keepaspectratio=true,scale=0.6]{slike/visina8}}
\captionof{figure}{...}\label{visina8}%      only if needed  
\end{minipage}

or

\begin{center}
  \includegraphics[...]{slike/visina8}}
\captionof{figure}{...}\label{visina8}%      only if needed  
\end{center}

One solution not mentioned by any of the other answers that just sorted me out is to use \clearpage

No special packages are needed.

\clearpage forces all figures above it in the .tex file to be printed before continuing with the text. This can leave large white spaces.

For me this was the best solution because I did not have to change any of the formatting and it just made sure that all figures were printed before the next bit of text. My issue was a part of the document with lots of figures and not much text.