Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying \section{} to make it colorful with LaTeX

Tags:

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}
like image 853
prosseek Avatar asked Jul 18 '10 13:07

prosseek


People also ask

How do you color in LaTeX?

The simplest command to change the color of elements in the LaTeX document is \color{color}. This command switches the color for the current group in which the command is inserted. This shows the basic use of colors in \LaTeX. \item {\color{red} And red!}

How do I change the color of a paragraph in LaTeX?

The color command is declared as {\color{mentioned-color}some text}. The textcolor command is used for all in one paragraph, while the color command is used for the text to run over other tex environments and the multiple lines. To change the background color, you can use the command \pagecolor{mentioned-color}.


3 Answers

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}{}
like image 136
Cloudanger Avatar answered Oct 06 '22 16:10

Cloudanger


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

I could change color using sectsty style.

like image 7
prosseek Avatar answered Oct 06 '22 17:10

prosseek


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}
like image 2
In silico Avatar answered Oct 06 '22 16:10

In silico