# Figures next to each other

I am trying to get two figures next to eachother withing some writing, and LaTeX keeps moving one underneath to the next page. This is my code:

\begin{figure}[h]

\includegraphics[width=8cm]{SIR2.pdf}
\caption{p=}
\label{SIRp2}

\end{figure}
shelo efeoeignregvrmbkr bkmtbpgk bgk bkgbg \\ \\

\begin{figure}[h]

\includegraphics[width=8cm]{SIR3.pdf}
\caption{p=}
\label{SIRp3}

\end{figure}

• Welcome to TeX.SX! Of course LaTeX does this way, since they float away – user31729 Mar 15 '15 at 11:23
• Using an option [h] greatly increases the chance that the float will go to the end of the document. Normally latex warns and changes it to [ht] to give itself a chance. [h] means not at top of page, not at bottom of a page and not on a float page, which means that the float is allowed almost nowhere. – David Carlisle Mar 15 '15 at 11:34

Unless you're working with an unusually wide paper size (or if the page margins are unusually narrow), fitting two 8cm-wide images next to each other simply isn't feasible. Instead of specifying an absolute width for the images, I suggest you select a relative width, such as 0.45\textwidth. Doing so will leave some whitespace -- in the amount of 0.1\textwidth -- between the images.

The horizontal line in the screenshot below is there just to illustrate the width of the text block.

\documentclass{article}
\usepackage[demo]{graphicx} % omit 'demo' option in real document
\begin{document}
\hrule  % just to illustrate width of text block
\begin{figure}[h]
\begin{minipage}[t]{0.45\textwidth}
\includegraphics[width=\linewidth]{SIR2.pdf}
\caption{p=} \label{SIRp2}
shelo efeoeignregvrmbkr bkmtbpgk bgk bkgbg
\end{minipage}
\hfill
\begin{minipage}[t]{0.45\textwidth}
\includegraphics[width=\linewidth]{SIR3.pdf}
\caption{p=}\label{SIRp3}
\end{minipage}
\end{figure}

\end{document}