1

Good morning, I have just seen a Question titled by ''How to change the color of Table of Contents from red to black?'' and I'm really satisfied by the proposed answer as I want, knowing that the table of contents and the page numbers are both hyperlinked.

The proposed answer is:

{ \hypersetup{linkcolor=black}
  \tableofcontents
} 

In addition to that, I would like to keep the black color in the table of contents but I want:

  • Either to change the color of the page numbers in this table to red
  • Or frame these page numbers in a color square.
  • 3
    Not sure, if this is what you want to achieve, but \usepackage[colorlinks=true,linktocpage=true]{hyperref} removes the hyperlinks from the titles in the table of contents, hyperlinks the corresponding page numbers instead and prints these numbers in red. By removing the option colorlinks=true, the page numbers are surrounded by a red frame. – leandriis Dec 8 '17 at 10:20
2

You wrote,

I would like to ... change the color of the page numbers [in the ToC] [to red]

I suggest you load the hyperref package with the option linktocpage.

enter image description here

\documentclass{article}
\usepackage[colorlinks,linktocpage]{hyperref}
\begin{document}  
\tableofcontents

\bigskip
\hrule
\section{A A A} \clearpage
\section{B A B} \clearpage
\section{C C C}
\end{document}
  • Thank you very much for you answer. Do you have an idea how to frame the page numbers by a colored square.? Thank you again. – A H Dec 10 '17 at 17:28
  • @AH - Just remove the option colorlinks. If necessary, specify the option linkcolor=red when loading hyperref. – Mico Dec 10 '17 at 17:31

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.