latex3 / unicode-math

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

Inconsistency in remapping literal characters #549

Open DamienRobert opened 4 years ago

DamienRobert commented 4 years ago

In the current version:

\__um_new_alphabet_config:nnn {up} {Latin}
  {
    \bool_if:NTF \g__um_literal_bool { \__um_set_normal_Latin:nn {up} {#1} }
      {
        \bool_if:NT \g__um_upLatin_bool { \__um_set_normal_Latin:nn {up,it} {#1} }
      }
    \__um_set_mathalphabet_Latin:nnn {up} {up,it} {#1}
    \__um_set_mathalphabet_Latin:nnn {literal} {up} {up}
    \__um_set_mathalphabet_Latin:nnn {literal} {it} {it}
  }

We see that if we remap up/latin to eg sf then if the literal feature is active $a$ will give an sf a (I think the reasoning is that in literal mode an upright a is mapped to an upright a which is remapped to an sf a).

But a $\symliteral{a}$ is still an upright a. For consistency, I think the code should instead be

    \__um_set_mathalphabet_Latin:nnn {literal} {up} {#1}

By the way, shouldn't the line

    \__um_set_mathalphabet_Latin:nnn {literal} {it} {it}

be in \__um_new_alphabet_config:nnn {it} {Latin}? And then we can also use

\__um_set_mathalphabet_Latin:nnn {literal} {it} {#1}
wspr commented 4 years ago

Thanks! You are brave to look through the source code here… would you mind also adding an example of the currently-inconsistent behaviour? That would help me a lot to add a test file when the behaviour is fixed.

DamienRobert commented 4 years ago

Sorry for the delay... Here is a minimal sample, where the first two $a$ are mapped to the sf version, but the last a is still in the rm version.

\documentclass{article}
\usepackage[normal-style=literal]{unicode-math}
\setmathfont{latinmodern-math.otf}
\setmathfont[range=up->sfup]{latinmodern-math.otf}
\begin{document}
$a$

$\symup{a}$

$\symliteral{a}$

\end{document}

By the way compiling this gives me a

Missing number, treated as zero.
<to be read again> 
\c__um_sfup_greek_usv

but I did not investigate further why.

wspr commented 4 years ago

Oh, that error is a known issue that I’ve been hoping to get fixed at the Unicode end. There are no sans serif regular weight greek symbols in Unicode — IMO an oversight. But to get it fixed they have asked me to find examples of sans serif greek in published mathematics (differentiated from serif greek).

Unfortunately even though \mathsf{} does work in LaTeX I’ve found next to nothing in actual use. Any leads?