# Figure keeps going to the end of the document

I'm able to include an image where I want if I use the following code

\section{foo}
...content
\includegraphics[width=\textwidth]{images/blockchain.png}
...more content


However I'd like to have a caption for my image so I have replaced the includegraphics with the following

\begin{figure}[!htbp]
\centering
\includegraphics[width=\textwidth]{images/blockchain.png}
\captionsetup{justification=centering}
\caption{An illustration of blockchain (own image)}
\label{fig:blockchain}
\end{figure}


When I do this the image goes to the bottom of the entire document, after the references.

I've tried a few different positioning parameters with no lock. I also tried to include the float package and a [H] parameter.

Ideally I'd like to keep it where I put the block but even if it was within the section I'd be happy.

I'm using overleaf if that has any bearing.

Edit Below is the structure of my document

\documentclass[letterpaper,man,natbib]{apa6}
\usepackage[natbibapa]{apacite}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}

\title{title content}
\shorttitle{short title content}
\author{name}
\affiliation{foo}

\begin{document}

\maketitle

\section{Introduction}
paragraph

paragraph

\section{How blockchain works}

paragraph

\begin{figure}
\centering
\includegraphics[width=\textwidth]{images/blockchain.png}
\caption{An illustration of blockchain (own image)}
\label{fig:my_label}
\end{figure}

paragraph

\section{Applications}
\subsection{s1}
paragraph
\subsection{s2}
paragraphon{The role of blockchain in Smart Contracts}
Role

\bibliography{ref}
\bibliographystyle{apacite}

\end{document}

• the only reason to use figure is to allow it to be moved, so moving isn't that much of a surprise (it will not move if you use [H]) but without a test document it is impossible to debug why it moves to any place as it depends on so many factors not shown Mar 4 '20 at 21:35
• Please provide complete, compilable small document which reproduce your problem. From your code fragment we cant say anythivh what you doing wrong. Mar 4 '20 at 21:36
• The symptom is that LaTeX cannot place that figure in any of the previous pages for some reason (too many tables, for instance), but without a MWE showing what is wrong is not possible to give you a clue to make it right, except that you can use captions without floats with the help of some packages. See ctan.org/pkg/caption
– Fran
Mar 4 '20 at 21:45
• No sorry it does not help at all, as the positioning of the figure depends on the actual size of the images, the amount of text that needs to be on the page, the document settings etc, so you need to make an actual document that we can run that shows the problem (you can use example-image as the image as it is available for tests like this) Mar 4 '20 at 21:49

The class manual (texdoc apa6) says in section 5.2 Float Placement :
However the class has a [floatsintext] option to over-ride this in manuscripts.