Possible Duplicate:
Two figures side by side
Subfigures placed horizontally
I want to place two figures side by side in my document. I am using the subcaption package and my code is as follows
\documentclass[a4paper, 12pt, notitlepage]{report}
\usepackage{amsfonts} % if you want blackboard bold symbols e.g. for real numbers
\usepackage{graphicx} % if you want to include jpeg or pdf pictures
\usepackage{amsmath}
\usepackage{chngcntr}
\usepackage{wrapfig}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}[h]
\centering
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=0.4\textwidth]{tworoundgameeffortvaryingmujnegative}
\caption{J=-1}
\label{fig:tworoundvarymujnegative}
\end{subfigure}
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=0.4\textwidth]{tworoundgameeffortvaryingmujpositive}
\caption{$J=1$}
\label{fig:tworoundvarymujpositive}
\end{subfigure}
\caption{Effort levels in round one and two with varying $\mu$. $\alpha=1$, $v=0.25$ and $w=0.25$}
\label{fig:effortlevelsvarymu}
\end{figure}
\end{document}
For some reason my two pictures get put on top of each other. Does anybody know why this may be the case?
\end{subfigure}%for the first subfigure. See http://tex.stackexchange.com/a/37597/4427 – egreg Jan 10 '13 at 19:13.5\textwidthto each figure. Unfortunately this not always adds1\textwidth, due to rounding errors or other skips (for example newlines which are seen as spaces by tex). Better give some margin for error using.49\textwidth– JLDiaz Jan 10 '13 at 19:14\hfuzz. – yo' Jan 10 '13 at 19:15\end{subfigure}%(note the ending%) allows one to use.5\textwidth:) – cmhughes Jan 10 '13 at 21:28