prosseek
prosseek

Reputation: 191069

Modifying \section{} to make it colorful with LaTeX

How can I change the \section{} style? Especially I want to change the color of section heading.

I happen to find some neat style following Edward R. Tufte (http://code.google.com/p/tufte-latex/), and I'm trying to find a way to modify the section color.

Added

color package works fine, but the thing is that the color chapter number is not changed.

\section{\color{Red}ELPA}

Upvotes: 27

Views: 82198

Answers (5)

postylem
postylem

Reputation: 1121

If you would like to only change the format of the section number (and subsection and subsubsection), while leaving the section title as normal, then you can do it like this, with the titlesec package

\usepackage{titlesec}
%modifies the format of section,subsection,subsubsection
\titlelabel{\textcolor{red}\thetitle\quad}

Upvotes: 0

Cloudanger
Cloudanger

Reputation: 9534

Use package titlesec.

Put this in the LaTeX header (before \begin{document})

\usepackage{titlesec}
\usepackage{color}


\titleformat{\section}
{\color{red}\normalfont\Large\bfseries}
{\color{red}\thesection}{1em}{}

Upvotes: 38

Stefan
Stefan

Reputation: 3620

You could use the titlesec package and its \titleformat command.

Upvotes: 1

prosseek
prosseek

Reputation: 191069

\usepackage{sectsty}
%\allsectionsfont{\color{blue}\itshape\underline}
\sectionfont{\color{blue}\itshape\selectfont}
\subsectionfont{\color{green}\itshape\selectfont}

I could change color using sectsty style.

Upvotes: 7

In silico
In silico

Reputation: 52187

Have you tried using the color package?

\usepackage[usenames, dvipsnames]{color}

\section{\color{Red} Section Header}

You can also define your own colors:

\usepackage[usenames, dvipsnames]{color}
\definecolor{MetallicGold}{RGB}{212, 175, 55}

\section{\color{MetallicGold} Section Header}

You can define a command to make it simplier to type:

\usepackage[usenames, dvipsnames]{color}
\definecolor{MetallicGold}{RGB}{212, 175, 55}
\newcommand{\coloredsection}[2]{\section{\color{#1} #2} }

\coloredsection{MetallicGold}{Section Header}

Upvotes: 2

Related Questions