5

I wanted to insert two figures, one below the other, and then continue entering text after figure 2. But the text gets inserted after figure 1. Can someone please tell me what I am doing wrong? The following are the commands I used (document class is report):

\begin{figure}[h]
   \centering
    \includegraphics[scale=0.5]{figure1.png}
     \caption{this is figure 1}\label{one}
\end{figure}
\begin{figure}[h]
   \centering
    \includegraphics[scale=0.5]{figure2.png}
     \caption{this is figure 2}\label{two}
\end{figure}
sodd
  • 5,771
  • 2
    Welcome to TeX.SX! That's the concept of floats. Please provide an example that's long enough to show us your real problem to help us help you. – TeXnician May 21 '17 at 15:13
  • 2
    See this answer for an explanation of what floats are, and how they are placed. – sodd May 21 '17 at 15:13
  • 1
    You could put both images/captions in the same figure environment. I.e. just remove the \end{figure} \begin{figure}[h] \centering in the middle. But you should most likely have more placement options than just h, e.g. htp. – Torbjørn T. May 21 '17 at 15:44
  • 1
    Another way to force LaTeX to twin the two figure is to use subfig package, with a code like this \begin{figure} \centering \subfloat[][Figure label 2.] { figure1 } \end{figure} } \\ \subfloat[][Figure label 2.] { figure2 }\caption{The "two figures" caption} \end{figure}. You can use separate captions and, if you like, a global caption too. Put \includegraphics or what you need where I put figure1 and figure2. – Fausto Vezzaro May 21 '17 at 21:54

1 Answers1

7

To keep both figures together, use a single figure environment. If you want to decide on your own where images shall appear, avoid using the figure environment.

\documentclass{report}
\usepackage{graphicx}
\usepackage{blindtext}
\begin{document}
\begin{figure}[h]
\centering
\includegraphics[width=.5\textwidth]{example-image-a}
\caption{this is figure 1}\label{one}
\bigbreak
\includegraphics[width=.5\textwidth]{example-image-b}
\caption{this is figure 2}\label{two}
\end{figure}
\blindtext
\end{document}
Johannes_B
  • 24,235
  • 10
  • 93
  • 248