Accessible TeX colors

Summary: Instead of using \textcolor{red}, green, and blue, use purple, teal, and blue. Want more colors? Use \usepackage{ninecolors}.

Which default LaTeX colors are readable?

The set of LaTeX default colors are chosen primarily to be a mathematically clean subsample of the RGB space. For example, red, green, and blue are just #FF0000, #00FF00, and #0000FF—the codes look nice, but the actual colors have drastically different brightnesses ■■■. This leads to some unintuitive behavior, like \textcolor{green} making text pretty unreadable. (See this example?)

I wanted to find some simple-to-state advice for what to use instead, so I went through the list of default colors and checked which met the web standard for being readable against a white page. (See the tables at the bottom for more specifics, and additional data for dvipsnames colors.)

6 meet this standard for use as text color against a white background: blue, purple, teal, violet, black, and darkgray. Note that red is not on this list! I think this makes sense: I often see default red in papers, but it is bright to the point that it slightly hurts readability, at least for me. (See this example?)

So, in short, you only wanted to use default colors, purple, teal, and blue would serve as good replacements for a red, green, and blue.

Other color advice

Here’s some other general strategies I use to pick colors for talks/papers.

ninecolors package

In 2021, the ninecolors TeX package was released. It defines reasonable defaults for color choices (for example, here are their colors red4, green4, and blue4), and I’ve used it for papers ever since. Recommend.

Steal colors from data visualization software

If I need more than one color, I often just copy existing sets of colors from matplotlib, Tableau, Excel. They’ve already done all of the hard work of making colors look nice together while also making colors maximally distinguishable, even for colorblind viewers. This sort of software also often has excellent documentation about how to use colors in plots and things.

Don’t steal color schemes from text editors

Once, I gave a talk using the solarized dark theme, and then someone later told me that the slides were very hard to read. Since then, I’ve heard other people make this exact mistake as well. And I think it’s quite a bad mistake: even if everyone can technically make out the text on the slides if they try, once someone in the back starts daydreaming, you will not get them back unless your slide is immediately legible at a glance.

Coding color schemes are often designed to have less contrast between light and dark. This means that they’re harder to read. And for talk slides in particular, you want your text to be easily readable, even for those sitting in the back, and for those with weaker eyesight. (And I think generally “light mode” is preferred over “dark mode”, since the former projects better across various lighting conditions.)

Don’t rely on color too much

As a final comment on accessibility, I want to point out the guideline that no crucial information should be communicated solely through color. I highlight important things with colors all the time. But I try to follow the guideline that, if my document was printed in grayscale, someone could still understand it.

Appendix: methodology and data

There’s accessibility guidelines for how large the contrast of text needs to be against its background. It’s designed for the web, but since pdfs are typically viewed on screens, I used it as the standard.

What these guidelines give is a formula to measure the relative luminance of the two colors, and then measure the relative contrast between them. If the contrast is above 4.5 to 1, it meets the minimum bar for being used for body text.

There are 19 default LaTeX colors. I used a color checker to check the contrast.

color hex code contrast ratio
red FF0000 â–  3.99
green 00FF00 â–  1.37
blue 0000FF â–  8.59
brown C08040 â–  3.27
lime C0FF00 â–  1.19
orange FF8000 â–  2.51
pink FFC0C0 â–  1.54
purple C00040 â–  6.33
teal 008080 â–  4.77
violet 800080 â–  9.41
cyan 00FFFF â–  1.25
magenta FF00FF â–  3.13
yellow FFFF00 â–  3.99
olive 808000 â–  4.19
black 000000 â–  21
darkgray 404040 â–  10.36
gray 808080 â–  3.94
lightgray C0C0C0 â–  1.81
white FFFFFF â–  1

And here are the colors named by dvips, sorted by contrast.

color hex code contrast ratio
White FFFFFF â–  1
Yellow FFF200 â–  1.16
Goldenrod FFDF42 â–  1.32
GreenYellow DFE674 â–  1.33
SpringGreen C6DC67 â–  1.51
Dandelion FDBC42 â–  1.68
Apricot FBB982 â–  1.69
YellowGreen 98CC70 â–  1.87
Lavender F49EC4 â–  1.99
LimeGreen 8DC73E â–  2.02
SkyBlue 46C5DD â–  2.04
YellowOrange FAA21A â–  2.04
Melon F89E7B â–  2.06
Peach F7965A â–  2.21
Salmon F69289 â–  2.23
BurntOrange F7921D â–  2.31
Tan DA9D76 â–  2.31
SeaGreen 3FBC9D â–  2.36
CarnationPink F282B4 â–  2.43
CornflowerBlue 41B0E4 â–  2.45
ProcessBlue 00B0F0 â–  2.47
Turquoise 00B4CE â–  2.49
Aquamarine 00B5BE â–  2.51
Cyan 00AEEF â–  2.52
BlueGreen 00B3B8 â–  2.57
Orange F58137 â–  2.59
Thistle D883B7 â–  2.67
TealBlue 00AEB3 â–  2.72
Cerulean 00A2E3 â–  2.88
Emerald 00A99D â–  2.93
JungleGreen 00A99A â–  2.94
Gray 949698 â–  2.96
Green 00A64F â–  3.19
VioletRed EF58A0 â–  3.19
RedOrange F26035 â–  3.23
Rhodamine EF559F â–  3.24
Orchid AF72B0 â–  3.58
ForestGreen 009B55 â–  3.6
WildStrawberry EE2967 â–  4.07
Periwinkle 7977B8 â–  4.08
Magenta EC008C â–  4.24
PineGreen 008B72 â–  4.25
RubineRed ED017D â–  4.28
OrangeRed ED135A â–  4.33
Red ED1B23 â–  4.39
CadetBlue 74729A â–  4.54
Bittersweet C04F17 â–  4.8
OliveGreen 3C8031 â–  4.85
DarkOrchid A4538A â–  5.02
RoyalBlue 0071BC â–  5.13
NavyBlue 006EB8 â–  5.35
Mulberry A93C93 â–  5.59
Purple 99479B â–  5.63
BrickRed B6321C â–  6.06
MidnightBlue 006795 â–  6.22
Maroon AF3235 â–  6.3
Mahogany A9341F â–  6.56
RawSienna 974006 â–  6.88
Fuchsia 8C368C â–  6.95
RedViolet A1246B â–  7.04
Plum 92268F â–  7.25
RoyalPurple 613F99 â–  7.83
Violet 58429B â–  7.87
BlueViolet 473992 â–  9.25
Brown 792500 â–  10.1
Blue 2D2F92 â–  10.86
Sepia 671800 â–  12.29
Black 221E1F â–  16.48

Bolded are the ones that meet the contrast guidelines against a white background. Overall, the colors that remain are pretty unsatisfying: for example, there’s only one green. This is why I was so happy to see the ninecolors package when it came out; it is much more usable as a set of colors than any other package I am familiar with.