4

In my code below, I wanted to change the color of the text for the table and figure caption. I am using this:

\usepackage[svgnames]{xcolor}
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{caption}
\usepackage[labelfont={color=ocre,bf}]{caption}

\renewcommand{\thefigure}{\textcolor{ocre}{\bfseries\itshape\thechapter.\arabic{figure}}}
\renewcommand{\figurename}{\textcolor{ocre}{\bfseries\itshape Fig.}}
\renewcommand{\thetable}{\textcolor{ocre}{\bfseries\itshape\arabic{table}}}
\renewcommand{\tablename}{\textcolor{ocre}{\bfseries\itshape Table}}

This is what I get as the output.

enter image description here

Can you tell me how to get the caption text the same color as the Fig.1.1 text?

  • 2
    Use font instead of labelfont. – Gonzalo Medina Sep 10 '13 at 15:50
7

You can do all your changes using options for the caption package:

\documentclass[12pt,twoside]{report}
\usepackage[svgnames]{xcolor}
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{caption}
\usepackage[font={color=ocre,bf},figurename=Fig.,labelfont={it}]{caption}

\begin{document}

\chapter{Test chapter}
\begin{figure}
\centering
A
\caption{Test figure}
\end{figure}

\end{document}

enter image description here

In standard classes book and report, the figure and table counters are by default subordinated to the chapter counter; if you are using a class in which this is not the default, you can use

\usepackage{chngcntr}
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter

so the counter will be subordinated and will reset each time chapter steps.

It is not a good idea,in general, to involve direct modifications of attributes like color in redefinitions of \thefigure (or \thetable), since then the changes will also appear in (most of the times) undesired locations, such as cross-references.

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.