I need to have subcaption labels (and references) be of the format
Fig. 1a
Instead of the default "(a)", and be able to reference them with \cref
Unfortunately, I can't seem to get any subcaption related commands change the format of the subcaption "label" (is that the correct name for this?)
This is as close as I can get (while still having \cref
work for normal, non-subfigure figures).
As you can see, I'm using memoir
. The problem with the below code is that the references using \cref
start with the figure counter (the first "1" below), and I can't seem to get rid of it. I understand this is the wrong way to handle it (I change the counter to include a name/label instead of changing the caption format). Any proper solution is very welcome, failing that, a hack to fix my hack is welcome as well!
\documentclass{memoir}
\usepackage{hyperref}
\usepackage[nameinlink]{cleveref}
\newsubfloat{figure}
\renewcommand{\thesubfigure}{Fig. \arabic{figure}\alph{subfigure}}
\renewcommand{\thefigure}{\arabic{figure}}
\crefformat{subfigure}{#2{}#1{}#3{}}
\begin{document}
\begin{figure}
\subbottom[first subfigure \label{fig:first}]{\fbox{Numero uno}}
\subbottom[second subfigure \label{fig:second}]{\fbox{Numero dos}}
\end{figure}
\cref{fig:first}
\cref{fig:second}
\end{document}
EDIT it seems also that if I don't use \caption
the figure number isn't incremented and a following normal figure will use the same figure number. Is there an automated way to change this behaviour? Currently, I'm adding a \addtocounter{figure}{1}
in each subfig only figure, which has the desired effect.
Best Answer
This is quite an unusual request/demand. Here is one solution, but it probably will make a mess at normal use of figure referencing:
Edit: Desired look-out is achieved by use
\renewcommand{\thefigure}{}
in each float with subfigures and\stepcounter{figure}
before end offigure
float. Now I hope is fulfilled your requests.