1

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%
,hyperindex=true,hyperfootnotes=true,linktocpage=false%
,colorlinks=true,citecolor=blue,menucolor=red,bookmarks=true%
,bookmarksnumbered=true,pdftitle={Latitude and Month Correction},pdfauthor={Muhammad Hamdy Al-bassoussi},pdfkeywords={Cooling Load},pdfdisplaydoctitle=true,pdffitwindow=true,pdfmenubar=true%
,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{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.5pt}
%\addtolength{\headheight}{0pt} % make space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
%\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}%
\qquad
\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}

The image

  • 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
  • I have already edited my post and I am waiting for your answer :) – Muhammad Mar 24 '13 at 14:36
5

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}%
\hfill                              %% note this addition
\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}%
\qquad
\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}

enter image description here

  • 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
  • 1
    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
3

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.

enter image description here

\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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.