GeneralColored headline should show as black in table of contents

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Sapientum
Posts: 4
Joined: Tue Dec 11, 2007 2:15 pm

Colored headline should show as black in table of contents

Post by Sapientum »

Hi,

I'm setting up a report in LaTex at the moment, and in order to make it more appealing, I've made the headlnes another color than black. But, the headline is also this color in the table of contents, so I was wondering if it is possible to have it appear black in the table of contents?

It could be because of the way I have defined the color. I don't know.
I have used the \textcolor on the headline. But there must be another way. A way that can define all headlines to be a specific color. How can I do this??

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Colored headline should show as black in table of contents

Post by gmedina »

Sapientum wrote: Hi,

I'm setting up a report in LaTex at the moment, and in order to make it more appealing, I've made the headlnes another color than black. But, the headline is also this color in the table of contents, so I was wondering if it is possible to have it appear black in the table of contents?

One possibility is to use the optional argument of the sectioning commands, as the following example suggests:

Code: Select all

\documentclass{report} 
\usepackage{xcolor}

\begin{document}
\tableofcontents

\chapter[First chapter]{\textcolor{blue}{First chapter}}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
balfonsi
Posts: 93
Joined: Wed Mar 14, 2007 12:05 am

Re: Colored headline should show as black in table of contents

Post by balfonsi »

The reason is that you coded the textcolor in the argument to chapter, or section, or whatever ou want. That's not good programming. You would have the same problem with a fontsize command, for instance. What should be done is to redefine the formatting of chapters, sections, etc. A very good package to easily customize that formatting is titlesec (which has a titletoc companion,incidentally). I suggest you take a look at its documentation.

Regards,
B.A.
Sapientum
Posts: 4
Joined: Tue Dec 11, 2007 2:15 pm

Re: Colored headline should show as black in table of contents

Post by Sapientum »

I will give it a try :)

Thanks for the quick answers
Post Reply