How to use custom colours in LaTeX

I will post short minimum working examples (MWEs) of minimal LaTeX documents, showing a certain feature in action. Though the well-maintained LaTeX Wikibook is a much more extensive resource than a collection of such examples could ever be, they show directly compilable examples compared to isolated snippets.

I start simple: custom text colours, using different colour models. Shown here are RGB (0-255) and HTML (00-FF) style definitions. The text shows two different ways to access them. Bonus: these colours can be used in TikZ as well.

latex-xcolors

[code lang=”latex” gutter=”0″]
\documentclass{article}
\usepackage{xcolor}
\definecolor{cool}{RGB}{0, 110, 220}
\definecolor{heat}{RGB}{240, 120, 40}
\definecolor{pink}{HTML}{FF00FF}
\begin{document}
I am some \textcolor{heat}{really hot},
though \textcolor{cool}{also cold} text.
{\color{pink}Bright colors} are discouraged.
\end{document}
[/code]


Posted

in

,

by

Tags: