Open jebej opened 3 years ago
there are several things conspiring to make your example not work, compared to this version which does work
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Stix Two Math}
\begin{document}
\Umathcodenum`ħ=`ħ
hbar: $\hbar$
hbar unicode (U+0127): $ħ$
hslash: $\hslash$
hslash unicode (U+210F): $ℏ$
\end{document}
The Latin modern math font doesn't have U+0127, Stix does, but it does not work by default as U+0127 doesn't have a mathcode nor does the unicode-math-table.tex define \hbar
, just \hslash
.
the default math codes are based on the Uniocde data file MathClass-15.txt which is in texlive as texmf-dist/tex/generic/unicode-data/MathClass-15.txt and that only lists U+210F
One other issue that the engine default is math fam 1 but unicode-math sets everything in fam 0 and fam1 stays as the 7 bit computer math italic, so if you take a random character that does not get a specific math code from the data file
\Umathcharnumdef\zzz=\Umathcodenum"100DB
\show\zzz
\showthe\textfont1
you see:
> \zzz=\Umathchar"7"01"0100DB.
l.18 \show\zzz
?
> \OML/cmm/m/it/10 .
l.20 \showthe\textfont1
so as with hbar even if the open type fonts have the character the default in math is to take the character from computer modern math.
unicode-math could put the main font in slot 1 as well as slot 0 but that may have compatibility issues.
Thanks for your reply. I'll admit I'm not an expert with all this, in particular the fonts.
The Latin modern math font doesn't have U+0127
By default, latex include \hbar
with a horizontal bar, and amssymb
define the \hslash
macro. Are these both not from the Latin modern font? E.g. if I do not use unicode-math
and instead add amssymb
I obtain:
unicode-math
itself makes \hbar
equivalent to \hslash
, which is an other issue as well...
the default math codes are based on the Uniocde data file MathClass-15.txt which is in texlive as texmf-dist/tex/generic/unicode-data/MathClass-15.txt and that only lists U+210F
I suppose \hbar
U+0127 is considered text then. Assuming that this doesn't change, is the command you used, that is
\Umathcodenum`ħ=`ħ
the "proper" way to add input characters to unicode-math
?
It probably isn't the proper way , but it works, without having to look up the character number,making the character come from the font in fam 0 (and act like a fixed symbol, not changing for \mathbf
etc)
If you wanted to define \hslash
you could use the form used in unicode-math-table.tex
\UnicodeMathSymbol{"0210F}{\hslash }{\mathalpha}{/hslash - variant planck's over 2pi}%
(note I don't have write access here, just an interested observer....)
For reference, \hbar
is included as a math symbol here: https://www.w3.org/Math/characters/unicode.xml
unicode.xml is my file:-) actually the latest (Uniocde 13) version is https://w3c.github.io/xml-entities/unicode.xml
210F has
<character id="U0210F" dec="8463" mode="math" type="alphabetic">
<unicodedata category="Ll" combclass="0" bidi="L" decomp="<font> 0127" mirror="N" unicode1="PLANCK CONSTANT OVER 2 PI" mathclass="N"/>
<afii>EF68</afii>
<latex>\hslash </latex>
<mathlatex set="unicode-math">\hslash</mathlatex>
0127 has
<character id="U00127" dec="295" mode="math" type="alphabetic">
<unicodedata category="Ll" combclass="0" bidi="L" mirror="N" unicode1="LATIN SMALL LETTER H BAR" upper="0126" title="0126"/>
<afii>E2EB</afii>
<latex>\Elzxh </latex>
note the lack of a mathclass
entry in <unicodedata
(because it is not in MathClass-15.txt) and lack of <mathlatex>
element (as it is not in unicode-math-table.tex
)
For classic tex \hbar
is not a character in the font it is a small horizontal bar sone negative space then an h.
the problem is that Unicode has a specific slot for this (U+0127) so in xetex of luatex the character is just passes straight through as data like h
but then if the font does not have that character you get no output and a Missing Character
warning in the log file. You could set things up to over-print a bar and an h in unicode-math as well, but then (without more complicated tests) fonts like Stix that do have the character would "lose" the character and also get the constructed version
Description
The unicode symbol
U+0127
(ħ) is not defined and so does not appear when used.Minimal example demonstrating the issue
Compiling with
lualatex unicode-test.tex
outputs: