3

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{https://tex.stackexchange.com/}{https://tex.stackexchange.com/}
\end{center}
\end{document}
  • 2
    \usepackage[usenames,dvipsnames]{xcolor} instead of the corresponding with color – egreg Dec 20 '11 at 0:39
7

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}​

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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