4

I am using cleveref with crefmultiformat to reference a list of subfigures. I would like to have the letters referencing the subfigure of the main figure listed inside parentheses, like so: figs. 1(a,b)

The output that I get using the code below is: figs. 1a(,b)

How can it be achieved?

\documentclass[11pt,
               twoside,
               a4paper,
               english,
               abstract=off,
               headsepline=on,
               captions=tableheading]
               {scrartcl}

\usepackage[]{graphicx} \usepackage[colorlinks]{hyperref} \usepackage{xstring} \usepackage{subcaption} \usepackage{cleveref}

\crefmultiformat{figure} {figs.~#2#1\xdef\mycreffirstarg{#1}(#3} {,#2{\crefstripprefix{\mycreffirstarg}{#1}}#3)} {,#2{\crefstripprefix{\mycreffirstarg}{#1}}#3} {,#2{\crefstripprefix{\mycreffirstarg}{#1}}#3)}

\begin{document}

\begin{figure}[h] \centering {\phantomsubcaption\ignorespaces\label{subfig:fig-a}} {\phantomsubcaption\ignorespaces\label{subfig:fig-b}} \includegraphics[width=0.5\textwidth]{example-image-a} \caption{Example} \label{fig:fig} \end{figure}

The output that I would like to get is: figs. 1(a,b)

The output that I get is: \cref{subfig:fig-a,subfig:fig-b}

\end{document}

enter image description here

luege
  • 41

0 Answers0