Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by cmhughes, diabonas, Andrew Swann, tohecz, Martin Schröder Jan 10 '13 at 23:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
This is a very common problem; write`\end{subfigure}%` for the first subfigure. See tex.stackexchange.com/a/37597/4427 –  egreg Jan 10 '13 at 19:13
    
you give .5\textwidth to each figure. Unfortunately this not always adds 1\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
1  
@JLDiaz Rounding errors don't play role in this case, due to \hfuzz. –  tohecz Jan 10 '13 at 19:15
    
@Alex Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  tohecz Jan 10 '13 at 19:16
    
@JLDiaz No, it's definitely not a rounding error problem, but it is due to the space caused by the new line. –  egreg Jan 10 '13 at 19:17