##  Class files

This is when LaTeX has a problem placing your float (such as an image or figure of some kind) in the position you have specified in the float specifier i.e. the ht in \begin{figure}[ht] . LaTeX tries to place figures in a way that fits in with the flow of the text in order to avoid big gaps and bunched up paragraphs. The placement specifier parameter allows us to have a greater control over where a figure is placed. The different placement options available to us are listed below:

Specifier Permission
h Place the float here, i.e., approximately at the same point it occurs in the source text (however, not exactly at the spot)
t Position at the top of the page.
b Position at the bottom of the page.
p Put on a special page for floats only.
! Override internal parameters LaTeX uses for determining "good" float positions.
H Places the float at precisely the location in the LaTeX code. Requires the float package (\usepackage{float}). This is somewhat equivalent to h!.

While LaTeX will do its best to follow the placement we specify, it may not always be possible for it to adhere to it. When LaTeX has trouble placing our float in the desired location, it may override the placement specifier in favor of a new placement specifier which does not break up the flow of text. When this happens, an error message will appear as shown below.

 \documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\begin{document}

\section{Introduction}
\vspace{10cm}

\begin{figure}[h]
\centering
\includegraphics{image.PNG}
\end{figure}

\end{document}

This will generate an error message which looks like

main.tex, line 12

h' float specifier changed to ht'.

The float specifier h by itself is usually too strict of a command for LaTeX. To resolve this error, it is best to relax this demand to ht i.e. place the float either here or at the top of the page. The demand can even be relaxed further to htbp or !htbp if necessary.

If you would like to override this replacement and have the figure placed at a specific location in the page, there are some useful ways of doing this listed below.

Using the float package:

If we include the float package in our preamble, then instead of using h to specify here in our float specifier option, we can use the more powerful H, which will ensure the figure is kept in place.

 \documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{float}

\begin{document}

\section{Introduction}

\begin{figure}[H]
\centering
\includegraphics{image.PNG}
\end{figure}

\end{document}

Using the placeins package:

Using the placeins package, we can use the \FloatBarrier command. Wherever we put a \FloatBarrier command, a barrier will be put in place which figures cannot pass through. This means that if we put a \FloatBarrier command on either side of our figure, it will be locked in place

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{placeins}

\begin{document}

\section{Introduction}

\FloatBarrier
\begin{figure}
\centering
\includegraphics{image.PNG}
\end{figure}

\FloatBarrier
\end{document}

Tweaking the parameters:

In order to tell LaTeX to place figures within the text and not at the end of a chapter (which is default), we adjust the 'float placement' parameters in the preamble to our document. Here are some useful values.

\renewcommand\topfraction{.9}
\renewcommand\textfraction{0.35}
\renewcommand\floatpagefraction{0.8}