1

Here's my MWE:

Computer Modern vs. Latin Modern's mathbb and mathcal

% !TEX program = lualatex

% DOCUMENT CLASS
\documentclass[11pt,preview,varwidth,%
border={5pt 5pt 5pt 5pt}% left bottom right top
]{standalone}

% PACKAGES
\usepackage{mathtools, amssymb} % Math packages

\let\oldmathbb\mathbb % Computer Modern blackboard bold
\let\oldmathcal\mathcal % Computer Modern calligraphic
\AtBeginDocument{\def\mathbb{\oldmathbb}} % Redefine \mathbb to use Computer Modern
\AtBeginDocument{\def\mathcal{\oldmathcal}} % Redefine \mathcal to use Computer Modern

\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math} % Math fonts
\setmathfont{Latin Modern Math}
\let\newmathbb\mathbb % Latin Modern blackboard bold
\let\newmathcal\mathcal % Latin Modern calligraphic

\newcommand{\AtoZ}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}

% START OF DOCUMENT
\begin{document}
    Computer Modern's \verb|\mathbb|: \(\mathbb{\AtoZ}\)
    
    Latin Modern's \verb|\mathbb|: \(\newmathbb{\AtoZ}\)
    
    Computer Modern's \verb|\mathcal|: \(\mathcal{\AtoZ}\)
    
    Latin  Modern's \verb|\mathcal|: \(\newmathcal{\AtoZ}\)
\end{document}
% END OF DOCUMENT

I am trying to mainly use Computer Modern's blackboard bold (\mathbb) and calligraphic (\mathcal) fonts in LuaTeX with the unicode-math package simply because I prefer them over Latin Modern's (in those particular cases) but I would still want to be able to access Latin Modern's blackboard bold and calligraphic fonts, hence the \newmathbb and \newmathcal macros.

As seen from my MWE, I seem to have a problem accessing Computer Modern's calligraphic font for some reason.

I've read this TeX.SX answer but when I used \setmathfont[range={cal}]{cmsy10}, I ended up not being able to access Latin Modern's calligraphic font instead as it seems to globally change every calligraphic font to cmsy10:

Attempted Solution #1

% !TEX program = lualatex

% DOCUMENT CLASS
\documentclass[11pt,preview,varwidth,%
border={5pt 5pt 20pt 5pt}% left bottom right top
]{standalone}

% PACKAGES
\usepackage{mathtools, amssymb} % Math packages

\let\oldmathbb\mathbb % Computer Modern blackboard bold
\AtBeginDocument{\def\mathbb{\oldmathbb}} % Redefine \mathbb to use Computer Modern

\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math} % Math fonts
\setmathfont{Latin Modern Math}
\let\newmathbb\mathbb % Latin Modern blackboard bold
\let\newmathcal\mathcal % Latin Modern calligraphic
\setmathfont[range={cal}]{cmsy10} % Computer Modern calligraphic

\newcommand{\AtoZ}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}

% START OF DOCUMENT
\begin{document}
    Computer Modern's \verb|\mathbb|: \(\mathbb{\AtoZ}\)
    
    Latin Modern's \verb|\mathbb|: \(\newmathbb{\AtoZ}\)
    
    Computer Modern's \verb|\mathcal|: \(\mathcal{\AtoZ}\)
    
    Latin  Modern's \verb|\mathcal|: \(\newmathcal{\AtoZ}\)
\end{document}
% END OF DOCUMENT

(I received the warnings Package fontspec Warning: Font "cmsy10" does not contain requested Script "Math"., Package fontspec Warning: OpenType feature 'Style=MathScript' (ssty) not available for font 'cmsy10' with script '' and language 'Default'., and Package fontspec Warning: OpenType feature 'Style=MathScriptScript' (ssty) not available for font 'cmsy10' with script '' and language 'Default'.)

I've also read another TeX.SX answer but when I tried its approach I still couldn't use both Computer Modern and Latin Modern's calligraphic fonts at the same time:

Attempted Solution #2

% !TEX program = lualatex

% DOCUMENT CLASS
\documentclass[11pt,preview,varwidth,%
border={5pt 5pt 20pt 5pt}% left bottom right top
]{standalone}

% PACKAGES
\usepackage{mathtools, amssymb} % Math packages

\let\oldmathbb\mathbb % Computer Modern blackboard bold
\AtBeginDocument{\def\mathbb{\oldmathbb}} % Redefine \mathcal to use Computer Modern

\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math} % Math fonts
\setmathfont{Latin Modern Math}
\let\newmathbb\mathbb % Latin Modern blackboard bold

