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.

I've defined a different color for hyperlink using \hypersetup command with urlcolor. When I am compiling it with XeLaTeX I am getting undefined color error for the URL link, but it works fine when I compile with LaTeX (the color of the link changes). Similar error have been discussed before here and here, but my problem seems to be a bit different. Below is a simplified example of code I am trying to compile:

\documentclass[10pt, a5paper]{article}
\usepackage{fontspec}
\PassOptionsToPackage{pdftex,usenames,dvipsnames}{color}
\usepackage[bookmarks, colorlinks, breaklinks]{hyperref}
\hypersetup{linkcolor=blue,citecolor=blue,filecolor=black,urlcolor=MidnightBlue} 
\begin{document}
\begin{center}
\href{http://tex.stackexchange.com/}{http://tex.stackexchange.com/}
\end{center}
\end{document}
share|improve this question
2  
\usepackage[usenames,dvipsnames]{xcolor} instead of the corresponding with color –  egreg Dec 20 '11 at 0:39

1 Answer 1

up vote 6 down vote accepted

You would also receive a host of other errors. Here it is best to use

\usepackage[usenames,dvipsnames]{xcolor}

rather than "passing the options to the package". Since you're processing your file under xelatex anyway, I've dropped the driver support pdftex. By default I use xcolor, although you could also use color.

enter image description here

\documentclass[10pt, a5paper]{article}
\usepackage{fontspec}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[bookmarks, colorlinks, breaklinks]{hyperref}
\hypersetup{linkcolor=blue,citecolor=blue,filecolor=black,urlcolor=MidnightBlue} 
\begin{document}
\begin{center}
\href{http://tex.stackexchange.com/}{http://tex.stackexchange.com/}
\end{center}
\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.