2

I am using LuaLaTeX with the fontspec and unicode-math packages. The digits 0-9 do not always display in the same style (italic, bold, etc.) as the alphanumerics. Since a name can be more than one letter, and can include digits, the digit style should match the letter sytle. The unicode-math documementation states that is deliberate -- but does not offer a way to change it. The older mathspec package may (I am not totally sure), but it is explicitly stated to be incompatible with unicode-math.

If my normal or sans font doesn't have the styles, then a fallback is reasonable. But, if it does - as when I explicitly provide those font variants, I expect that, for example, when I use symsfit or mathsfit that I get exactly what I requested. If I wanted symsfup or mathsfup then I would have used that.

Is there a way to change this default behavior?

I thought that this did not need an example, but by request I am adding an example. I have explicitly chosen the GNU free fonts so that I can explicitly specify each of four font variants. I can open those fonts in FontLab and verify that they do have the required glyph variants. Notice that for the sans-serif example, not only does the italic / bold not match, but it actually uses the serif font for its substitution

\documentclass{amsart}

\usepackage{fontspec}
\usepackage{unicode-math}

    \setmainfont{FreeSerif}[
       ItalicFont     = FreeSerifItalic,
       BoldFont       = FreeSerifBold,
       BoldItalicFont = FreeSerifBoldItalic]

   \setsansfont{FreeSans}[
      ItalicFont     = FreeSansOblique,
      BoldFont       = FreeSansBold,
      BoldItalicFont = FreeSansBoldOblique]

\begin{document}

   \setlength{\parindent}{0em}

   $ \mathsfup{0 1 2 3 4 5 6 7 8 9}                                 $   \\
   $ \mathsfup{a b c d e f g h i j k l m n o p q r s t u v w x y z} $   \\
   $ \mathsfup{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} $   \\

   $ \mathsfit{0 1 2 3 4 5 6 7 8 9}                                 $   \\
   $ \mathsfit{a b c d e f g h i j k l m n o p q r s t u v w x y z} $   \\
   $ \mathsfit{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} $   \\

   $ \mathbfsfup{0 1 2 3 4 5 6 7 8 9}                                 $ \\
   $ \mathbfsfup{a b c d e f g h i j k l m n o p q r s t u v w x y z} $ \\
   $ \mathbfsfup{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} $ \\

   $ \mathbfsfit{0 1 2 3 4 5 6 7 8 9}                                 $ \\
   $ \mathbfsfit{a b c d e f g h i j k l m n o p q r s t u v w x y z} $ \\
   $ \mathbfsfit{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} $ \\

   $ \mathup{0 1 2 3 4 5 6 7 8 9}                                 $     \\
   $ \mathup{a b c d e f g h i j k l m n o p q r s t u v w x y z} $     \\
   $ \mathup{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} $     \\

   $ \mathit{0 1 2 3 4 5 6 7 8 9}                                 $     \\
   $ \mathit{a b c d e f g h i j k l m n o p q r s t u v w x y z} $     \\
   $ \mathit{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} $     \\

   $ \mathbfup{0 1 2 3 4 5 6 7 8 9}                                 $   \\
   $ \mathbfup{a b c d e f g h i j k l m n o p q r s t u v w x y z} $   \\
   $ \mathbfup{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} $   \\

   $ \mathbfit{0 1 2 3 4 5 6 7 8 9}                                 $   \\
   $ \mathbfit{a b c d e f g h i j k l m n o p q r s t u v w x y z} $   \\
   $ \mathbfit{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} $   \\

 \end{document}
3
  • 1
    Make a complete example. That will make it much easier to understand your problem. Jul 24, 2018 at 19:23
  • Just an addition: mathspec and unicode-math follow very different aims (with mathspec being XeLaTeX-centered). So do you basically want your text font to be used as math font?
    – TeXnician
    Jul 25, 2018 at 6:04
  • Not exactly. The math font has sans-serif, mono and serif math fonts present. However, even when the glyph variations are present it assumes that numbers should always be in the same form. But, if I specify a specific form (e.g. bold, italic) I expect to get exactly what I specified. That is not the case, and hopefully there is a way to suppress that interference. If not, I will need to load separate fonts for each use and define my own symXxx and mathXxx commands as a work-around. I may not be able to match the font style as cleanly as actually using the math font. Jul 25, 2018 at 9:49

2 Answers 2

2

unicode-math maps only a few of the math alphabet commands to the text font (the whole list is imho mathrm/mathup, mathit, mathbf ,mathsf and mathtt). So \mathsf will use it, but \mathsfup and \mathsfit will not, they instead use the math symbols from the mathplane. As there are not italic/slanted numerals there you get upright numerals.

If you want an slanted "text" math alphabet you will have to define a new math alphabet:

\documentclass{article}

\usepackage{unicode-math}

\setsansfont{FreeSans}

\setmathfontface\mymathsfit{FreeSansOblique}
\begin{document}

   \noindent\textsf{0aA}  text\\
   \textsf{\textsl{0aA}}  text, slanted\\ 
   $ \mathsf{0aA}     $   mathsf \\
   $ \mathsfup{0aA}   $   mathsfup\\
   $ \mymathsfit{0aA} $   mymathsfit 

\end{document}

enter image description here

1
\documentclass{article}
\usepackage{unicode-math}
\usepackage{libertine}
\setmathfont{Neo Euler}
\setmathfont{Linux Libertine O}[range=up/{num}]% 0..9 from Libertine

\begin{document}    
ABC$0123$0123abc

\setmathfont{Neo Euler}% overwrite old definition
ABC$0123$0123abc    
\end{document}

enter image description here

3
  • This did not work when I tried it. I posted a working example above using the GNU free fonts. Jul 24, 2018 at 23:45
  • Look into the documentationof unicode-math. There you'll find some explanations why numbers are always upright.
    – user2478
    Jul 26, 2018 at 5:23
  • I have read that extensively. The explanation for why is really weak - and I can't actually think of a use case that justifies changing an explicit italic, bold or bold italic to something else. If you are writing a number as in 123.45 then you would always use symup or mathup. But, if you are writing something that potentially contained numbers and you used symit{} or symbfit{} then it would be horrendous to have the font mismatch. It could be the case that you want numbers to be italic or bold to match the context. This is really a situation of let the user decide and don't interfere. Jul 26, 2018 at 6:52

You must log in to answer this question.

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