# How to make the section and theorems with different colour

How to write the section and examples in different colour, such as the title with blue colour

\documentclass[20pt,a4paper]{extarticle}
\usepackage[a4paper,margin=6mm]{geometry}
\usepackage{amsmath}
\usepackage{hyperref}

\title{\LaTeX\ Mathematics Examples}

\begin{document}

\maketitle

%\tableofcontents

\section{Delimiters}

See how the delimiters are of reasonable size in these examples
\begin{displaymath}
\left(a+b\right)\left[1-\frac{b}{a+b}\right]=a\,,
\end{displaymath}
\begin{displaymath}
\sqrt{|xy|}\leq\left|\frac{x+y}{2}\right|,
\end{displaymath}
even when there is no matching delimiter
\begin{displaymath}
\int_a^bu\frac{d^2v}{dx^2}\,dx
=\left.u\frac{dv}{dx}\right|_a^b
-\int_a^b\frac{du}{dx}\frac{dv}{dx}\,dx.
\end{displaymath}

\section{Spacing}

Differentials often need a bit of help with their spacing as in
\begin{displaymath}
\iint xy^2\,dx\,dy
=\frac{1}{6}x^2y^3,
\end{displaymath}
whereas vector problems often lead to statements such as
\begin{displaymath}
w=0\,.
\end{displaymath}

\section{Theorems et al.}

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}[theorem]{Definition}

\begin{definition}[right-angled triangles] \label{def:tri}
A \emph{right-angled triangle} is a triangle whose sides of length~$$a$$, $$b$$ and~$$c$$, in some permutation of order, satisfies $$a^2+b^2=c^2$$.
\end{definition}

\begin{lemma}
The triangle with sides of length~$$3$$, $$4$$ and~$$5$$ is right-angled.
\end{lemma}

This lemma follows from the Definition~\ref{def:tri} as $$3^2+4^2=9+16=25=5^2$$.

\begin{theorem}[Pythagorean triplets] \label{thm:py}
Triangles with sides of length $$a=p^2-q^2$$, $$b=2pq$$ and $$c=p^2+q^2$$ are right-angled triangles.
\end{theorem}

Prove this Theorem~\ref{thm:py} by the algebra $$a^2+b^2 =(p^2-q^2)^2+(2pq)^2 =p^4-2p^2q^2+q^4+4p^2q^2 =p^4+2p^2q^2+q^4 =(p^2+q^2)^2 =c^2$$.

\end{document}


For section titles, you can use titlesec and do

\usepackage{titlesec}
\titleformat*{\section}{\color{magenta}}
\titleformat*{\subsection}{\color{Brown}}


To use Brown colour, you have to pass dvipsnames option to xcolor package.

For theorem titles etc you can do

\newtheorem{theorem}{\color{blue}Theorem}
\newtheorem{corollary}[theorem]{\color{blue}Corollary}
\newtheorem{lemma}[theorem]{\color{blue}Lemma}
\newtheorem{definition}[theorem]{\color{blue}Definition}


For theorems etc, there may be a better way, but I am unaware of them.

Code:

\documentclass[20pt,a4paper]{extarticle}
\usepackage[a4paper,margin=6mm]{geometry}
\usepackage{amsmath}
\usepackage[dvipsnames]{xcolor}    %% dvipsnames has Brown colour
\usepackage{hyperref}

\usepackage{titlesec}
\titleformat*{\section}{\color{magenta}}
\titleformat*{\subsection}{\color{Brown}}

\title{\LaTeX\ Mathematics Examples}

\begin{document}

\maketitle

%\tableofcontents

\section{Delimiters}
\subsection{Some subsection}

See how the delimiters are of reasonable size in these examples
\begin{displaymath}
\left(a+b\right)\left[1-\frac{b}{a+b}\right]=a\,,
\end{displaymath}
\begin{displaymath}
\sqrt{|xy|}\leq\left|\frac{x+y}{2}\right|,
\end{displaymath}
even when there is no matching delimiter
\begin{displaymath}
\int_a^bu\frac{d^2v}{dx^2}\,dx
=\left.u\frac{dv}{dx}\right|_a^b
-\int_a^b\frac{du}{dx}\frac{dv}{dx}\,dx.
\end{displaymath}

\section{Spacing}

Differentials often need a bit of help with their spacing as in
\begin{displaymath}
\iint xy^2\,dx\,dy
=\frac{1}{6}x^2y^3,
\end{displaymath}
whereas vector problems often lead to statements such as
\begin{displaymath}
w=0\,.
\end{displaymath}

\section{Theorems et al.}

\newtheorem{theorem}{\color{blue}Theorem}
\newtheorem{corollary}[theorem]{\color{blue}Corollary}
\newtheorem{lemma}[theorem]{\color{blue}Lemma}
\newtheorem{definition}[theorem]{\color{blue}Definition}

\begin{definition}[right-angled triangles] \label{def:tri}
A \emph{right-angled triangle} is a triangle whose sides of length~$$a$$, $$b$$ and~$$c$$, in some permutation of order, satisfies $$a^2+b^2=c^2$$.
\end{definition}

\begin{lemma}
The triangle with sides of length~$$3$$, $$4$$ and~$$5$$ is right-angled.
\end{lemma}

This lemma follows from the Definition~\ref{def:tri} as $$3^2+4^2=9+16=25=5^2$$.

\begin{theorem}[Pythagorean triplets] \label{thm:py}
Triangles with sides of length $$a=p^2-q^2$$, $$b=2pq$$ and $$c=p^2+q^2$$ are right-angled triangles.
\end{theorem}

Prove this Theorem~\ref{thm:py} by the algebra $$a^2+b^2 =(p^2-q^2)^2+(2pq)^2 =p^4-2p^2q^2+q^4+4p^2q^2 =p^4+2p^2q^2+q^4 =(p^2+q^2)^2 =c^2$$.

\end{document}


• I tried to use Brown colour but does not work I use this package but still does not work \usepackage[Brown,dvipsnames]{color} \definecolor{light-Brown}{Brown}{0.95} – percusse Sep 18 '14 at 6:19
• How about subsection, how can I make it different colour. Thanks – percusse Sep 18 '14 at 6:36
• @percusse Please see the updated answer. – user11232 Sep 18 '14 at 6:49
• Thank you Harish, I really appreciate your help. Thanks a lot – percusse Sep 18 '14 at 6:53
• @percusse Thanks are conveyed through upvoting (all!) and accepting the most useful answer (after a reasonable delay to see if other (better) answers pop up) in this site. For details, please see How do you accept an answer – user11232 Sep 18 '14 at 6:55