3

I'm studying how fonts and symbols work, and can't understand how the quoted code gives me the attached output.

For the record: thanks to nice people from this community I already have reasonably working solutions for Cyrillics in math, both with mathspec and unicode-math packages. I'd like to make those more versatile.

Why isn't backtick + Cyrillic glyph working?

Why are some symbols from the font I use (which actually are present in the font), like long integral sign parts and plusminus substituted by standard TeX glyphs?

I'm using XeTeX 3.141592653-2.6-0.999994 (TeX Live 2022 on Slackware).

\documentclass{article}

\usepackage{amsmath}
\usepackage{mathspec}

\setmainfont{Liberation Serif}
\SetMathAlphabet{\mathrm}{normal}{TU}{\familydefault}{m}{n}
\SetMathAlphabet{\mathit}{normal}{TU}{\familydefault}{m}{it}
\SetMathAlphabet{\mathbf}{normal}{TU}{\familydefault}{b}{n}

% looking at mathspec sources
\DeclareSymbolFont{Cyrillic:m:n}{TU}{\familydefault}{m}{n}
\DeclareMathSymbol{А}{\mathalpha}{Cyrillic:m:n}{`А}
\DeclareMathSymbol{а}{\mathalpha}{Cyrillic:m:n}{`а}
\DeclareMathSymbol{Я}{\mathalpha}{Cyrillic:m:n}{`Я}
\DeclareMathSymbol{я}{\mathalpha}{Cyrillic:m:n}{`я}

\setmathsfont(Digits,Latin,Greek){Liberation Serif}
\setmainfont{Liberation Serif}

\begin{document}
% text mode, to see proper outlines
А ~ Б ~ С ~ Д ~ 123 ~ ± ~ µ ~ υ ~ ζ ~ ∫ 1/x

% this is in \mathnormal
$ А_а ~ АаЯя $ ~~~<--- should be \it{ А\textsubscript{а} АаЯя}

% this is in \mathalpha's
$\mathrm{Б_б \zeta} ~ \mathit{C_с \zeta} ~ \mathbf{Д_д \zeta} ~ 123 ~ \pm ~ \mu ~ \upsilon ~ \zeta ~ 1.2 , 2.3  \int 1/x $

\end{document}

Output is here

1
  • I can't even include both mathspec and unicode-math, at least on my system. \Declare... and \Set instructions are from core latex (per latex fontguide), and the specific use with backtick+non-latin glyph name I've lifted from mathspec sources.
    – yury10578
    Jun 26, 2023 at 12:29

1 Answer 1

6

The command \DeclareMathSymbol doesn't go beyond slot 255. You need \Umathcode.

\documentclass{article}

\usepackage{amsmath}
\usepackage{mathspec}

\setmainfont{Liberation Serif}
\DeclareMathAlphabet{\mathrm}{TU}{\familydefault}{m}{n}
\DeclareMathAlphabet{\mathit}{TU}{\familydefault}{m}{it}
\DeclareMathAlphabet{\mathbf}{TU}{\familydefault}{b}{n}

% looking at mathspec sources
\DeclareSymbolFont{Cyrillic}{TU}{\familydefault}{m}{it}
\Umathcode`А="0 \symCyrillic `А
\Umathcode`а="0 \symCyrillic `а
\Umathcode`Я="0 \symCyrillic `Я
\Umathcode`я="0 \symCyrillic `я

\setmathsfont(Digits,Latin,Greek){Liberation Serif}


\begin{document}
% text mode, to see proper outlines
А ~ Б ~ С ~ Д ~ 123 ~ ± ~ µ ~ υ ~ ζ ~ ∫ 1/x

% this is in \mathnormal
$ А_а АаЯя $ ~~~<--- should be \textit{А\textsubscript{а}АаЯя}

% this is in \mathalpha's
$\mathrm{Б_б \zeta} ~ \mathit{C_с \zeta} ~ \mathbf{Д_д \zeta} ~ 
  123 ~ \pm ~ \mu ~ \upsilon ~ \zeta ~ 1.2 , 2.3  \int 1/x $

\end{document}

enter image description here

Aside: you seem to think that \it is a command taking an argument. It isn't, because it's a declaration, so {\it ...} would be the correct syntax, weren't for the fact that \it (and other two-letter font changing commands) has been deprecated for almost 30 years.

5
  • Thank you! So how does mathspec code work then, with lots of \DeclareMathSymbol-s with backtick+Greek glyph as their arguments? In TeX distro's dir I see a database of Unicode glyphs mappings to \math... types, but it doesn't seem to be used. Or is there just a bunch of \Umathcode's in the core declaring Greek glyphs to be in \mathalpha? P.S. Please disregard my use of \it, it was just a kind of nervous tick.
    – yury10578
    Jun 26, 2023 at 12:39
  • Also, could you clarify a bit more, please? Do I have to use \Umathcode with 0 type or with 7 type properly? And why are 'plusminus' and 'long integral sign' not taken from 'Liberation Serif', although they actually are in it?
    – yury10578
    Jun 26, 2023 at 12:44
  • @yury10578 You should be aware that mathspec is a long series of hacks. You can use "7 if you so prefer.
    – egreg
    Jun 26, 2023 at 12:49
  • Doesn't it matter at all, whether 0 or 7 is used? Nevermind, thanks, and what about the second part of my question (plusminus and other symbols not being taken from the employed font - without anything reported in the logs or in the console at that)? Is it fixable? Does it seem to be mathspec's issue?
    – yury10578
    Jun 26, 2023 at 12:59
  • @yury10578 As I said, mathspec is a hack. Finding one's way into it usually is an adventure. Good luck.
    – egreg
    Jun 26, 2023 at 13:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .