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.
1
  • 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, 2017 at 10:20

1 Answer 1

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}
2
  • 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, 2017 at 17:28
  • @AH - Just remove the option colorlinks. If necessary, specify the option linkcolor=red when loading hyperref.
    – Mico
    Dec 10, 2017 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .