Text FormattingColored Section Headings, but no colored Headers

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Atticus_Freeze
Posts: 3
Joined: Thu Jun 30, 2011 12:01 pm

Colored Section Headings, but no colored Headers

Post by Atticus_Freeze »

Hi, I'm having a problem trying keep my section titles colored, but not my headers, using the fancyhdr package. So, basically what I have is my sections colored in red, and my headers being red too. I would like for the headers to be black. Now, I've already tried specifying a color (like the color gray in code snippet below) within the fancy header parameters, but it doesn't work out too well, because the specified color does not display fully unless my section title is colored black.

Code: Select all

\fancyhead[RE]{\color{Gray}{\bfseries\nouppercase{\rightmark}}}
Attached below is a pdf demonstrating the issue I'm having.
demo.pdf
Demonstration of issue
(68.89 KiB) Downloaded 188 times
Also, I seem to have the same issue with my table of contents. I'd like to have the listed items colored black. Any help would be much appreciated.

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Colored Section Headings, but no colored Headers

Post by localghost »

Forget fancyhdr and use titlesec. It manages page styles as well as the formatting of headings.

Code: Select all

\documentclass[11pt,a4paper,twoside,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[dvipsnames]{xcolor}
\usepackage[pagestyles,raggedright]{titlesec}
\usepackage{blindtext}

\titleformat*{\section}{\Large\bfseries\color{Maroon}}
%\titleformat*{\subsection}{\large\bfseries\color{Maroon}}
%\titleformat*{\subsubsection}{\normalsize\bfseries\color{Maroon}}

\newpagestyle{main}{%
  \sethead[\thepage][][\thesection\ \sectiontitle]{\thesubsection\ \subsectiontitle}{}{\thepage}
  \headrule
}
\pagestyle{main}

\begin{document}
  \tableofcontents
  \blinddocument
\end{document}
Using both packages would be redundant and can have side effects. The blindtext package it not part of the solution. It is only used for creating dummy text.

The classes of KOMA Script and the memoir class have built-in mechanisms to control the appearance of headings.


Thorsten
Post Reply