I'd like to know how to hack subfig
in order to change the format of \subref
. The current format, when subfig
is initialized with listofformat=parens
yields output like 4.5(b) . I'd like to add a space between the 4.5 and (b).
I know the documentation of subfig
says that new formats can be defined with \DeclareSubrefFormat{hkeyword valuei}{hcodei}
but I haven't managed to actually get hat to work.
Does anyone have an example of how the format can be changed?
Best Answer
The option
listofformat
controls the way subfloat numbers are typeset in the List of Figures/Tables and the actual format of the string produced by the\subref
command. To change this format, you have to declare a new format using\DeclareCaptionListOfFormat
and then use this new format in\captionsetup
. In the second argument of the\DeclareCaptionListOfFormat
command,#1
represents the float number and#2
represents the subfloat number. So to obtain the space between the float number and the subfloat number in the the LoF/LoT and when using\subref
, you'll have to do something like the following:Here's the List of Figures obtained:
and a fragment of the document, showing the output produce by
\subref
:If you only want to change the way
\subref*
(note the star) typesets the string associated to a subfloat, without affecting the entries in the Lof/Lot, you have to declare a new format using\DeclareSubrefFormat
and then use this format in\captionsetup
. In the second argument of\DeclareSubrefFormat
you can use#1
(the string associated to the float),#2
(the string associated to the subfloat),#3
(the value of the float counter) y#4
(the value of the counter associated to the subfloat). A little example producing a space between the float and subfloat numbers:Now the LoF looks like this:
and the fragment showing the output of
\subref*
: