I recently switched to using cleveref
in my latex document. However, I have one case I still don't quite get right (or maybe it is just not covered in cleveref):
I use the subfigure
-environment of the subcaption
package on a regular basis. In the caption of the main figure, I then use \subref{}
to get only the label of the subfigure, e.g. (a)
instead of 1a
.
The main advantage of cleveref
is that I can type \cref{fig}
and get the result of fig.~\ref{fig}
, but this does not work for a subreference, because \cref
always produces the full label (1a
).
Is there a way to reproduce fig.~\subref{fig:a}
using cleveref as well? I.e. can I use \cref
to create a reference than only uses the subfigure label without the mainfigure label?
Edit: here is a MWE illustrating the problem:
\documentclass{article}
\usepackage{mwe}
\usepackage{subcaption}
\usepackage{cleveref}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{.3\linewidth}
\includegraphics[width=\linewidth]{image-a}
\caption{Figure 1a}
\label{fig:a}
\end{subfigure}
\begin{subfigure}{.3\linewidth}
\includegraphics[width=\linewidth]{image-b}
\caption{Figure 1b}
\label{fig:b}
\end{subfigure}
\caption{Main figure caption}
\label{fig}
\end{figure}
Using subcaption, I can link to \ref{fig}, \ref{fig:a} or to \subref{fig:a} alone.
Using cleverref, I can also link to \cref{fig} and to \cref{fig:a},
However, I cannot link to \subref{fig:a} alone.
\end{document}
This produces the following result:
Edit 2: To be extra clear: The point of using cleveref
is to be able to write text references without the need to describe the nature of every label. But, if I can not create a subref version of the cref
command, I am still stuck with manually typing those references, which, imho, makes not much sense. Either I use cleveref all the way, or not at all.
So the question is, can I create a \cref
variant of \subref
?
\label{fig:1a}
in MWE. Anyhow, what would you like to be the result of\subref{fig:a}
? Also in your MWE you are just using the same command twice, i.e.\subref{fig:a}
, in what respect do you expect it to give you a different result, the second time you invoke it? Are you saying you are missing a\csubref{}
command? But again what would you like to see as a result? Imho saying fig. a is pretty meaningless in a document, because it does not refer to a distinct image, unless you intend to use it in the captions. – Matthias Arras Oct 22 '16 at 16:09