Introduction

Colors are an essential aspect of document design, and LaTeX provides various tools for using and managing colors in your documents. The xcolor package is one of the most popular and versatile packages for working with colors in LaTeX.

Using xcolor package

You can use colors in LaTeX via the xcolor package. This package provides a lot of options for defining and using colors in your document. Here are a few basic examples to get you started:

1. Setting the text color

\documentclass{article}
\usepackage{xcolor}

\begin{document}

\textcolor{blue}{TexReady in blue color}

\textcolor{yellow}{TexReady in yellow color}

\textcolor{green}{TexReady in green color}

\textcolor{red}{TexReady in red color}

\end{document}

This example generates the following output:

text color

2. Setting the background color

\documentclass{article}
\usepackage{xcolor}

\begin{document}

\colorbox{lime}{TexReady with lime background}

\colorbox{yellow}{TexReady with yellow background}

\colorbox{orange}{TexReady with orange background}

\colorbox{purple}{TexReady with purple background}

\end{document}

This example generates the following output:

background color

3. Defining a custom color
There are many standard color names available to be used in LaTeX color command, if the color you want is not available you can define it using:

\definecolor{MyColor}{rgb}{127,0,255}

and then use it like the following:

\textcolor{MyColor}{TexReady in custom color}

Basic colors in LaTeX

The following named colors are available in LaTeX:

basic colors

Adding more colors

In order to use additional colors in your document, specify the dvipsnames option when including the xcolor package at the preamble of your document:

\usepackage[dvipsnames]{xcolor}

Once the package is loaded, you can use any of the predefined color names from the dvipsnames color list:

dvipsnames colors