# Customise the font of only the number in Figure labels

I'm attempting to customise the font of only the figure number in the label of a figure. I've tried

\usepackage{caption}
\captionsetup{labelfont={color=blue}}


but this produces something like

whereas I wish for the word Figure and the colon to remain black. I couldn't find anything in the documentation for caption about such specific customization.

You can define your own labelformat (described in the documentation in 4 Own enhancements):

\documentclass{article}
\usepackage{xcolor}
\usepackage{caption}
\DeclareCaptionLabelFormat{colorlabel}{#1 \textcolor{blue}{#2}}
\captionsetup{labelformat=colorlabel}
\begin{document}
\begin{figure}
\caption{abc}
\end{figure}
\end{document}


• You were posting while I was writing ;o). – Bernard Aug 8 '16 at 13:43
• I usually dislike the clutter in answers with an example, but I'll give it to the speedster :) – Anti Earth Aug 8 '16 at 13:45
• @AntiEarth I usually dislike questions without an example, it meant that I had to write the example myself to test the solution. – Ulrike Fischer Aug 8 '16 at 13:51
• @UlrikeFischer Fair enough, I suppose it's careful juggle of clarity, convenience and relevance. – Anti Earth Aug 8 '16 at 13:56

With the caption package:

\usepackage{xcolor}
\colorlet{labelcolor}{blue}
\DeclareCaptionLabelFormat{bluenum}{#1~\textcolor{labelcolor}{#2}}
\captionsetup{labelformat=bluenum}


Redefine \fnum@figure to add the color.

\documentclass{article}
\usepackage{xcolor}
\renewcommand\figurename{Figure}
\makeatletter
\def\fnum@figure{\figurename\nobreakspace\textcolor{red}{\thefigure}}
\makeatother
\begin{document}
\begin{figure}[ht]
\centering
\rule{1in}{1in}
\caption{This is a caption}
\end{figure}
\end{document}


This will only change the color in the caption, but not, for example in a reference to the figure. If you want the number changed in color even in references to it, then one can redefine \thefigure:

\documentclass{article}
\usepackage{xcolor}
\let\svthefigure\thefigure
\def\thefigure{\textcolor{red}{\svthefigure}}
\begin{document}
\begin{figure}[ht]
\centering
\rule{1in}{1in}
\caption{This is a caption}
\label{fg:A}
\end{figure}

In figure\nobreakspace\ref{fg:A}
\end{document}