Every time I have to denote a figure name in the text I have to type: {\textcolor{ocre}{\bf{\emph{Fig.\;\ref{figurename}(b)}}}}

Is there an optimized way to specify this in the preamble so I do not have to type this each time I refer to a figure name?

I already specified:


in the preamble to take care of the caption name and text.


Since you're writing sub-figure captions and references manually, my suggestion would be to use a macro like the following:

\newcommand{\figref}[2][]{% \figref[<sub-figref>]{<figref>}

This allows you to use \figref{<figref>} to reference full figures, or \figref[(b)]{<figref>} (say) to reference sub-figures.

Here's a complete minimal example:

enter image description here


\newcommand{\figref}[2][]{% \figref[<sub-figref>]{<figref>}



    \includegraphics[width=100pt]{example-image-a} \\
    {\subfigfont (a) first}
  \end{tabular} \qquad
    \includegraphics[width=100pt]{example-image-b} \\
    {\subfigfont (b) second}
  \caption{Some caption}

\verb|\ref{fig:label}|: \ref{fig:label} \par
\verb|\figref{fig:label}|: \figref{fig:label} \par
\verb|\figref[(b)]{fig:label}|: \figref[(b)]{fig:label}


You may have to make some adjustments to the formatting. However, consistency is the key and wrapping content inside a macro allows you to change things later, if needed.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.