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.

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

enter image description here

share|improve this question
    
@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
add comment

1 Answer

up vote 4 down vote accepted

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}

digits in mono

share|improve this answer
    
Works perfectly! Thankyou so much. –  Andy Morris Feb 25 '13 at 1:14
1  
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
add comment

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.