# Subfigure captions appear too close together

Is there anyway to avoid what is observed below with the subfigure captions appearing too close together?

I would rather not use the minipage environment as a solution.

\documentclass[]{article}
\usepackage{graphicx}

\usepackage{caption}

\usepackage{subcaption}
\usepackage{subfig}

\begin{document}

\begin{figure}[h!]
\begin{subfigure}[t]{.5\textwidth}
\centering
\includegraphics[width=50mm]{image1.png}
\caption{Test 1 - text filling out page so it is possible to view the how close the text regions get. I will keep going to show that in the second line.}
\end{subfigure}%
\begin{subfigure}[t]{.5\textwidth}
\centering
\includegraphics[width=50mm]{image2.png}
\caption{Test 2 - text filling out page so it is possible to view the how close the text regions get}
\end{subfigure}
\caption{Full caption}
\end{figure}

\end{document}


-
Use 0.45\textwidth and \hfill between the two subfigure environment. –  egreg May 5 at 18:00

Just use a shorter width for the subfigure:

\documentclass[]{article}
\usepackage[demo]{graphicx} % demo is just for the example

\usepackage{caption}

\usepackage{subcaption}

\begin{document}

\begin{figure}[h!]
\begin{subfigure}[t]{.45\textwidth}
\centering
\includegraphics[width=.9\textwidth]{image1.png}
\caption{Test 1 - text filling out page so it is possible to view the how close the text regions get. I will keep going to show that in the second line.}
\end{subfigure}\hfill
\begin{subfigure}[t]{.45\textwidth}
\centering
\includegraphics[width=.9\textwidth]{image2.png}
\caption{Test 2 - text filling out page so it is possible to view the how close the text regions get}
\end{subfigure}
\caption{Full caption}
\end{figure}

\end{document}


Don't load subfig along with subcaption. Also specifying a fixed width like 50mm is not good, because you might exceed the width for the subfigure.

-
There appeared to be two copies of the MWE's code; I've taken the liberty of removing the duplicate. –  Mico May 5 at 19:11
I see, thanks ever so much for this solution. I had tried .45\textwidth before, but of course forgot to add \hfill to separate them so it didn't appear to be working. –  yorkie1990 May 5 at 19:38

You can change the style of the subcaptions using \captionsetup command executed in the preamble of the document.

To change the width of the caption, you would use parameter width as follows (takes 90% of the width of the subfigure).

 \captionsetup[subfigure]{width=0.9\textwidth}


Include this command in the preamble of your document.

Note, that it changes style of subcaptions in the whole document. There are also several other useful parameters you might experiment with (like margin, indent, for more see subfig package documentation http://ctan.org/pkg/subfig, section 3.1.2 ).

Regards.

-
\captionsetup may be used locally too, within the figure environment. –  srao May 5 at 17:38
wasn't aware of that @srao, thanks.. –  Emil May 5 at 17:51

You could use the \subcaptionbox command from the subcaption package. http://ctan.mirrorcatalogs.com/macros/latex/contrib/caption/subcaption.pdf

\documentclass[]{article}
\usepackage{graphicx}

\usepackage{caption}

\usepackage{subcaption}
%\usepackage{subfig}

\begin{document}

\begin{figure}[h!]
\captionsetup[subfigure]{position=top} %if you want to change the position of the subcaption; default is bottom.
\subcaptionbox{Test 1 - text filling out page so it is possible to view the how close the text regions get. I will keep going to show that in the second line.\label{subfig-1}}{\includegraphics[width=50mm]{image1.png}}
\hfill
%\hspace{1cm}
\subcaptionbox{Test 2 - text filling out page so it is possible to view the how close the text regions get\label{subfig-b}}{\includegraphics[width=50mm]{image2.png}}
\caption{Full caption}
\end{figure}

\end{document}

-

Shorter version from original code. Just using \subfloat from \subfig packages.

\documentclass[draft]{article}

\usepackage{graphicx}
\usepackage{subfig}

\begin{document}
\begin{figure}[h!]
\centering
\subfloat[Test 1 - text filling out page so it is possible to view the how close the text regions get. I will keep going to show that in the second line.]
{
\includegraphics[width=.45\textwidth]{testing.png}
}