# Problem with digits in URLs when using mathspec and hyperref

When I use mathspec's \setmathsfont and hyperref, and try to typeset a URL, most of the URL uses monospace, as it should. Good.

However, digits use the maths font. Anyone know how to fix this?

## MWE

\documentclass{article}
\usepackage{mathspec,fontspec,hyperref}

\setmathsfont(Digits){Minion Pro}
\setmonofont{Source Code Pro}

\begin{document}
\nolinkurl{abc123def} % same problem with \url{..}
\end{document}


## Output

-
@Qrrbrbirlbel: Thanks for the edit. I didn't have enough reputation to embed the image myself, of course. –  Andy Morris Feb 24 '13 at 21:28

The problem is due to the fact that mathspec makes the digits of type mathord not mathalpha. Then the work done by hyperref to set up to use the ttfamily does not conclude successfully for the digits, as it proceeds in math mode.

\documentclass{article}
\usepackage{mathspec,fontspec,hyperref}

\setmathsfont(Digits){Minion Pro}

\makeatletter
\DeclareMathSymbol{0}{\mathalpha}{\eu@DigitsArabic@symfont}{0}
\DeclareMathSymbol{1}{\mathalpha}{\eu@DigitsArabic@symfont}{1}
\DeclareMathSymbol{2}{\mathalpha}{\eu@DigitsArabic@symfont}{2}
\DeclareMathSymbol{3}{\mathalpha}{\eu@DigitsArabic@symfont}{3}
\DeclareMathSymbol{4}{\mathalpha}{\eu@DigitsArabic@symfont}{4}
\DeclareMathSymbol{5}{\mathalpha}{\eu@DigitsArabic@symfont}{5}
\DeclareMathSymbol{6}{\mathalpha}{\eu@DigitsArabic@symfont}{6}
\DeclareMathSymbol{7}{\mathalpha}{\eu@DigitsArabic@symfont}{7}
\DeclareMathSymbol{8}{\mathalpha}{\eu@DigitsArabic@symfont}{8}
\DeclareMathSymbol{9}{\mathalpha}{\eu@DigitsArabic@symfont}{9}
\makeatother

% \setmonofont{Source Code Pro}

\begin{document}
\nolinkurl{abc123def} % same problem with \url{..}
\end{document}


-
Works perfectly! Thankyou so much. –  Andy Morris Feb 25 '13 at 1:14
You're welcome! I looked for an option to mathspec package to do this, but there does not seem to be one, so I just copied-pasted from mathspec.sty and replaced \mathord by \mathalpha. The point is that hyperref does its things in math mode (after having set-up the font to be the mono font). –  user700902 Feb 25 '13 at 8:46