Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How do I specify color in RGB using \hypersetup in hyperref?

I know that this is the right way to do it with color names:

\hypersetup{colorlinks,breaklinks,
            urlcolor=Maroon,
            linkcolor=Maroon}

But I want Teal, which hyperref doesn't recognize. I know Teal = {0 128 128} in RGB, but the following code won't compile:

\hypersetup{colorlinks,breaklinks,
            urlcolor={0 128 128},
            linkcolor={0 128 128}}

I have tried it with comma separators, proportional values (e.g. 0 < x < 1), but to no avail. What is the right way to do it? Also mention the correct texdoc that I should read for further info.

share|improve this question
1  
To specify colors as RGB byte triplets as in your example, replace rbg with RGB in Geoffrey Jones answer below. E.g. urlcolor = [RGB]{0 128 128}. –  ntc2 Jan 27 at 8:49

2 Answers 2

up vote 17 down vote accepted

If you'd really prefer to specify RGB colours in \hypersetup without loading the (x)color package, you can always type them in directly like this:

\hypersetup{colorlinks,breaklinks,
            urlcolor=[rgb]{0,0.5,0.5},
            linkcolor=[rgb]{0,0.5,0.5}}

Still, as Ulrike mentioned, loading xcolor is usually the more comfortable way to go. Although probably a little overkill for your problem, this is how I generally proceed:

\usepackage[dvipsnames,svgnames,x11names,hyperref]{xcolor}

Note that you can specify multiple colour name spaces so long as you're not too concerned about name clashes (otherwise read the rules about this in the xcolor manual). Since you're loading xcolor to fit in with hyperref, don't forget to include the [hyperref] option as you go.

share|improve this answer
    
I wonder why there is no mention of the [rgb] option in texdoc hyperref? Do you happen to know where it is documented? –  Kit Oct 25 '10 at 1:09
1  
@Kit, like many things in TeX/LaTeX, the ultimate documentation is the source code itself. I just stuck my nose into hyperref.sty (and child packages that it loads) to figure out how it does things. Classic case of "no pain, no gain", wot? :) –  Geoffrey Jones Oct 25 '10 at 6:20
    
More like slowly but surely for me :) And also, the sooner I accept that source code is the best documentation, the better. And to be able to read source code, I'll need the TeXbook, right? –  Kit Oct 25 '10 at 13:27

You must define the name of color first. In the case of Teal it is not necessary as it is defines in svgnam.def, so you can use the svgnames option.

 \documentclass{book}
 \usepackage[svgnames]{xcolor}
 %\definecolor{Teal}{RGB}{0 128 128}
 \usepackage{hyperref}
 \hypersetup{colorlinks,breaklinks,
             urlcolor=Teal,
             linkcolor=Teal}
 \begin{document}
 \url{abc}
 \end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.