0

I'm currently writing my thesis and I'm trying to split several images under different sections.

For some reason, the images dont appear under the correct sections and instead are just placed on the page one after the other.

I wasnt sure how to reproduce a proper MWE as it relies on using my images. I have used placeholders where my images would normally be.

Please see the below MWE I have put together as an example (hope this is ok):

\documentclass[10pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{ {YourGraphicsPath/} }
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\section{Section 1}

\begin{figure}[h]
    \includegraphics{Your Image}
    \centering
    \caption{Test}
    \label{fig:Test}
\end{figure}

\section{Section 2}

\begin{figure}[h]
    \includegraphics{Your Image 2}
    \centering
    \caption{Test}
    \label{fig:Test}
\end{figure}

\begin{figure}[h]
    \includegraphics{Your Image 3}
    \centering
    \caption{Test}
    \label{fig:Test}
\end{figure}

\section{Section 3}

\begin{figure}[h]
    \includegraphics{Your Image 4}
    \centering
    \caption{Test}
    \label{fig:Test}
\end{figure}

\end{document}
  • figure (and table) are floating environments which means they not necessarily appear in the pdf exactly where you pleaced them in the input. You can influence the positioning of floats (See How to influence the position of float environments like figure and table in LaTeX?). – leandriis Mar 25 at 11:02
  • If you absolutely do not want images to float but need a caption nevertheless (however, be warned about large white spaces if an image does not fit onto the remainder of a page), you can use \captionof{figure}{...} (or \captionof{table}{...}) to add captions to images and tabulars outside of figure od table environments. – leandriis Mar 25 at 11:02
  • As a tip: You can always use \includegraphicx{example-image} to prepare a MWE. – leandriis Mar 25 at 11:06
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Alessandro Cuttin Mar 25 at 11:36
  • You could use \clearpage to flush the float queue, but that would also force sections to start an new pages. See also tex.stackexchange.com/questions/88657/… – John Kormylo Mar 25 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.