\subsection{First} \index{First}
Some text of first subsection.
\begin{figure}[!htb] %[hbtp]
\centering
\noindent\makebox[\textwidth]{\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{images/a.pdf}}
\caption{Some description}
\label{a}
\end{figure}
\subsection{Second} \index{Second}
Some text
For some reason, the figure / image I want to implement appears in the second subsection, even though it's been declared at the end of the first subsection.
Other posts suggested using [!htb] which didn't help.
Thanks!
[!htb]makes it more likely that the figure floats further away as it prevents the figure being placed on a float page (no p) but you can use theplaceinspackage to stop floats going past a\section– David Carlisle May 09 '18 at 15:54\usepackage[section]{placeins}to my main file, but that didn't have any affects on the figure. – user3367856 May 09 '18 at 15:56\sectionbut if you have an error in your code you need to provide a complete document fromdocumentclassto\end{document}so people can debug, (you can useexample-imageas the image as that is available for testing – David Carlisle May 09 '18 at 15:58[section]stops floats going past\sectionbut you show\subsectionso you would need\FloatBarrier(or simply\clearpage) before the\subsection– David Carlisle May 09 '18 at 16:02