8

I want to change only the color (not font size, etc.) of all headings in my documents (\section, \subsection, \subsubsection, ...). I want to keep all other settings fixed.

Is there a way to do this?

13

sectsty allows you to modify sectional heading fonts on a case-by-case basis, or all at once. For example, to modify only the \subsection fonts, use \subsectionfont{<font defs>}:

enter image description here

\documentclass{article}
\usepackage{sectsty}% http://ctan.org/pkg/sectsty
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\sectionfont{\color{red}}
\subsectionfont{\color{green!80!black}}
\subsubsectionfont{\color{blue!50!white}}
\begin{document}
\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\end{document}

For all sections, use \allsectionsfont{<font defs>}:

enter image description here

\documentclass{article}
\usepackage{sectsty}% http://ctan.org/pkg/sectsty
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\allsectionsfont{\color{black!30!green!50!cyan}}
\begin{document}
\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\end{document}
9

If you're using a KOMA-Script class you don't need an additional package (besides the color package, of course) but can use \addtokomafont. Adapting Werner's examples:

\documentclass{scrartcl}
\usepackage{xcolor}

\addtokomafont{section}{\color{red}}
\addtokomafont{subsection}{\color{green!80!black}}
\addtokomafont{subsubsection}{\color{blue!50!white}}

\begin{document}
\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\end{document}

Or all sections with the same color:

\documentclass{scrartcl}
\usepackage{xcolor}

\addtokomafont{sectioning}{\color{black!30!green!50!cyan}}

\begin{document}
\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.