Specify Figure name color and slant

by Joe   Last Updated April 14, 2015 22:10 PM - source

Evertime 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.

Tags : captions

Answers 1

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>}



  \begin{tabular}{@{}[email protected]{}}
    \includegraphics[width=100pt]{example-image-a} \\
    {\subfigfont (a) first}
  \end{tabular} \qquad
  \begin{tabular}{@{}[email protected]{}}
    \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.

April 14, 2015 20:22 PM

Related Questions

Caption figure in Latex

Updated March 28, 2015 14:07 PM

Add a caption under an image

Updated May 04, 2015 21:10 PM