# Specify Figure name color and slant

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?

\usepackage{caption}
\usepackage[font={color=ocre,bf,it},figurename=Fig.,labelfont={it}]{caption}


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

• – Werner Apr 14 '15 at 20:05
• Do you use a package that helps to create sub-figures? Perhaps subcaption? Or are you manually writing both the sub-figure captions and their references? – Werner Apr 14 '15 at 20:07
• I do not use a package that helps to create sub-figures. I manually write both the sub-figure captions and their references. – Joe Apr 14 '15 at 20:19

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>}
\textcolor{ocre}{\bfseries\emph{\figurename\,\ref{#2}#1}}}


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:

\documentclass[dvipsnames]{article}
\usepackage{xcolor,graphicx}
\usepackage{caption}
\DeclareCaptionLabelFormat{mycaplabelformat}{#1\,#2}
\captionsetup[figure]{%
font={color=red!70!black,bf,it},
labelformat=mycaplabelformat}

\renewcommand{\figurename}{Fig.}
\newcommand{\figref}[2][]{% \figref[<sub-figref>]{<figref>}
\textcolor{red!70!black}{\bfseries\emph{\figurename\,\ref{#2}#1}}}

\newcommand{\subfigfont}{\small}

\begin{document}

\begin{figure}
\centering
\begin{tabular}{@{}c@{}}
\includegraphics[width=100pt]{example-image-a} \\
{\subfigfont (a) first}
\begin{tabular}{@{}c@{}}
\includegraphics[width=100pt]{example-image-b} \\
{\subfigfont (b) second}
\end{tabular}
\caption{Some caption}
\label{fig:label}
\end{figure}

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

\end{document}


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.