2

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}
Peck3277
  • 123
  • 2
    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 – David Carlisle Mar 04 '20 at 21:35
  • 1
    Please provide complete, compilable small document which reproduce your problem. From your code fragment we cant say anythivh what you doing wrong. – Zarko Mar 04 '20 at 21:36
  • 1
  • 1
    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 https://www.ctan.org/pkg/caption – Fran Mar 04 '20 at 21:45
  • I have updated the question with the basic layout of the document I am writing. Hopefully that will help debug the problem – Peck3277 Mar 04 '20 at 21:47
  • 1
    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) – David Carlisle Mar 04 '20 at 21:49
  • 1
    Oh if you change the image to example-image you will see in the log and terminal AED endfloat: that is your document class is enforcing a journal style that has all figures at teh end, so it is by design. – David Carlisle Mar 04 '20 at 21:52
  • 1
    Change the first line to \documentclass[letterpaper,man,natbib, floatsintext ]{apa6} – Fran Mar 04 '20 at 21:53
  • Thank you everyone. The cause was as you said @DavidCarlisle and the code snippet Fran provided did the trick. If you want to add the answer below I'll mark it as correct. – Peck3277 Mar 04 '20 at 21:56

1 Answers1

4

You are using apa6 document class which enforces the house style of the APA.

The class manual (texdoc apa6) says in section 5.2 Float Placement :

The 6th Edition requires that tables and figures (in that order) be placed after the references but before the appendices.

That is, in this document class the float placement option is ignored and figures are always inserted at the end.

However the class has a [floatsintext] option to over-ride this in manuscripts.

David Carlisle
  • 757,742