To define the caption color in my document, I am using
\usepackage{caption}
\usepackage[font={small,color=ocre}]{caption}
Which works perfectly, but currently facing the following two problems:
- Subcaptions are not colored (I am using the subfigure package, so I can't use the same code as above)
- When a citation is included in the figure caption , it is not colored.
Does any one have some solutions or hints?
After the request, here is a minimum working example:
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage[numbers,square]{natbib}
%The following is uesd to make the caption colored
\usepackage{xcolor}
\definecolor{ocre}{RGB}{1,160,233}
\usepackage{caption}
\usepackage[font={small,color=ocre}]{caption}
\usepackage{graphicx,subfigure}
\usepackage[hidelinks]{hyperref} % hyperlinks
\usepackage[hidelinks]{hyperref} % hyperlinks
\hypersetup{
colorlinks=true,
allcolors=black,
citecolor=black,
linkcolor=black,
}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{Knu86,
author = {Knuth, Donald E.},
year = {1986},
title = {The \TeX book},
}
\end{filecontents*}
\bibliography{\jobname} % if you’re using BibTeX
\begin{document}
\begin{figure}[hb]
\centering %%% not \center
\boxed{\subfigure[Subfigure One]{\label{fig:SubfigureOne}\includegraphics[width=0.4\textwidth]{../../Desktop/StackExchange/Test.pdf}}}
\boxed{\subfigure[Subfigure Two]{\label{fig:SubfigureTwo}\includegraphics[width=0.4\textwidth]{../../Desktop/StackExchange/Test.pdf}}}
\caption{Comparison between Subfigure One and Subfigure Two. \autoref{fig:SubfigureOne} shows the difference for the complete data range, and \autoref{fig:SubfigureTwo} as displayed in \cite{Knu86}}
\label{fig:OverAllFigure}
\end{figure}
\end{document}
Best Answer
Code
Document
Explanation
The problem is, that you defined a black color for hyperlinks using
\hypersetup
. You can change the link colors locally using\hypersetup
again at the begin of everyfigure
environment. I think the most comfortable way of doing this is using\AtBeginEnvironment
of the packageetoolbox
.To change the color of the subfigure captions, I defined a new command
\boxedcolor
. It allows you to change the color inside the box and also affects subfigure captions. Depending on whether you always want to useocre
as you color, you could also define\boxedcolor
it with one argumentwhich leads to shorter usage:
\boxedcolor{...}
.Alternatively, you could append
\color{ocre}
tofigure
using\AtBeginDocument
like I did it withhypersetup
before. This would be the most comfortable solution, but it also leads to a colored box (which is not desired, I expect).