Is there a way to customize the display of a subfigure reference like a \tag command does in an equation.

For example, the following MWE:


  \begin{tikzpicture}\path[draw=#1,fill=#1!20] (0,0) rectangle (4,4);\end{tikzpicture}}

    \phantomsubcaption \label{subfig1}
    % \tag{\figurenum(red)}
    \phantomsubcaption \label{subfig2}
    % \tag{\figurenum(green)}
    \phantomsubcaption \label{subfig3}
    % \tag{\figurenum(blue)}
  \caption{Three squares. Left: red. Center: green. Right: blue.}

In \cref{fig:all}, we have three subfigures \cref{subfig1}
\cref{subfig2} and \cref{subfig3}.

In this example, cref displays

In fig. 1, we have three subfigures fig. 1a fig. 1b and fig. 1c.

I would like to instead have

In fig. 1, we have three subfigures fig. 1(red) fig. 1(green) and fig. 1(blue).

By customizing the labels as the invalid commented statement do, i.e., using something like \tag{\figurenum(red)}

I saw an answer here for a similar problem(where I took the MWE from). That answer has a more global solution for all subfigures and is based on the placement of the subfigures (or their number). It also does not use cleveref which I prefer to use.

Is there a way to customize the label for each figure/subfigure separately?

  • 1
    Somewhat related: tex.stackexchange.com/questions/423580/… Jun 30, 2021 at 13:43
  • That is actually exactly what I need! A command like \def\figtag#1{\renewcommand{\thesubfigure}{#1}} seems to work flawlessly. Thanks! If you write an answer I will accept it, otherwise I can answer my own question based on this comment.
    – Tohiko
    Jun 30, 2021 at 13:50
  • Hmm... It is difficult to customize the reference and subref formats if the label is set this way.
    – Tohiko
    Jun 30, 2021 at 14:17
  • 1
    I have to admit that redefining \thesubfigure is the simplest way to accomplish the task. The best part is that the effects are limited to one figure. Jul 1, 2021 at 1:53


You must log in to answer this question.

Browse other questions tagged .