Text Formatting ⇒ Colored chapter and section headings
-
- Posts: 1
- Joined: Tue Dec 08, 2020 6:18 pm
Colored chapter and section headings
So far, I have tried the following within the document:
\chapter{\color{purple}Chapter title}
\chapter{\textcolor{purple}{Chapter title}}
Both of these returned Error: Undefined color `Purple' even though purple is a color included in xcolor. Indeed, when I use a command within the body of the text such as {\color{purple}blah blah blah} the text is output in the appropriate color with no error message.
Is there a way to change the color of chapter and section headings globally in the preamble? Can I change the colors of the chapter and section headings individually so that each chapter heading has different colors?
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
- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
Colored chapter and section headings
Code: Select all
\documentclass{scrbook}
\usepackage{xcolor}
\usepackage{blindtext}
\addtokomafont{disposition}{\color{purple}}% color of all headings
\addtokomafont{chapterentry}{\normalcolor}% but not in the ToC
\begin{document}
\tableofcontents
\blinddocument
\end{document}
Code: Select all
\documentclass{scrbook}
\usepackage{xcolor}
\usepackage{blindtext}
\addtokomafont{chapter}{\color{purple}}
\addtokomafont{section}{\color{magenta}}
\addtokomafont{subsection}{\color{green}}
\begin{document}
\tableofcontents
\blinddocument
\end{document}

Colored chapter and section headings
I have to change the section colors for different sections, but all ideas I found are used in the preamble for the whole document...
(I cannot use koma, since I am using a very old latex/lyx)
And since I am using lyx, it would be helpful to change the style for all following sections, instead of using the \section command..