[Tex/LaTex] Subfigures. To add A and B to subfigures (in the top left corner), and to label them for referencing

cross-referencingsubfloats

I'm trying to set up a figure, so that it contains 2 subfigures. I would prefer if I could set them up with an A and B in the left-top corner (outside of the figure). However, I would also want to be able to reference each subfigure in my text. I have searched for a lot of different solutions, but I haven't been able to put together anything that works, so I'll try with a question.

Here's my MWE:

\documentclass[a4paper,11pt]{book} 
\usepackage{subcaption} 
\usepackage[export]{adjustbox} 
\usepackage{cleveref} 

\begin{document}
\begin{figure}[tb]
\centering

\begin{subfigure}[t]{0.03\textwidth}
    \textbf{A}
\end{subfigure}
\begin{subfigure}[t]{0.45\textwidth}
    \includegraphics[width=\linewidth,valign=t]{"test1"}
    \label{subfigure1}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.03\textwidth}
    \textbf{B}  
\end{subfigure}
\begin{subfigure}[t]{0.45\textwidth}
    \includegraphics[width=\linewidth,valign=t]{"test1"}
    \label{subfigure2}
\end{subfigure}

\caption{Here's a nice caption}. \label{overall label}
\end{figure}

Me trying to reference the entire figure: Figure \ref{overall label}. 
Me trying to reference the first subfigure A: Figure \cref{subfigure1}.
Me trying to reference the first subfigure B: Figure \cref{subfigure2}.
\end{document}

It looks something like this

Subfigure reference problem

I think I've got the part covered with the letters (even though I have to manually assign the letters). However, I can not get the subfigure reference to work.

I'm sorry if it seems messy. I'm not particularly adept with LaTeX. I hope someone will be able to help out!

Best Answer

I suspect that you like to have something like this:

enter image description here

It is adopted from answer sidesubfloats:

\documentclass{article}
\usepackage{floatrow}
\usepackage{graphicx}
%\usepackage{subfig}
\usepackage[label font=bf,labelformat=simple]{subfig}% <-- changed
\usepackage{caption}
\floatsetup[figure]{style=plain,subcapbesideposition=top}

\begin{document}
    \begin{figure}[htb]\centering
\sidesubfloat[]{\includegraphics[width=0.4\textwidth]{example-image-a}\label{fig:a}}
\hfil
\sidesubfloat[]{\includegraphics[width=0.4\textwidth]{example-image-b}\label{fig:b}}
\caption{Main caption}
    \label{fig:myfigure}
    \end{figure}
Figure \ref{fig:myfigure} consist three sub figures: \ref{fig:a} and \ref{fig:b}     
\end{document}

Addendum: Sub captuion layout you can determine by subfig options. They are summarized in subfig documentation, page 8. If you replace

\usepackage{subfig}

with

\usepackage[label font=bf,labelformat=simple]{subfig}

than subcaptions will look as show new image.