# Problem with placement of subfigure captions

I am using the subcaption package and I want to know how to place the captions of the subfigures in the bottom center of each subfigure.

\documentclass[12pt,a4paper]{article}
%
%
\usepackage{utopia}
\usepackage{enumitem}
\usepackage[usenames,dvipsnames]{color}
\usepackage[superscript,ref,nomove]{cite}
\usepackage{textcomp}
\usepackage{verbatim, amsmath, amsfonts, amssymb, amsthm}
\usepackage[british]{babel}
\usepackage{float}
\usepackage{graphicx}
\usepackage{booktabs,longtable,rotating}
\usepackage{array,warpcol}
\usepackage{multirow}
\usepackage{fixme}
\usepackage[section,verbose]{placeins}
\usepackage{gensymb,units}
\usepackage{fancyhdr}
\usepackage{setspace}
\usepackage{microtype}
\usepackage{stfloats}
%
\usepackage[width=11cm,font=footnotesize,labelfont=bf%
,format=hang,labelformat=parens,labelsep=endash,%
justification=raggedright,singlelinecheck=on]{caption} % Captions.
\usepackage{subcaption}
\captionsetup[sub]{width=6cm,font=scriptsize,labelfont=bf%
,format=hang,labelformat=parens,labelsep=endash,%
justification=centering,singlelinecheck=on}
%
\usepackage{fixltx2e}
\usepackage{varwidth}
\usepackage{todonotes}
\usepackage[pageanchor=true,plainpages=false,pagebackref=false%
,pdftoolbar=true,pdfwindowui=true,pdfpagelayout=OneColumn]{hyperref}
%
\graphicspath{{./Figures/}} %To set the first directory to search for images in.
%
%\setlength{\parindent}{0pt}
\setlength{\parskip}{2ex plus 0.5ex minus 0.2ex}
%\parindent0em
%\parskip\medskipamount
%
\renewcommand{\baselinestretch}{1.25}
%
\pagestyle{fancy}
\fancyhf{}
\cfoot{\bfseries{\thepage}}
\rfoot{\scriptsize\bf{Latitude \& Month Correction}}
\lfoot{\scriptsize\bf{M. Hamdy}}
\renewcommand{\footrulewidth}{0.5pt}
\fancypagestyle{plain}{%
%\fancyfoot{}
%\renewcommand{\footrulewidth}{0pt}
}
%
\renewcommand{\arraystretch}{1.5} % To edit the height of the rows of a table.
%

\begin{document}

\begin{figure}[H]
\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height= 6cm, width=12cm]{W80_32N_Sep_S}
\caption{Wall no.(80): 32$^\circ$N - September - South orientaion}
\label{fig:w80}
\end{subfigure}%

\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height= 6cm, width=12cm]{W17_56N_Apr_NE}
\caption{Wall no.(17): 56$^\circ$N - April - NourthEast orientaion}
\label{fig:w17}
\end{subfigure}%
\caption{Comparing Corrected CLTDs Resulting from Equations~(\ref{eq:corr}) and~(\ref{eq:corr_ash}) with the Calculated CLTDs for Two Different Wall Constructions, Locations, Months, and Orientations.}\label{fig:corr}
\end{figure}

\end{document}


• Welcome to TeX.SE! Please edit your posting to include the code that you use to generate the figure (and subfigures). It would appear that the subfigure widths have been set in a certain way; unfortunately, without seeing the code, it's going to be difficult to diagnose and fix the problem. – Mico Mar 24 '13 at 13:36

You are using a subfigure with width of 0.3\textwidth and a width of 6cm in \captionsetup[sub]. The caption is centered within that width. But the figure width (as in \includegraphics[height= 6cm, width=12cm]) is more than that. Hence all this trouble.

Remedies:

1. Don't use more width in \includegraphics[width=..] than given in \begin{subfigure}{....} and use same width in both \captionsetup[sub] as well.
2. It is better to give only width in \includegraphics[width=..]. If you include height, you should use keepaspectratio to prevent the figure from getting distorted.

