[Tex/LaTex] Figure alignment using sub caption

horizontal alignmentsubcaptionvertical alignment

I'm trying to align some figures using the subcaption package.

My current code is that:

\documentclass[11pt,twocolumn]{article}

\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{caption}

\begin{document}

    \begin{figure}[htpb]
        \subcaptionbox{}
            {\includegraphics[width=0.48\columnwidth]{figs/Fig_a}} \hspace{.5em}
        {\includegraphics[width=0.2\columnwidth]{figs/legend} phantomsubcaption}
        \subcaptionbox{}
            {\includegraphics[width=0.48\columnwidth]{figs/Fig_b}} \hfill
        \subcaptionbox{}
            {\includegraphics[width=0.48\columnwidth]{figs/Fig_c}} 
        \caption{}
    \end{figure}

\end{document}

Which produces:

enter image description here

However, I would like the first image to be left alined. I tried to use this:

\usepackage[export]{adjust box}
\captionsetup{justification=raggedright, singlelinecheck=false}

\begin{figure}[htpb]
    \subcaptionbox{}
        {\includegraphics[width=0.48\columnwidth, left]{figs/Fig_a}} \hspace{.5em}
    {\includegraphics[width=0.2\columnwidth]{figs/legend} phantomsubcaption}
    \subcaptionbox{}
        {\includegraphics[width=0.48\columnwidth]{figs/Fig_b}} \hfill
    \subcaptionbox{}
        {\includegraphics[width=0.48\columnwidth]{figs/Fig_c}} 
    \caption{}
\end{figure}

With no success:

enter image description here

Also, the image with the \phantomsubcaption doesn't have the same heigh as Figure (a) and I would like it to be center vertically aligned, and not bottom or top, i.e., aligned with the center of Figure (a). Is that possible?

Thank you.

Best Answer

Is this what you want? Just place the narrow figure in the first \subcaptionbox.

\documentclass[11pt,twocolumn]{article}

\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{caption}

\begin{document}

\begin{figure}[htpb]
\centering
\subcaptionbox{}{%
  \includegraphics[width=0.48\columnwidth]{figs/Fig_a}%
  \hspace{0.04\columnwidth}%
  \includegraphics[width=0.2\columnwidth]{figs/legend}}\hspace*{\fill}

\subcaptionbox{}{\includegraphics[width=0.48\columnwidth]{figs/Fig_b}}\hfill
\subcaptionbox{}{\includegraphics[width=0.48\columnwidth]{figs/Fig_c}}

\caption{Some caption or this wouldn't make much sense}

\end{figure}

\end{document}

enter image description here

If you want that (a) is centered with respect to the wide image, you can insert the narrow image in a zero width box:

\documentclass[11pt,twocolumn]{article}

\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{caption}

\begin{document}

\begin{figure}[htpb]
\centering
\subcaptionbox{}{%
  \includegraphics[width=0.48\columnwidth]{figs/Fig_a}%
  \makebox[0pt][l]{%
    \hspace{0.04\columnwidth}%
    \includegraphics[width=0.2\columnwidth]{figs/legend}%
  }%
}\hspace*{\fill}

\subcaptionbox{}{\includegraphics[width=0.48\columnwidth]{figs/Fig_b}}\hfill
\subcaptionbox{}{\includegraphics[width=0.48\columnwidth]{figs/Fig_c}} 

\caption{Some caption or this wouldn't make much sense}

\end{figure}

\end{document}

enter image description here

If you want left aligned subcaptions, tell so to caption:

\documentclass[11pt,twocolumn]{article}

\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{caption}

\begin{document}

\begin{figure}[htpb]
\captionsetup[subfigure]{singlelinecheck=false}
\centering
\subcaptionbox{}{%
  \includegraphics[width=0.48\columnwidth]{figs/Fig_a}%
    \hspace{0.04\columnwidth}%
    \includegraphics[width=0.2\columnwidth]{figs/legend}%
}\hspace*{\fill}

\subcaptionbox{}{\includegraphics[width=0.48\columnwidth]{figs/Fig_b}}\hfill
\subcaptionbox{}{\includegraphics[width=0.48\columnwidth]{figs/Fig_c}} 

\caption{Some caption or this wouldn't make much sense}

\end{figure}

\end{document}

The \captionsetup[subfigure]{singlelinecheck=false} can also go in the preamble, so it will affect all subcaptions.

enter image description here

Related Question