6

What do I need to do to define a \mathscr which can handle both upper and lower case letters and a \mathcal which can handle both upper and lower case, with the latter staying as close to the default \mathcal as possible?

A simple approach with a single \usepackage line along with some options supplied would be desirable. Every other solution I run into which involves a \newcommand, makeatletter, \newenvironment, \setmathfont, etc., has failed me.

Below, boondox was as close as I could get to the existing \mathcal. Note that my definition for scr did not support lowercase, for some reason.

XeLaTeX/PdfLaTeX make no difference here.

I've gone through a number of posts related to this topic, with none just working for me. I may have an issue with not being able to install font packages correctly? This is mysterious.

\documentclass{article}
\usepackage{mathrsfs}
\usepackage[scr=rsfs,cal=boondox]{mathalfa}
\begin{document}
    $$\mathscr{abcdefghijklmnopqrstuvwxyz}$$
    $$\mathscr{ABCDEFGHIJKLMNOPQRST}$$
    $$\mathcal{abcdefghijklmnopqrstuvwxyz}$$
    $$\mathcal{ABCDEFGHIJKLMNOPQRST}$$
\end{document}

enter image description here

UPDATE: This may just be an issue with the rsfs font. Replacing my usepackage line above with

\usepackage[scr=esstix,cal=boondox]{mathalfa} 

produces results for all four lines. I prefer the rsfs fonts to esstix and prefer whatever the default \mathcal font is to boondox. But if no one has another solution, this may just need to be what I go with.

1
  • 5
    the computer modern font used for \mathcal, and the rsfs font only have uppercase so one way or another you need to pick a different font, of course some are more or less like those two than others but it's just a matter of personal choice. May 16, 2019 at 14:41

1 Answer 1

1

The unicode-math package supports OpenType math fonts, all of which have lowercase script letters (as well as bold).

By default, the package loads the same font as \mathcal and \mathscr, but you can override this with \setmathfont[range={cal,bfcal}, Scale=MatchUppercase]{...} or \setmathfont[range={scr,bfscr}, Scale=MatchUppercase]{...}.

\documentclass{article}
\usepackage{unicode-math}
% So that the output fits the allowed width on TeX.SX:
\usepackage[paperwidth=10cm]{geometry}

\setmathfont{STIX Two Math}
% Unicode uses the same range for `\mathcal` and `\mathscr` letters, but the
% STIX Two font provides a separate script alphabet as Stylistic Set 01.
\setmathfont[range={scr,bfscr}, StylisticSet=1]{STIX Two Math}

\begin{document}
    \[\mathscr{abcdefghijklmnopqrstuvwxyz}\]
    \[\mathscr{ABCDEFGHIJKLMNOPQRST}\]
    \[\mathcal{abcdefghijklmnopqrstuvwxyz}\]
    \[\mathcal{ABCDEFGHIJKLMNOPQRST}\]
\end{document}

STIX Two font sample

A few other OpenType math fonts come with separate \mathcal and \mathscr alphabets, including XITS Math and Asana Math. You can, however, mix and match however you like. You could, for example, add

\setmathfont[range={cal,bfcal},
                    Scale=MatchUppercase
                   ]{STIX Two Math}

or

\setmathfont[range={scr,bfscr},
             Scale=MatchUppercase,
             StylisticSet=1
            ]{STIX Two Math}

to use the script or calligraphic alphabets above in another document.

There are a handful of legacy NFSS math script fonts that come in lowercase. For example, stix2-mathscr does, but stix2-mathcal does not. The mathalfa package ought to be able to load the lowercase alphabet if it exists; you should not need to load both mathalfa and a package such as mathrsfs.

4
  • No understanding how to put this all together. Could you add a minimal example?
    – lowndrul
    May 16, 2019 at 19:55
  • @lowndrul Is this better?
    – Davislor
    May 16, 2019 at 21:16
  • Thanks for sharing the example. Unfortunately, I get an error. When running using bookdown, I get the message ! LaTeX3 Error: Command '\setmathfont' already defined! and when running using XeLaTeX directly I get the error message "Package fontspec Error: The font "STIX Two Math" cannot be found. \setmathfont. That's one among many errors. Found people on other boards having similar trouble with \setmathfont.
    – lowndrul
    May 16, 2019 at 22:46
  • 1
    @lowndrul That’s really a separate question. But to use \setmathfont with bookdown, you’d use these options.
    – Davislor
    May 16, 2019 at 22:53

You must log in to answer this question.

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