Use something like

\begin{figure}[H]
\begin{subfigure}{6cm}
\centering
\includegraphics[width=6cm]{example-image-a}
\caption{Wall no.(80): 32$^\circ$N - September - South orientaion}
\label{fig:w80}
\end{subfigure}%
\begin{subfigure}{6cm}
\centering
\includegraphics[width=6cm]{example-image-b}
\caption{Wall no.(17): 56$^\circ$N - April - NourthEast orientaion}
\label{fig:w17}
\end{subfigure}%
\caption{Comparing Corrected CLTDs Resulting from Equations~(\ref{eq:corr}) and~(\ref{eq:corr_ash}) with the Calculated CLTDs for Two Different Wall Constructions, Locations, Months, and Orientations.}\label{fig:corr}
\end{figure}


• It works :) ... Really thank you very very much :) – Muhammad Mar 24 '13 at 15:03
• @Muhammad Glad it worked. :-) – user11232 Mar 24 '13 at 15:06
• Two quick notes: (i) Because the graphs in the subfigures are set up to take up all of the available width, there's no need to provide \centering instructions inside the subfigure environments. Second, because the graphs are designed to use the entire available width of the subfigure environments, I'd use width=\linewidth instead of a hard-coded value (here: width=6cm) in the optional arguments of the \includegraphics directives. That way, if the widths ever have to be changed later on, one only has to adjust one parameter rather than two. – Mico Mar 24 '13 at 15:24
• @Mico Good points. I agree. :-) – user11232 Mar 24 '13 at 16:34

I can't tell for sure from your setup if you want the graphs in the subfigures to be 6 centimeters wide -- as would seem to be indicated by the arguments of the \subcaption statements -- or 12 centimeters wide -- as would seem to be indicated by the optional arguments of the \includegraphics statements).

If it's the former, and if you want the two graphs to be placed next to each other, you should follow the code that Harish has provided in his separate answer.

If it's the latter, i.e., if the two graphs should each be 12 centimeters wide, they can't fit side by side on an A4-sized page. In this case, you may want to adopt something along the following lines. Note that the codes sets up a minipage of width 12cm; within this environment, all width references are to \linewidth (which will be 12cm) rather than to a hard-coded length value.

\documentclass[12pt,a4paper]{article}
\usepackage{utopia}
\usepackage[demo]{graphicx} % remove "demo" for real doc
\usepackage[font=footnotesize, labelfont=bf,
format=hang, labelformat=parens,
labelsep=endash, justification=raggedright,
singlelinecheck=on]{caption}
\usepackage{subcaption}
\captionsetup[sub]{font=footnotesize,
labelsep=endash, justification=centering}

\begin{document}
\begin{figure}
\centering
% Create a minipage that's 12cm wide
% Then, use \linewidth parameter inside the minipage environment
\begin{minipage}{12cm}
\begin{subfigure}{\linewidth}
\includegraphics[width=\linewidth]{W80_32N_Sep_S}
\caption{Wall no.(80): 32$^\circ$N -- September -- South orientation}
\label{fig:w80}
\end{subfigure}

\medskip % insert a bit more vertical space between subfigures
\begin{subfigure}{\linewidth}
\includegraphics[width=\linewidth]{W17_56N_Apr_NE}
\caption{Wall no.(17): 56$^\circ$N -- April -- NorthEast orientation}
\label{fig:w17}
\end{subfigure}

\caption{Comparing Corrected CLTDs Resulting from Equations~(\ref{eq:corr})
and~(\ref{eq:corr_ash}) with the Calculated CLTDs for Two Different Wall
Constructions, Locations, Months, and Orientations.}
\label{fig:corr}
\end{minipage}
\end{figure}
\end{document}

• @ Mico : Thanks a lot for your great notes, and I am sorry since I have noticed your answer just now :) – Muhammad Mar 27 '13 at 9:23