# [Tex/LaTex] Put Subcaptions on the right of vertically aligned subfigures

subcaptionsubfigsubfloats

I'm struggling to find a solution for my problem. I want something like this

but for VERTICALLY aligned subfigures, as an attempt to save some vertical space (I can't reduce the size more than this)

I'm using \subfig package to have my subfigures aligned. here is my code:

\begin{figure}[ht!]

\centering
\begin{minipage}{\textwidth}
\centering
\subfloat[]
{
\includegraphics[width=0.6\textwidth, keepaspectratio]{fig_a}
\label{fig:a}
}
\\
\centering
\subfloat[]
{
\includegraphics[width=0.6\textwidth, keepaspectratio]{fig_b}
\label{fig:b}
}
\\
\centering
\subfloat[]
{
\includegraphics[width=0.6\textwidth, keepaspectratio]{fig_c}
\label{fig:c}
}
\caption{Three figures, take too much vertical space}
\label{fig:unified}
\end{minipage}
\end{figure}


Thank you for any help!

Note that only the image is centered, not the caption.

Ideally one should put the \label immediately after the \caption, but in this case that isn't possible. Instead one should put the \label inside the caption. Otherwise some of the local macros used by \label may be lost.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\captionsetup[sub]{justification=raggedright,singlelinecheck=false}
\usepackage{showframe}% debuggingh tool

\makeatletter
\newcommand{\mysub}[2][]% #1=caption (optional), #2=graphics
{\bgroup
\sbox0{#2}\usebox0
\dimen0=\dimexpr \textwidth-\wd0\relax
\ifx\\\@centercr \divide\dimen0 by 2\fi
\sbox1{\begin{minipage}[t]{\dimen0}
\subcaption{#1}%
\end{minipage}}%
\rlap{\raisebox{\dimexpr \ht0-\ht1}[0pt][0pt]{\usebox1}}\allowbreak
\egroup}
\makeatother

\begin{document}
\begin{figure}[p]
\centering
\mysub[A very long caption, just to test the limits. \label{fig:a}]
{\includegraphics[width=0.6\textwidth, keepaspectratio]{example-image-a}}

\mysub[\label{fig:b}]
{\includegraphics[width=0.6\textwidth, keepaspectratio]{example-image-b}}

\mysub[\label{fig:c}]
{\includegraphics[width=0.6\textwidth, keepaspectratio]{example-image-c}}

\caption{Three figures, take too much vertical space}
\label{fig:unified}
\end{figure}
\end{document}