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?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communitysectsty
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>}
:
\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>}
:
\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}
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}