Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 9 down vote accepted

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}
share|improve this answer

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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