2

I am using LuaLaTeX and unicode-math in my documents. I input most of the simple symbols (sum, products, greek letters, quantification, etc.) directly in unicode (using agda-mode for emacs). When I input the unicode character "SCRIPT CAPITAL L" (U+2112), I get in the pdf the equivalent of a \mathscr L. How can I tell the package unicode-math that I would like to have a \mathcal L instead whenever it encounters a unicode character U+2112?

Ideally, I would like to just pass an option to the package so that all "SCRIPT ..." uses \mathcal ... instead of \mathscr ...

EDIT. To clarify, here is a MWE:

\documentclass{minimal}

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

\setmathfont{Libertinus Math Regular}
\setmathfont{Latin Modern Math}[range={\mathscr}]
\setmathfont{TeX Gyre Pagella Math}[range={\mathcal}]

\begin{document}
Unicode input: $ℒ$

Mathcal input: $\mathcal L$

Mathscr input: $\mathscr L$
\end{document}

The pdf output 3 different Ls, which leads me to believe that the unicode input actually uses \mathscr of Libertinus Math Regular in that example. How to I tell the package that I want it to use \mathcal from TeX Gyre Pagella Math when it encounters a U+2212 in the source?

7
  • @DavidCarlisle I think you misunderstood my problem. I do have both fonts, using range indeed, and I do get different outputs if I use \mathscr L and \mathcal L in my source. But when I input the unicode character ℒ in my source, the output in the pdf looks like if I had typed \mathscr L in the source, and I would like the output in the pdf to look like if I had typed \mathcal L in the source.
    – Pece
    Jun 2, 2023 at 14:26
  • 1
    Unicode specifies U+2212 (ℒ) may be in either style depending on the font Jun 2, 2023 at 14:38
  • 1
    @DavidCarlisle So if I have \setmathfont{Math Font 1}[range={\mathcal}] and \setmathfont{Math Font 2}[range={\mathscr}] in my preamble, how does unicode-math decide if U+2212 will use Math Font 1 or Math Font 2? I don't find the information in the documentation of the package.
    – Pece
    Jun 2, 2023 at 14:54
  • @DavidCarlisle I edited with a MWE and real fonts.
    – Pece
    Jun 2, 2023 at 15:11
  • Try swapping the input order of \setmathfont ranges for Latin Modern and Pagella. Jun 2, 2023 at 15:23

1 Answer 1

1

enter image description here

range is a bit temperamental, and script and calligraphic being the same Unicode range makes it more interesting, but


\documentclass{minimal}

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

\setmathfont{Libertinus Math Regular}
\setmathfont{TeX Gyre Pagella Math}[range=cal]
\setmathfont{Latin Modern Math}[range=scr]

\AtBeginDocument{
\Umathcode"2112= "0 4 "2112
}

\begin{document}
Unicode input: $ℒ$

Mathcal input: $\mathcal L$

Mathscr input: $\mathscr L$

$ℒ$ $\mathcal L $ $\mathscr L$
\end{document}
2
  • Thanks! So I guess I will have to do it on a letter basis. That's fine, I usually only use a small number, but I would definitely have expected unicode-math to have some kind of option for that!
    – Pece
    Jun 2, 2023 at 17:32
  • 1
    @Pece unicode-math has the list of code points for each alphabet (used for range) so it could make a loop for those Umathode but i don't think it does. You could make a feature request at unicode-math github Jun 2, 2023 at 17:45

You must log in to answer this question.

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