Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Figures all over the show in latex in overleaf

I am having issues with a report I am writing. First time using latex and after getting some help on here regarding some tables weirdness I again have a silly frustrating issue. Figures don’t stay where I put them. I made a MWE Posted Below

\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {./Figures/} }

%%%%%% Referencing %%%%%%
\usepackage{natbib}
\bibliographystyle{abbrvnat}
\setcitestyle{authoryear,open={(},close={)}}

\title{MWE}

\begin{document}

\maketitle

\section{Introduction}
The average sea surface temperature (SST) trend is shown in Figure \ref{fig:SST}.
\section{Figures}

\begin{figure}
  \includegraphics[width = \linewidth]{Figures/SST.png}
  \label{fig:SST}
\end{figure}
\section{References}
\bibliography{References.bib}
\bibliographystyle{agsm}
\end{document}

I expect, probably an error, for the figure to be inserted under the Figures subheading however it appears on the next page after references. I have to refer to my figure in the text, hence the \ref{fig:SST} so it is clickable. It’s not a size issue as there is more than enough space on the page to accommodate the figure. Even if that was the issue I would expect the references subheading to be after it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Most latex classes use so called floats for figures, tables etc. The idea is that latex will automatically find a good place for your images and avoid ugly white space.

To make use of the abilities of latex to produce a good looking output, you must specify possible placements with floating specifier such as [htbp], which allows latex to place the image here, at the top, at the bottom or an a separate page.

Also if you want to use the \label\ref mechanism, your figure must have a caption (and the label inside or after the caption).

\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {./Figures/} }

%%%%%% Referencing %%%%%%
\usepackage{natbib}
\bibliographystyle{abbrvnat}
\setcitestyle{authoryear,open={(},close={)}}

\title{MWE}

\begin{document}

\maketitle

\section{Introduction}
The average sea surface temperature (SST) trend is shown in Figure \ref{fig:SST}.
\section{Figures}
\begin{figure}[htbp]
  \includegraphics[width = \linewidth]{example-image-duck}
  \caption{test}
  \label{fig:SST}
\end{figure}
\section{References}
\bibliography{References.bib}
\bibliographystyle{agsm}
\end{document}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading