0

I have to follow a special template for captioning figures. For a figure caption's label I should have the following format (2.5cm indention from the most left where the text begins):

enter image description here

For this format, I am already using the caption package and captionsetup changing \thefigure command as in the following:

\renewcommand{\thefigure}{\makebox[2.5cm][l]{Fig. \thesection-\arabic{figure}:}}
\captionsetup[figure]{labelsep=none,name={},format=hang,justification=justified, indention=0.0cm, singlelinecheck=false, margin={0mm,0mm}, aboveskip=6pt, belowskip=12pt, font={stretch=1.25}}

Basically I am putting the command \thefigure in a 2.5cm box in order to keep that 2.5 cm indention.

But with this setup, when I am refering to a figure, it looks like the following within the text: enter image description here

Does someone have an idea how I can differentiate between figure labels in the caption of the figure and figure label when I am referring to it within the text? The format I need for refering to a figure within a text is just Fig. 2-2 in this case and without the colon and space in the end. I could not find any specific keyword that differentiates between those two labels. Another idea would be to define a new command like:

\newcommand{\figurereflabel}{Fig. \thesection-\arabic{figure}}

But I don't know how to use this instead as the reference. The same issue I have also with tables. I would appreciate if someone can help in this case. Thanks.

Update: As @AxelSommerfeldt suggested, I used the following as a solution: DeclareLabelFormat to generally define my format of caption label:

\DeclareCaptionLabelFormat{myfig}{\makebox[2.5cm][l]{Fig. \thesection-\arabic{figure}:}}
\captionsetup[figure]{labelformat=myfig, labelsep=none,name={},format=hang,justification=justified, indention=0.0cm, singlelinecheck=false, margin={0mm,0mm}, aboveskip=6pt, belowskip=12pt, font={stretch=1.25}}

With help of cleveref package:

\creflabelformat{figure}{\thesection-#1}

Moreover, I am loading the cleveref package as \usepackage[capitalize]{cleveref} such that the first letter of fig. is always capitalized and refering to the figures with \cref{label} command.

  • 3
    Welcome to TeX.SX! Could you please turn your code fragments into a compilable minimal working example (MWE)? – leandriis Sep 16 at 13:31
  • Instead of redefining \thefigure I'd recommend using \DeclareCaptionLabelSeparator from the caption package in combination with a cross-referencing package such as cleveref. – leandriis Sep 16 at 13:46
  • @leandriis thanks for your comment. The main limitation is with that 2.5cm indention, so in the current modification of \thefigure, if I have a double digit number, the distance from the colon(:) to the caption text gets lower, as the whole distance from the most left part of the figure label (Fig...) to the beginning of the caption text should always be 2.5 cm, which is possible when I put everything into a box, but otherwise I have no idea how I can cover this restriction of my template. Do you know any other alternative way? – soroor Sep 16 at 14:05
  • 1
    Instead of redefining \thefigure I would do \DeclareCaptionLabelFormat{figure}{\makebox[2.5cm][l]{Fig. #2:}} and \captionsetup[figure]{labelformat=figure,labelsep=none,format=hang,...}. Regarding the reference I second what @leandriis wrote: Use cleverref or a similar package to add "Fig.~" to your figure references. – Axel Sommerfeldt Sep 16 at 18:08
  • @AxelSommerfeldt thanks, it worked very well for me. I add it to the question post as an update. – soroor Sep 17 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.