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?
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
- 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..