3

I'm trying to have subcaption labels of the form (a), (b), etc. references of the form fig. 1(a), and ranges of the form figs. 1(a--c). I cannot seem to get the last requirement. Here's my MWE (adapting the second answer in Adding parentheses around subfig references) that gives me references of the form figs. 1(a)--c):

\documentclass{article}
\usepackage{subcaption,cleveref}
\renewcommand\thesubfigure{(\alph{subfigure})}
\captionsetup[subfigure]{labelformat=simple}
\crefrangeformat{figure}{figs.~#3#1#4--#5\crefstripprefix{#1}{#2}#6}
\begin{document}
\cref{1,2,3}
\begin{figure}
\subcaptionbox{\label{1}}[0.3\textwidth][c]{}
\subcaptionbox{\label{2}}[0.3\textwidth][c]{}
\subcaptionbox{\label{3}}[0.3\textwidth][c]{}
\end{figure}
\end{document}
bjorne
  • 637

1 Answers1

2

Your declared formatting objective -- figs. 1(a--c) -- is not stylistically unambiguous. I think you'd be better off omitting the parentheses around the subcaption's numbers (letters) entirely, both for cross-references to single subfigures and to ranges of subfigures. Of course, you're perfectly free to use parentheses in the subfigures' captions.

enter image description here

\documentclass{article}
\usepackage{subcaption,cleveref}
\crefrangelabelformat{subfigure}{#3#1#4--#5\crefstripprefix{#1}{#2}#6}

\begin{document}
\cref{1}, \cref{1,2,3}

\begin{figure}
\subcaptionbox{\label{1}}[0.1\textwidth][c]{}\quad
\subcaptionbox{\label{2}}[0.1\textwidth][c]{}\quad
\subcaptionbox{\label{3}}[0.1\textwidth][c]{}
\label{Overall caption}
\end{figure}
\end{document}
Mico
  • 506,678
  • Thanks for the advice. Why do you say the choice is not stylistically unambiguous? In what circumstance could I have "figs. #" followed with no space by a parenthetical, other than this one? – bjorne Apr 17 '19 at 21:48
  • @bjorne - Questions of style are inherently subjective, so I’ll readily grant that you may see these matters from the way I do. When I read something like figs. 1(a—c), my instinctual reaction is to start looking for a single subfigure labeled (a—c). Then, after sime hesitation and stumbling around, I’d probably figure out that 3 separate subfigures are being cross-referenced... – Mico Apr 17 '19 at 21:58