0

Suppose I have four small figures and I want to use Subfloat to produce a figure with captions similar to upper panels of the following figure:

enter image description here

Here is what I have done, but as you can see, the captions are not centered.

\documentclass{article}
    \usepackage{graphicx}
    \usepackage[labelformat = simple]{subfig}
\renewcommand{\thesubfigure}{Panel (\Alph{subfigure})}
    \begin{document}

    \begin{figure}
    \centering
    \caption{Rate of Y Over Time}
    \subfloat[Horizon: One Month \newline Trend: $0.43 + 0.14 \tau,\;p = 0.00$]{ \includegraphics[ height=6cm, width=0.45\columnwidth]{./H1}}\qquad
    \subfloat[Horizon: Three Month  \newline Trend: $0.46 + 0.11 \tau,\;p = 0.00$]{ \includegraphics[ height=6cm, width=0.45\columnwidth]{./H3}}

    \subfloat[Horizon: Six Month  \newline Trend: $0.46 + 0.08 \tau,\;p = 0.00$]{ \includegraphics[ height=6cm, width=0.45\columnwidth]{./H6}}\qquad
    \subfloat[Horizon: Twelve Month  \newline Trend: $0.57 + 0.03\tau,\;p = 0.27$]{ \includegraphics[ height=6cm, width=0.45\columnwidth]{./H12}}
    \end{figure}
    \end{document}   

enter image description here Can someone help with this, please.

9
  • Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem, starting with \documentclass and ending with \end{document}. - Do you want subcaptions?
    – Bobyandbob
    Sep 6 '17 at 17:33
  • Just lose the subfloats. You might add \hfil between the images for spacing. Note that \includegraphics aligns the bottoms of the images (which may or may not include white space). Sep 6 '17 at 17:50
  • 1
    You should be more specific in terms of what you want. Your visual requirement and the code snippet has very little in common.
    – Werner
    Sep 6 '17 at 18:15
  • I think you should add Trend: $0.43 + 0.14 \tau,\;p = 0.00$ as title of the figure and not inside the subcaption. - 1.)Please clearify which caption do you like. (Your code differs from the image, so i assume that you don't want an 1:1 copy)). 2.) Is the numbering((a), (b),...)) correct?
    – Bobyandbob
    Sep 7 '17 at 12:23
  • @Bobyandbob, 1) Correct, I do not want a 1:1 copy, just something similar to the Figure. 2) the numbering (a), (b), ... is ok, but I prefer Panel (A), Panel (B), ....
    – user27808
    Sep 7 '17 at 12:55
4

like this?

enter image description here

centering of subloat caption with \newline for force text break to two lines doesn't work well. instead this move second line of caption to \subfloat's content as title of images as is shown in mwe below:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage[labelformat = simple, 
            justification=centering]{subfig}
\renewcommand{\thesubfigure}{Panel (\Alph{subfigure})}
\begin{document}

\begin{figure}
\centering
\setlength\tabcolsep{0pt}
\caption{Rate of Y Over Time}
\subfloat[Horizon: One Month]
{   \begin{tabular}{c}
Trend: $0.43 + 0.14\tau,\;p=0.00$\\
\includegraphics[height=6cm, width=0.45\columnwidth]{./H1}
    \end{tabular}
}\hfil
\subfloat[Horizon: Three Month]
{   \begin{tabular}{c}             
Trend: $0.46 + 0.11 \tau,\;p = 0.00$\\
\includegraphics[height=6cm, width=0.45\columnwidth]{./H3}
\end{tabular}
}

\subfloat[Horizon: Six Month]
{   \begin{tabular}{c}
Trend: $0.46 + 0.08 \tau,\;p = 0.00$\\
\includegraphics[height=6cm, width=0.45\columnwidth]{./H6}
\end{tabular}
}\hfil
\subfloat[Horizon: Twelve Month]
{   \begin{tabular}{c}
Trend: $0.57 + 0.03\tau,\;p = 0.27$\\
\includegraphics[height=6cm, width=0.45\columnwidth]{./H12}
\end{tabular}
}
\end{figure}
\end{document}

addendum (1): an alternative to above solution is use

\subfloat[text fot LoF][first line of caption

                        second line of caption]
{\includegraphics{example-image}}

considering this, above solution become

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage[labelformat = simple,
            justification=centering]{subfig}
\renewcommand{\thesubfigure}{Panel (\Alph{subfigure})}
\begin{document}

\begin{figure}
\centering
\caption{Rate of Y Over Time}
\subfloat[][Horizon: One Month

Trend: $0.43 + 0.14\tau,\;p=0.00$]
{
\includegraphics[height=6cm, width=0.45\columnwidth]{./H1}
}\hfil
\subfloat[][Horizon: Three Month

Trend: $0.46 + 0.11 \tau,\;p = 0.00$]
{
\includegraphics[height=6cm, width=0.45\columnwidth]{./H3}
}

\subfloat[][Horizon: Six Month

Trend: $0.46 + 0.08 \tau,\;p = 0.00$]
{
\includegraphics[height=6cm, width=0.45\columnwidth]{./H6}
}\hfil
\subfloat[][Horizon: Twelve Month

Trend: $0.57 + 0.03\tau,\;p = 0.27$]
{
\includegraphics[height=6cm, width=0.45\columnwidth]{./H12}
}
\end{figure}
\end{document}

enter image description here

where we can see, that with this solution the second line of caption belong to caption and not to "title" of image" as solution before. what is better is matter of personal preferences :)

addendum (2): equivalent solution with subcaption package (which has some features superior to subfig package):

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage[labelformat = simple,
            justification=centering]{subcaption}
\renewcommand{\thesubfigure}{Panel (\Alph{subfigure})}
\begin{document}

\begin{figure}
\centering
\caption{Rate of Y Over Time}
\begin{subfigure}{0.45\linewidth}
\caption[]{Horizon: One Month 

Trend: $0.43 + 0.14\tau,\;p=0.00$}
\includegraphics[height=6cm, width=\linewidth]{./H1}
\end{subfigure}\hfil
\begin{subfigure}{0.45\linewidth}
\caption[]{Horizon: Three Month

Trend: $0.46 + 0.11 \tau,\;p = 0.00$}
\includegraphics[height=6cm, width=\linewidth]{./H3}
\end{subfigure}

\bigskip
\begin{subfigure}{0.45\linewidth}
\caption[]{Horizon: Six Month

Trend: $0.46 + 0.08 \tau,\;p = 0.00$}
\includegraphics[height=6cm, width=\linewidth]{./H6}
\end{subfigure}\hfil
\begin{subfigure}{0.45\linewidth}
\caption[]{Horizon: Twelve Month

Trend: $0.57 + 0.03\tau,\;p = 0.27$}
\includegraphics[height=6cm, width=\linewidth]{./H12}
\end{subfigure}
\end{figure}
\end{document}

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.