Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical Supply Distributor100,000+ medical supplies. 48-hour critical dispatch.Ships from 8 regional U.S. hubs. Net-30 terms for verified institutional accounts.Shop lac.us CodeCASRAIlac.us

LaTeX Text Color: textcolor, color and xcolor Names

How to change LaTeX text color with xcolor: textcolor vs color, defining colors in rgb, cmyk or HTML models, and fixing common errors.

Written and maintained by CASRAI Editorial Board

Last updated

Short answer: load the xcolor package, then write \textcolor{red}{some words} to colour a few words or {\color{red} some words} to colour everything inside a group. \textcolor takes the colour first and the text second; \color is a switch that stays on until its group or environment ends.

What it is used for in research

Coloured text in a LaTeX manuscript, thesis, poster or set of slides is used to flag revisions during co-authoring, mark variables or results in an equation walk-through, or keep a consistent palette across figures and text. Journals often print in greyscale or restrict colour, so check the target venue’s author instructions before relying on colour alone to carry meaning (see boldface in LaTeX for an emphasis cue that does not depend on colour).

Install or access (official source only)

xcolor is the driver-independent colour extension for LaTeX and pdfLaTeX. It builds on the basic color package and adds tints, shades, tones and mixes, with eight colour models. The CTAN entry lists version 3.02 dated 2024-09-29 under the LaTeX Project Public Licence 1.3c, with documentation in xcolor.pdf and development at github.com/latex3/xcolor (CTAN, read 2026-11-07). Load it in the preamble:

\usepackage{xcolor}

Step-by-step: colour text in LaTeX

1. Colour a few words with textcolor

  1. Add \usepackage{xcolor} to the preamble.
  2. In the body, write \textcolor{red}{easily}. The first argument is the colour, the second is the text (Overleaf, read 2026-11-07).

2. Colour a block with color

  1. Write \color{blue} where the colour should begin. It sets the colour for the current block of text, for example inside an itemize environment.
  2. To keep the change local, put the switch inside braces: {\color{red} \rule{linewidth}{0.5mm}}. The group confines the change.

3. Define your own colour

  1. Use \definecolor{name}{model}{definition} in the preamble, then use the name in \textcolor or \color:
\definecolor{mypink1}{rgb}{0.858, 0.188, 0.478}
\definecolor{mypink2}{RGB}{219, 48, 122}
\definecolor{mypink3}{cmyk}{0, 0.7808, 0.4429, 0.1412}
\definecolor{mygray}{gray}{0.6}
\definecolor{Mycolor2}{HTML}{00F9DE}

\textcolor{mypink1}{Pink with rgb}

4. Mix colours or use a named set

  1. Mix with \colorlet, for example \colorlet{Mycolor1}{green!10!orange}, or tint a named colour with \colorlet{LightRubineRed}{RubineRed!70}.
  2. For extra named colours, pass an option when loading: \usepackage[dvipsnames]{xcolor}. Basic names such as red and blue need no option.
  3. For a coloured background behind text, \colorbox{color}{text} takes the background colour first and the text second. For boxed layouts see framed boxes in LaTeX and tcolorbox examples.

Output and how to read it

The compiled PDF shows the chosen words in the requested colour; the rest of the paragraph keeps the default colour. If a whole list or section turns the colour, a \color switch was not closed in a group. \pagecolor{black} followed by \color{white} sets a dark page with white default text, and \nopagecolor restores the normal background (Overleaf).

Colour models at a glance

Model Values
rgb three numbers from 0 to 1
RGB three integers from 0 to 255 (xcolor)
cmyk four numbers from 0 to 1
gray one number from 0 to 1
HTML six hexadecimal digits, A to F in uppercase (xcolor)
hsb, cmy, Gray (1 to 15), wave (363 to 814 nm) additional xcolor models

Named sets loaded by option: dvipsnames has 68 CMYK colours, svgnames has 151 RGB colours and x11names has 317 RGB colours (Overleaf, read 2026-11-07).

textcolor versus color

textcolor color
Form \textcolor{red}{text} \color{red}
Applies to the text in its second argument the current block, confined by braces when grouped
Typical use a word or phrase in a sentence a list, a block, or a rule inside braces

Troubleshooting

  • Wrong colour or nothing coloured: check argument order. \textcolor takes colour, then text; \colorbox takes background colour, then text.
  • Colour carries into later text: wrap the \color switch in braces so it stays local.
  • Undefined colour name: names beyond the basics need an option such as dvipsnames, svgnames or x11names on \usepackage{xcolor}, or a \definecolor in the preamble.
  • HTML colour rejected: use exactly six hexadecimal digits with A to F in uppercase, for example 00F9DE.
  • Unexpected shade: rgb expects values from 0 to 1 while RGB expects integers from 0 to 255; do not mix the ranges.

Free alternatives

Package What the sources say
\color The basic colour package that xcolor builds on (CTAN, read 2026-11-07)
xcolor Recommended over \color by Overleaf for its flexibility and extra models; adds tints, shades, tones and mixes; LPPL 1.3c licence (CTAN)

For coloured code listings see LaTeX listings; for strike-through marks see cross-out in LaTeX.

FAQ

How do I change text colour in LaTeX?

Load xcolor and use \textcolor{colourname}{text} for a phrase or {\color{colourname} text} for a group.

What is the difference between textcolor and color?

\textcolor colours only its argument. \color changes the colour for the current block, so wrap it in braces to limit its reach.

Can I use hex colour codes?

Yes, through xcolor’s HTML model: \definecolor{Mycolor2}{HTML}{00F9DE}, with six hexadecimal digits and A to F in uppercase.

How do I put a background colour behind text?

Use \colorbox{color}{text}; the colour in the first argument is the background.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about LaTeX Text Color: textcolor, color and xcolor Names

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →