# Different font for numbers in URLs [duplicate]

I am using mathspec to make the fonts in math mode match the roman fonts used in my text body. The “digits” environment in mathspec takes effect for all digits in the document. This means that digits that would normally use a font other than roman, such as those within URLs, also end up using this font, despite loading the mathspec command \setallmonofonts (which I had assumed would override \setmathfont).

\documentclass{article}

\usepackage{mathspec}
\setmainfont{Book Antiqua}
\setmathfont(Digits,Latin){Book Antiqua}
\setallmonofonts{Courier New}

\begin{document}
Some text. Some figures: 123456789\\
\url{http://some.urlwithnumbers/123456789}

$$Some text in math mode. Some figures in math mode: 12345789$$

\end{document}


Is there a way of setting the font for only the digits that occur in math mode? I would like to keep my specified monospace font for digits within monospaced strings (and likewise with sans serif fonts, should I need to use them).

## marked as duplicate by Stefan Pinnow, Mensch, Community♦Dec 3 '18 at 17:23

The trick from https://tex.stackexchange.com/a/99774 seems to work:

\documentclass{article}

\usepackage{mathspec}
\setmainfont{Arial}
\setmathfont(Digits,Latin){Arial}
\setallmonofonts{Courier New}

\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

$Some text in math mode. Some figures in math mode: 12345789$