I want to insert figures between text just like this:
So I use the following code:
**
\begin{document}
Text here.
\begin{figure}
\centering
\begin{subfigure}[!h]{0.3\textwidth}
\includegraphics[width=\textwidth]{graph01.png}
\caption{A tree.}
\end{subfigure}
~
\begin{subfigure}[!h]{0.3\textwidth}
\includegraphics[width=\textwidth]{graph02.png}
\caption{Petersen's graph}
\end{subfigure}
\caption{Examples of a graph}
\end{figure}
Text here again.
\end{document}
**
The image was not exact in the position where I want it to be. Instead, the image is placed on another page. How can I change that?

[htb]tofigureenvironment, like\begin{figure}[htb]. if between paragraphs will be enough place, figures will appear there. – Zarko May 22 '18 at 19:28figureenviornment is to allow it to be moved in that way. If you use\includegraphicsdirectly it is not moved. – David Carlisle May 22 '18 at 19:41\includegraphicscommand in acenterenvironment. If, in addition, you want to caption the figure, you can do so by means of thecaptionpackage and its\captionofcommand. An alternative solution is to load thefloatpackage and use theH(capital) placement specifier. – GuM May 22 '18 at 23:46