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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
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