\ExplSyntaxOn
\makeatletter
\cs_new:Npn\definemathgroup#1#2#3#4{
  \fontspec_set_family:Nnn\l_my_math_font_family{SmallCapsFont={},ItalicFont={},BoldFont={},Script=Math,#3}{#4}
  \exp_args:Nc\new@mathgroup{\string#1}
  \::c\::n\::f\:::\new@symbolfont{\string#1}{TU}{\l_my_math_font_family}{\seriesdefault}{\shapedefault}
  \cs_new:Npn#1##1{#2{\fam\use:c{\string#1}##1}}
}
\makeatother
\ExplSyntaxOff

\definemathgroup{\oldmathcal}{\symcal}{}{cmsy10} % Computer Modern calligraphic
\AtBeginDocument{\def\mathcal{\oldmathcal}} % Redefine \mathcal to use Computer Modern

\definemathgroup{\newmathcal}{\symcal}{}{Latin Modern Math} % Latin Modern calligraphic

\newcommand{\AtoZ}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}

% START OF DOCUMENT
\begin{document}
    Computer Modern's \verb|\mathbb|: \(\mathbb{\AtoZ}\)
    
    Latin Modern's \verb|\mathbb|: \(\newmathbb{\AtoZ}\)
    
    Computer Modern's \verb|\mathcal|: \(\mathcal{\AtoZ}\)
    
    Latin  Modern's \verb|\mathcal|: \(\newmathcal{\AtoZ}\)
\end{document}
% END OF DOCUMENT

(I also received the warning Package fontspec Warning: Font "cmsy10" does not contain requested Script "Math".)

What went wrong and how do I fix this issue?

Thank you.

4
  • 2
    computer modern doesn't have blackboard bold, you mean the ams fonts, but see tex.stackexchange.com/a/577603/1090 Commented Nov 29, 2022 at 12:16
  • 1
    You redefinitions such as \let\oldmathbb\mathbb do not do what your comments say they do after such a defintion, at best, \oldmathbb will access whatever font has the same \fam as the original \mathbb, but it will not be the same font if you redeclared math fonts. Also you are mixing opentype math where \mathbb does not change fonts (\mathbb{Z} is character U+2124 ℤ in the same font as Z) with classic 8 bit tex fonts (where \mathbb{Z} s the character Z but in a different font). Hence warnings about cmsy10. Commented Nov 29, 2022 at 12:28
  • 1
    What do you get if you explicitly call for \old... and \new,,,? Commented Nov 29, 2022 at 12:49
  • @barbarabeeton I want to define \oldmathcal to be Computer Modern's calligraphic font in math mode and \newmathcal for Latin Modern's calligraphic font in math mode. Then I want to redefine \mathcal to be \oldmathcal. Commented Nov 29, 2022 at 13:08

1 Answer 1

1

Your question is not so clear but this shows Latin Modern Math OpenType Blackboard bold and Calligraphic alongside type 1 AMS Blackboard bold and Computer Modern Calligraphic. enter image description here

\documentclass{article}

\usepackage{unicode-math}
\setmathfont{LatinModern Math}
\DeclareMathAlphabet\amsmathbb{U}{msb}{m}{n}
\DeclareMathAlphabet\cmmathcal{OMS}{cmsy}{m}{n}

\begin{document}

$ABC \symbb{ABC} \amsmathbb{ABC}$

$ABC \symcal{ABC} \cmmathcal{ABC}$


$\bar{\cmmathcal{A}} +
 \dot{\cmmathcal{A}}$

$\bar{{\mkern-1.5mu}\cmmathcal{A}{\mkern1.5mu}} + 
 \dot{{\mkern-1.5mu}\cmmathcal{A}{\mkern1.5mu}}$

\end{document}

4
  • Thank you for answering but if I use \DeclareMathAlphabet\cmmathcal{OMS}{cmsy}{m}{n}, how would I fix the spacing problems that occur with \bar{\cmmathcal{A}} or \bar{\cmmathcal{A}} or \dot{\cmmathcal{A}}? (As also seen from a comment on this answer, and from this question. Commented Nov 29, 2022 at 15:49
  • @AmanuensisFrances that is not really the same question. If you mix fonts you may expect to need to manually adjust spacing, I added a possible tweak this time, Commented Nov 29, 2022 at 16:01
  • I apologize for not being fully clear in my original question and thank you. I also assume I can simply use a similar manual kerning for \bar{\amsmathbb{A}}, etc. Commented Nov 29, 2022 at 16:07
  • @AmanuensisFrances yes I just did that by eye. Depending on need and how many different values you need you could imagine implementing some command looking up some table of values you determine, or something simple like \newcommand\shift[3]{#1{{\mkern-#2mu}#3{\mkern#2mu}}} so \shift\bar{1.5}{\cmmathcal{A}} Commented Nov 29, 2022 at 16:12

You must log in to answer this question.

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