Skip to content

Colours in LaTeX

Load xcolor and use \textcolor{red}{...} or \color{blue}; in Scissor LaTeX colours show in formulas, TikZ drawings and pgfplots charts, while ordinary body text always stays black.

Where colour works

The xcolor package gives you \textcolor{colour}{text}, \color{colour} (for the rest of a group) and \colorbox{colour}{text}. In Scissor LaTeX colour reaches three places, and each knows a different set of colours:

WhereIn Scissor LaTeXColours known
Formulas ($...$, displays)Works17 names: red, green, blue, cyan, magenta, yellow, black, white, gray, lightgray, darkgray, brown, orange, pink, purple, teal, olive. Other names and mixes give black.
TikZ pictures and pgfplots chartsWorksEvery xcolor base name, 54 of the dvipsnames names, mixes such as red!50!blue or blue!30, and your own from \definecolor and \colorlet.
Body text, headings, captions, tablesNot colouredThe command is accepted and the text is kept, in black.

Colour in formulas

Inside math, \textcolor, \color and \colorbox work with the 17 names above. This is handy for highlighting a term in a derivation.

Highlighting terms in a formula

LaTeXPreamble: \usepackage{xcolor}Open in editor (opens in a new tab)
\[
  (a + b)^2 = a^2 + \textcolor{red}{2ab} + b^2
\]
The middle term $\textcolor{blue}{2ab}$ is the one people forget,
and $\colorbox{yellow}{x}$ marks the unknown.
Rendered by Scissor LaTeX: Highlighting terms in a formula

Colour in drawings and charts

TikZ and pgfplots know far more colours. You can mix two colours with !: red!30 is 30% red and 70% white, and red!50!blue is half red, half blue. \definecolor defines a colour from HTML, RGB, rgb, cmyk or gray values, and \colorlet names a mix.

Named colours, mixes and \definecolor in TikZ

LaTeXPreamble: \usepackage{tikz}Open in editor (opens in a new tab)
\definecolor{brand}{HTML}{1F6FEB}
\colorlet{brandsoft}{brand!30}
\begin{tikzpicture}
  \fill[brand] (0,0) rectangle (1,1);
  \fill[brandsoft] (1.2,0) rectangle (2.2,1);
  \fill[red!50!blue] (2.4,0) rectangle (3.4,1);
  \fill[orange] (3.6,0) rectangle (4.6,1);
  \draw[thick, teal] (0,-0.3) -- (4.6,-0.3);
\end{tikzpicture}

Pictures also know 54 of the 68 dvipsnames colours, such as ForestGreen, RoyalBlue or Mahogany. Load xcolor with the dvipsnames option anyway, so the document also compiles in a TeX installation. A name that is not known is reported in the Problems tab.

dvipsnames colours in a picture

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \foreach \c [count=\i] in {ForestGreen, RoyalBlue, Mahogany, Goldenrod} {
    \fill[\c] (\i*1.2,0) circle (0.5);
  }
\end{tikzpicture}
\end{document}

Body text stays black

In body text, \textcolor{red}{words} prints the words in black, {\color{blue} ...} has no effect, and \colorbox draws no background. Coloured tables (\rowcolor, \cellcolor from colortbl) and \pagecolor are accepted and ignored in the same way.

\textcolor in body text: the text is kept, in black

LaTeXPreamble: \usepackage{xcolor}Open in editor (opens in a new tab)
This is \textcolor{red}{important}, this is {\color{blue} blue in LaTeX},
and this has a \colorbox{yellow}{yellow background} there.

What differs from a TeX installation

Everything here also compiles in a TeX installation, where the text colours appear as well. For the package itself, see xcolor; the full manual is on CTAN: ctan.org/pkg/xcolor.

See also xcolor, TikZ basics and Differences.

Questions and answers

How do I colour text in LaTeX?

Load xcolor and write \textcolor{red}{text}. In Scissor LaTeX the colour shows in formulas and pictures; body text stays black.

How do I define my own colour?

Write \definecolor{brand}{HTML}{1F6FEB} in the preamble and use brand like any colour name. In Scissor LaTeX defined colours work in TikZ and pgfplots.

Why is my coloured formula black?

The colour is not one of the 17 basic names that formulas know here, for example a mix such as red!50 or a colour from \definecolor. Use a basic name such as red or blue.

Every example on this page is typeset by Scissor LaTeX when the site is built. Last updated 2026-11-06.