52

Please, I'd like to use the blue color RGB (0,32,96) in LaTeX.

How can I do this?

I find this on the web:

\definecolor{ultramarine}{rgb}{0.07, 0.04, 0.56} 

But it is not the right color I search.

2
  • 5
    \usepackage{xcolor} and then \definecolor{ultramarine}{RGB}{0,32,96}
    – egreg
    Apr 19, 2015 at 15:52
  • 2
    @egreg Just to make sure, I immediately get it when googling this again: The emphasis lies on RGB in capital letters. RGB: [0, 255]; rgb: [0.0, 1.0] Nov 1, 2020 at 19:24

1 Answer 1

73

The color package also supports decimal values in the RGB color model that accepts integer values in the interval [0,255]. On the other hand, xcolor offers much more features, so it's better to use it.

\documentclass{article}
\usepackage{xcolor}

\definecolor{ultramarine}{RGB}{0,32,96}

\definecolor{wrongultramarine}{rgb}{0.07, 0.04, 0.56}

\begin{document}

\textcolor{ultramarine}{Ultramarine \rule{1cm}{1cm}}

\textcolor{wrongultramarine}{Wrong Ultramarine \rule{1cm}{1cm}}

\end{document}

enter image description here

On the other hand, you could just compute 32/255 and 96/255, getting

\definecolor{ultramarine}{rgb}{0, 0.125, 0.376}

that gives the very same color as with {RGB}{0,32,96}.

2
  • 1
    RGB works with color with the standard pdftex or dvips .def files Apr 19, 2015 at 16:50
  • Can I also use a \foreach\x variable in the color code similar to \definecolor{tmpcolor}{HSB}{\x,255,255}?
    – Someone
    2 days ago

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .