5

I've changed my caption font color to gray as seen in the screenshot below. My problem is that references is black (which I've chosen in the hypersetup), how do I change this to be gray as the rest of the caption text, while in all other places than the caption the links are black?

I've tried with linkcolor and urlcolor, but it seems like the caption package does not support these options.

enter image description here

Here is my preamble:

\documentclass[11pt, twoside]{report}

\usepackage{hyperref} % clickable references
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}


% ------- Images ------- %
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\DeclareCaptionFont{gray}{\color{gray}}
\captionsetup{
    textfont={footnotesize,sc,gray},
    font={footnotesize,sc,gray},
    %linkcolor={footnotesize,sc,gray},
}



% ------- Colors ------- %
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

And the code for the table and equation is here:

\begin{equation}
1+K_1K_2\frac{(s+2)^2}{(s+10)(s+100)(s^2+3.535s+6.25)}=0
\label{eq:part_b_characteristic_eq}
\end{equation}


\begin{table}[h!]
\begin{center}
\begin{tabular}{c|l}
$s_n$ & pole\\\hline
$s_1$ & $-100 + 0i$\\
$s_2$ & $-10 + 0i$\\
$s_3$ & $-1.77 + 1.77i$\\
$s_4$ & $-1.77 - 1.77i$\\
\end{tabular}
\end{center}
\caption{Pole values of the system from equation \eqref{eq:part_b_characteristic_eq}}
\label{tab:poles_from_characteristic_eq_partb}
\end{table}
3

Just add the specification when you define the font for the caption; note that you should load hyperref last.

\documentclass[11pt, twoside]{report}

\usepackage{amsmath} % it was missing


% ------- Images ------- %
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

% ------- Colors ------- %
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

% hyperref

\usepackage{hyperref} % clickable references
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

% customizations

\DeclareCaptionFont{gray}{\color{gray}\hypersetup{linkcolor=gray}}
\captionsetup{
    textfont={footnotesize,sc,gray},
    font={footnotesize,sc,gray},
}

\begin{document}

\begin{equation}
1+K_1K_2\frac{(s+2)^2}{(s+10)(s+100)(s^2+3.535s+6.25)}=0
\label{eq:part_b_characteristic_eq}
\end{equation}


\begin{table}[h!]
\begin{center}
\begin{tabular}{c|l}
$s_n$ & pole\\\hline
$s_1$ & $-100 + 0i$\\
$s_2$ & $-10 + 0i$\\
$s_3$ & $-1.77 + 1.77i$\\
$s_4$ & $-1.77 - 1.77i$\\
\end{tabular}
\end{center}
\caption{Pole values of the system from equation \eqref{eq:part_b_characteristic_eq}}
\label{tab:poles_from_characteristic_eq_partb}
\end{table}

\end{document}

enter image description here

| improve this answer | |
1

I have prepared two new commands \mref and \mpageref which call for \hyperref (Approach 1) or \hypersetup{linkcolor=...} (Approach 2). Please try it if it fits your needs.

%! *latex mal-url-color.tex
\documentclass[11pt, twoside]{report}
\pagestyle{empty}
\usepackage{amsmath}
\usepackage{hyperref} % clickable references
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=gray, % red
    urlcolor=black,
   }
% ------- Images ------- %
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\DeclareCaptionFont{gray}{\color{gray}}
\captionsetup{
    textfont={footnotesize,sc,gray},
    font={footnotesize,sc,gray},
    %linkcolor={footnotesize,sc,gray},
    }
% ------- Colors ------- %
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

% Approach number 1
%\def\mref#1{\hyperref[#1]{\color{black}\ref*{#1}}}
%\def\mpageref#1{\hyperref[#1]{\color{black}\pageref*{#1}}}
% Approach number 2
\def\mref#1{\hypersetup{linkcolor=black}\ref{#1}}
\def\mpageref#1{\hypersetup{linkcolor=black}\pageref{#1}}

\begin{document}
\begin{equation}
1+K_1K_2\frac{(s+2)^2}{(s+10)(s+100)(s^2+3.535s+6.25)}=0
\label{eq:part_b_characteristic_eq}
\end{equation}
\begin{table}[h!]
\begin{center}
\begin{tabular}{c|l}
$s_n$ & pole\\\hline
$s_1$ & $-100 + 0i$\\
$s_2$ & $-10 + 0i$\\
$s_3$ & $-1.77 + 1.77i$\\
$s_4$ & $-1.77 - 1.77i$\\
\end{tabular}
\end{center}
\caption{Pole values of the system from equation~\eqref{eq:part_b_characteristic_eq}}
\label{tab:poles_from_characteristic_eq_partb}
\end{table}
A citation from is~\mref{eq:part_b_characteristic_eq} on~\mpageref{eq:part_b_characteristic_eq}.
\end{document}

mwe

| improve this answer | |
  • Thank you for your response! It was much appreciated, however @egreg's answer was more like what I was looking for :) good day! – Nicolai Anton Lynnerup Apr 9 '14 at 6:35
  • @Nicolai Sure, sure, please have no worries. – Malipivo Apr 9 '14 at 6:38

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.