Page LayoutFont Colors for Headings at every Place

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
HcN
Posts: 5
Joined: Fri Jun 22, 2012 4:59 pm

Font Colors for Headings at every Place

Post by HcN »

Hi everyone,

I am facing a few (very small and unimportant) problems with changing font colours on my LaTeX template.

I want to introduce font colour for every heading level and an horizontal bar below chapter/section titles. I used the sectsty package, with \color and \sectionrule:

Code: Select all

\usepackage{sectsty,ulem} 
\definecolor{bleu1}{RGB}{0,51,128}
\chaptertitlefont{\color{bleu1}\sectionrule{0pt}{0pt}{-5pt}{0.8pt}}
\chapternumberfont{\color{bleu1}}
\subsectionfont{\color{bleu1}}
\sectionfont{\color{bleu1}\sectionrule{0pt}{0pt}{-5pt}{0.8pt}}
Results are perfect but changes do not apply to the table of contents. Ergo, chapter and section titles on the ToC are still in black, and I wanted then to be in bleu1. Then is tried using tocloft package.

Code: Select all

\usepackage{tocloft}
\renewcommand*\cftchapfont{\color{bleu1}\bfseries}
It works for chapter colours but removes colour from the "Contents" title as well as the horizontal bar underneath.
Does anyone of you have an idea about how to proceed to keep the colour of "content", the bar and the coloured chapter on the ToC?

The other problems I met was, in spite of the sectsty package, the "appendices" front page before appendices remains black (the one generated from the appendix package), and I don't know how to change font colour for fancyhdr headings and footers.

Cheers in advance :)

Edit:
In case it may be relevant, it uses the report class.

Code: Select all

\documentclass[twoside,10pt,report]{report}

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

HcN
Posts: 5
Joined: Fri Jun 22, 2012 4:59 pm

Re: Font Colors for Headings at every Place

Post by HcN »

Up .. nobody has an idea ?
Even about how to change font colour for FancyHDR ?
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Font Colors for Headings at every Place

Post by meho_r »

Probably people are waiting for a Minimal Working Example (MWE)...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Font Colors for Headings at every Place

Post by localghost »

HcN wrote:Up .. nobody has an idea ? […]
Instead of just writing a one-liner you should supplement your question with useful information as you have been asked for by meho_r. This applies to every question because offering specific help will be much easier then.
HcN wrote:Even about how to change font colour for FancyHDR ?
The package is called »fancyhdr« and not »FancyHDR«. For Linux users this is an important difference (because the file system is completely case sensitive).

Regarding your problem you should not rely on the combination of fancyhdr, sectsty and tocloft. You are better with the "twins" titlesec and titletoc, which make things much easier. Lucky that I have a code example present from my archives.

Code: Select all

\documentclass[11pt,twoside,english]{report}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[pagestyles,raggedright]{titlesec}
\usepackage{titletoc}
\usepackage[dvipsnames]{xcolor}
\usepackage{blindtext}

\definecolor{bleu1}{RGB}{0,51,128}

\titleformat*{\chapter}{\normalfont\huge\bfseries\color{bleu1}}
\titleformat*{\section}{\normalfont\Large\bfseries\color{bleu1}}
\titleformat*{\subsection}{\normalfont\large\bfseries\color{bleu1}}
\titleformat*{\subsubsection}{\normalfont\bfseries\color{bleu1}}
\titleformat*{\paragraph}{\normalfont\bfseries\color{bleu1}}
\titleformat*{\subparagraph}{\normalfont\color{bleu1}}

\titlecontents{chapter}
[1.5em]
{\color{bleu1}\bfseries}
{\contentslabel{1.3em}}
{\hspace*{-1.3em}}
{\normalcolor\titlerule*{}\contentspage}

\titlecontents{section}
[3.8em] % ie, 1.5em (chapter) + 2.3em
{\color{bleu1}}
{\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{\normalcolor\titlerule*[1pc]{.}\contentspage}

\titlecontents{subsection}
[6.1em] % ie, 1.5em (chapter) + 2.3em (section) + 2.3em
{\color{bleu1}}
{\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{\normalcolor\titlerule*[1pc]{.}\contentspage}

\newpagestyle{main}[\color{bleu1}]{
  \headrule
  \sethead[\normalcolor\thepage][][\chaptername\ \thechapter\quad\chaptertitle]{\thesection\quad\sectiontitle}{}{\normalcolor\thepage}
}
\pagestyle{main}

\begin{document}
  \tableofcontents

  \blinddocument
\end{document}
For a deeper understanding of their capabilities take a close look at the manuals of the involved packages so that you can do probable adjustment on your own.

The packages babel (along with its global language option) and blindtext are not part of the solution. They have only been used to create the dummy document.


Thorsten
Post Reply