# Setting the line length for caption

I am trying to use subfigure to put two figures beside each other and unfortunately LaTeX puts them to the right. I used hspace to reduce the space between them and that results in messing up the captions. So I thought the solution might be to change the length of line that makes the caption line break automatically.

\begin{figure}[~hbt]
\subfigure[Nonuniform distribution of points on sphere when the $n$-spherical coordinates are uniformly chosen from related intervals]
{
\includegraphics[scale=0.4]{sphere}
}
\hspace{-3em}
\subfigure[Nonuniform distribution of points on cube when the points on left figure has been transformed using the mentioned diffeomorphism]
{
\includegraphics[scale=0.4]{cube}
}

\end{figure}


Any other solution is welcomed as well.

• The problem is the width of them. Replace scale=0.4 by width=.45\linewidth and use \hfill between them. – Sigur Jan 14 '14 at 20:38

Here is a solution using the subcaption package (the subfigure package is deprecated).

\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\begin{document}
\begin{figure}[hbt]
\begin{subfigure}[t]{.45\linewidth}
\centering
\includegraphics[scale=0.4]{sphere}
\caption{Nonuniform distribution of points on sphere when the $n$-spherical coordinates are uniformly chosen from related intervals}
\end{subfigure}
\hspace{.06\linewidth}
\begin{subfigure}[t]{.45\linewidth}
\centering
\includegraphics[scale=0.4]{cube}
\caption{Nonuniform distribution of points on cube when the points on left figure has been transformed using the mentioned diffeomorphism}
\end{subfigure}
\caption{Caption for the overall figure}
\end{figure}
\end{document}


• Nice. IMHO it would be better to use .45 instead of .5. So we get a space. – Sigur Jan 14 '14 at 20:43
• @Sigur You won't get space in between the two subfigures, because they are centered automatically and the caption stretches over the whole width. You need to manually \hspace{...}. – Henri Menke Jan 14 '14 at 20:46
• @Sigur See my updated answer. – Henri Menke Jan 14 '14 at 20:48