7

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

  • @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
7

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

  • 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). – user4686 Feb 25 '13 at 8:46
  • I also ran into this problem. Now I'm wondering, is this a bug? If so, in which package, hyperref or mathspec? – ph0t0nix Jan 27 '16 at 17:09
  • @ph0t0nix The legacy LaTeX setup declares the digits of variable family type (aka "mathalpha") in order to be able to access old style figures via \mathnormal: $\mathnormal{0123456789}$. Package mathspec perhaps decided this did not make sense anymore in the context of Unicode type fonts. As per hyperref, well, it can not have to think about all possibilities; perhaps include a note in its documentation. Same can be said of mathspec. – user4686 Jan 28 '16 at 13:43

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.