3

I am using the unicode-math package with XeLaTeX. It works well, but it is making some of my characters look weird. Specifically, the code

f \colon x \mapsto x^2

looks different from normal. Normally, it looks like this:

Without unicode-math

However, when I use unicode-math, it looks like this:

With unicode-math

In the second image, the space between the dots in the \colon is too small. Also, the vertical bar on the \mapsto is too large and the horizontal bar is too short. How can I fix this?

I also had a similar issue with \mathbb{R} looking different, but when I googled a solution to that I found this similar question with this working solution. Is there anyway to do something similar for my problem with \colon and \mapsto?

Example:

\documentclass{article}
\usepackage{unicode-math}

\begin{document} [f\colon x\mapsto x^2] \end{document}

Rango
  • 41
  • 5
  • 3
    As always on this site: please provide a full but minimal example that others can copy and test as is. Here we have no idea what you are doing other than using unicode-math, there is no information about fonts etc. – daleif May 16 '23 at 14:45
  • 1
    Apologies, I am new to tex.stackexchange. I have not done anything with fonts. I edited in the code I used in another file to isolate the issue, as the issue still persists with only the code that I edited in. – Rango May 16 '23 at 16:54

2 Answers2

3

There are a few aspects to mention: unicode-math uses

  1. U+2236 RATIO for the colon in math mode;
  2. U+21A6 RIGHTWARDS ARROW FROM BAR for \mapsto;
  3. the amsmath definition of \colon (not simply \mathpunct).

To the contrary, legacy 8-bit LaTeX uses

  1. the text colon also in math mode;
  2. the combination \mapstochar+\rightarrow to build \mapsto;
  3. \mathpunct: for \colon (actually a different definition, but the effect is the same).

It's a job for the font designers to decide the shape for U+2236 and U+21A6. For strange reasons, the designers of Latin Modern Math decided that U+2236 has width 9.77pt, less than U+2192 RIGHTWARDS ARROW (used for \rightarrow) that has width 10pt (at natural size of the font). The same choice is done by NewCMMath.

You can restore the legacy behavior.

\documentclass{article}
\usepackage{unicode-math}
\usepackage{amsmath}

\DeclareSymbolFont{legacysymbols}{OMS}{cmsy}{m}{n} \DeclareMathSymbol{\legacymapstochar}{\mathrel}{legacysymbols}{"37}

\AtBeginDocument{% % use \mapstochar\rightarrow for \mapsto \RenewDocumentCommand{\mapsto}{}{\legacymapstochar\rightarrow}% % use the text colon for \colon as math punctuation \RenewDocumentCommand{\colon}{}{\Umathchar"6 "0 "3A\relax} }

\begin{document}

\begin{gather} f\colon x\mapsto x^2 \ f\colon x\rightarrow x^2 \end{gather}

\end{document}

enter image description here

egreg
  • 1,121,712
  • This worked, thank you! – Rango May 17 '23 at 01:01
  • By the way, how can I adapt this to other characters? I am also running into the same difficulty with \therefore and am having trouble adapting this to fix that. – Rango May 17 '23 at 11:56
  • @wwjwjwjwj Don’t use \therefore. It might be useful at the blackboard, not in print. And, in general, don’t be too attached to particular shapes. – egreg May 17 '23 at 13:14
  • 1
    Of course, I would not use \therefore for anything official, but I also use LaTeX for my notes in which I use \therefore a lot. I guess you are right, I should not be too attached to the shape, but I still would prefer to know how to adapt this solution to arbitrary characters incase I need it in the future. – Rango May 17 '23 at 15:00
3

The reason why the math colon is re-designed in Unicode math fonts (at the slot U+2236) depends on the typographical rule that all math operators and symbols should be vertically centered at math axis (like +, -, \to, \mapsto, \sum). The text colon doesn't meet this requirement as you can see in the pictures where the legacy math font is used. If you realize this, the Unicode math result may start to seem better to you.

uniclon

wipet
  • 74,238