Add Text After a Second Figure [duplicate]

I am simply trying to have two figures in one section on one page with text in between. In the below example the PDF result is text1, picture1, text2, text3 which is not what I intended.

Text1

\begin{figure}[h!]
\includegraphics[width=0.4\linewidth]{picture1.jpg}
\caption{A boat.}
\label{fig:boat1}
\end{figure}

Text2

\begin{figure}[h!]
\includegraphics[width=0.4\linewidth]{picture2.jpg}
\caption{A boat.}
\label{fig:boat1}
\end{figure}

Text3

Any help would be greatly appreciated!

• the only purpose of the figure environment is to allow the figures to be moved, and since you have used [h] you are preventing the figures being placed at top or bottom of the page or on a page of their own so it is quite likely that they can not be placed anywhere (you may see a warning that latex has changed this to ht to make it possible to output them somewheer) – David Carlisle Jan 17 at 13:56
• Does this answer your question? How to insert text between two figures? – naphaneal Jan 17 at 14:04
• Use \begin{figure}[H] and put \usepackage{float} in the preamble. – Henri Menke Jan 17 at 18:15

As @DavidCarlisle has already pointed out in a comment, you're not using the figure environments as they were intended to be used.

Since you apparently don't want the graphs to "float" (in the LaTeX-specific sense of the word), you'd be better off encasing the \includegraphics directives in center environments.

\documentclass[demo]{article}  % remove 'demo' option in real document
\usepackage{caption}  % for \captionof macro
\usepackage{graphicx} % for \includegraphics macro
\begin{document}

Text1

\begin{center}
\includegraphics[width=0.4\linewidth]{picture1.jpg}
\captionof{figure}{A boat.}
\label{fig:boat1}
\end{center}

Text2

\begin{center}
\includegraphics[width=0.4\linewidth]{picture2.jpg}
\captionof{figure}{Another boat.}
\label{fig:boat2}
\end{center}

Text3

\end{document}