How-to

How to Change Text Color in LaTeX

The fix

Load \usepackage{xcolor} and use \textcolor{red}{your text} to colour a span, or {\color{blue} a block}. Define custom colours with \definecolor{myblue}{HTML}{2A5CAA} and use them the same way. xcolor also colours table rows, boxes, and (with hyperref) links.

Not sure it worked on your document? Paste it into LetX and compile it, free and in the browser.

Example

\usepackage{xcolor}
\textcolor{red}{Important}.
\definecolor{brand}{HTML}{2A5CAA}
{\color{brand} A custom-coloured sentence.}

Frequently asked questions

How do I use a custom hex colour?

Define it once with \definecolor{name}{HTML}{RRGGBB} (no # sign), then use \textcolor{name}{...}. Load xcolor first.

How do I colour a whole paragraph?

Use a group: {\color{blue} your paragraph}. \textcolor is best for short inline spans; \color applies until the group ends.

Related LaTeX fixes

Browse all LaTeX problems & fixes, or start with the LaTeX guide.

Try the fix in LetX

Open the editor, paste your code, and compile in seconds to see the error clear. Free, in your browser.

Open LetX Free