When referencing floats using \cref
commands, they may sometimes yield an incorrect typesetting. That's especially true when subfloats are included.
An example is when we have float 1 with two subfloats; the range 1a and 2 to 5
will be mistaken as though it is from 1a to 5
. Also, if both 1a
and 1b
are ncluded in the source code referencing, it is supposed to mention all of subfloats included in the source code, not only one of them (see point 2). Typeset output is shown below:
This output is generated using the following source code:
\documentclass[twocolumn]{report}
\usepackage{float}
\usepackage{subfloat}
\usepackage{caption}
\usepackage{cleveref}
\usepackage{paralist}
\begin{document}
\begin{subfigures}
% Subfigure 1
\begin{figure}[H]
\centering
\fbox{\Huge Figure 1a}
\caption{Caption 1}
\label{fig1a}
\end{figure}
% Subfigure 2
\begin{figure}[H]
\centering
\fbox{\Huge Figure 1b}
\caption{Caption 1b}
\label{fig1b}
\end{figure}
\end{subfigures}
% Figure 2
\begin{figure}[H]
\centering
\fbox{\Huge Figure 2}
\caption{Caption 2}
\label{fig2}
\end{figure}
% Figure 3
\begin{figure}[H]
\centering
\fbox{\Huge Figure 3}
\caption{Caption 3}
\label{fig3}
\end{figure}
% Figure 4
\begin{figure}[H]
\centering
\fbox{\Huge Figure 4}
\caption{Caption 4}
\label{fig4}
\end{figure}
% Figure 5
\begin{figure}[H]
\centering
\fbox{\Huge Figure 5}
\caption{Caption 5}
\label{fig5}
\end{figure}
% Figure 6
\begin{figure}[H]
\centering
\fbox{\Huge Figure 6}
\caption{Caption 6}
\label{fig6}
\end{figure}
\newpage
Figures are correctly cited for different citation formats such as:
\begin{enumerate}
\item Multiple: \textbf{\cref{fig5,,fig3,,fig4,,fig2}}
\item Range: \textbf{\cref{fig5,fig3,fig4}}
\item Multiple and range: \textbf{\cref{fig2,fig4,fig3,fig6}}
\end{enumerate}
\vspace{5mm}
But once subfigures are included, some citations formats do not work:
\begin{enumerate}
\item Multiple (works): \textbf{\cref{fig3,,fig4,,fig2,,fig1a}}
\item Range: \textbf{\cref{fig1a,fig1b,fig5,fig3,fig4}} (the output should be \textbf{figs. 1a to 1b and 3 to 5})
\item Multiple and range: \textbf{\cref{fig1a,fig2,fig4,fig3,fig6}} (the output should be \textbf{figs. 1a, 2 to 4 and 6})
\end{enumerate}
\end{document}
I already have a solution that mitigates the problem, but not with the same expected output above.
paralist
necessary? Isfloat
? Can you reproduce with justsubfloat
andcleveref
?float
allows for deciding the figures locations using[H]
after\begin{figure}
.paralist
is used to provide a list of cases on how the typeset referencing output looks like.paralist
at all. Forcleveref
, see page 26 of the manual: 'Cleveref doesn’t know about the subfloat package, so you have to revert to using\ref
for cross-references to sub-figures. (Might be fixed in a future version.)'