latex3 / unicode-math

XeLaTeX/LuaLaTeX package for using unicode/OpenType maths fonts
http://ctan.org/pkg/unicode-math
LaTeX Project Public License v1.3c
241 stars 28 forks source link

Changing math font for ranges breaks redering of URLs with Hyperref #458

Open Wrzlprmft opened 6 years ago

Wrzlprmft commented 6 years ago

Description

If I change the math font for a range of characters, these characters break in URLs set by hyperref.

Check/indicate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{unicode-math,hyperref}
\setmathfont[range=up/{num}->sf]{Asana Math}
\begin{document}
\url{a1b2c3d4e}
\end{document}

In the output the numbers are replaced by spaces.

Further details

Issue #228 is similar

u-fischer commented 6 years ago

I think unicode-math should not only add \__um_switchto_up: to \Url@FormatString but also switch the digits back to the symoperator family: (I'm using here \Url@MathSetup for the patch as it is executed behind the \__um_switchto_up:):

\documentclass{article}
\usepackage{unicode-math}
\usepackage{url}
\setmathfont{Asana Math}
\setmathfont[range=up/{num}->sf]{Asana Math}

\usepackage{xpatch}
\makeatletter
\preto\Url@MathSetup
 {%
  \Umathcode 48=7\symoperators 48
  \Umathcode 49=7\symoperators 49
  \Umathcode 50=7\symoperators 50
  \Umathcode 51=7\symoperators 51
  \Umathcode 52=7\symoperators 52
  \Umathcode 53=7\symoperators 53
  \Umathcode 54=7\symoperators 54
  \Umathcode 55=7\symoperators 55
  \Umathcode 56=7\symoperators 56
  \Umathcode 57=7\symoperators 57
 }
\makeatother

\begin{document} 

$1=a$ 

\url{a1b2/~#c3d4e56789} 

\urlstyle{sf}
\url{a1b2/~#c3d4e56789} 

\urlstyle{rm}
\url{a1b2/~#c3d4e56789} 

\end{document}

image