5

This is a basic question but I quite frankly don't really understand how fonts work in ConTeXt. I've looked at the ConTeXt Garden wiki but nothing really clicked, I guess.

I'm trying out ConTeXt and I want to set up my math mode fonts how I do in LaTeX, which is:

\mathrm{A} % for Roman font
\mathcal{B} % for default calligraphic font
\mathscr{C} % for RSFS calligraphic font
\mathfrak{D} % for default fraktur / gothic font
\mathsf{E} % for default sans-serif font
\EuScr{F} % for Euler script calligraphic font

I can get A, B, and D working but I don't know how to add rsfs without overriding \mathcal and I don't at all know how to get \mathsf or Euler script working. I'm using ConTeXt Mk IV if its relevant.

  • 3
    Are you sure you want to use three different calligraphic fonts in one document? Your readers won't be very happy. – Henri Menke Sep 5 at 9:47
  • That's a pretty fair question. I like to think that by encoding the type of the object into the font helps. Example: an $\infty$-category is always in Euler script, formal schemes always in Fraktur, Berkovich's non-archimedean analytic spaces in RSFS, Tate's non-archimedean analytic spaces in usual calligraphic. What I'm working on involves pushing an object around between these categories and comparing some constructions. The way I see it, my options are using different fonts or adding a bunch of explicit operators / subscripts / superscripts. – Joe Berner Sep 5 at 15:09
4

Let's start with the easiest one, \mathsf, because that one is actually already there, but the name is \mathss, just like the text switch \ss. If you prefer \mathsf, you can just assign a different name using \let.

For the RSFS and EuScript fonts it is a bit more tricky, because those are legacy TFM fonts, so one has to screw with the low-level font setup to get those to work. For RSFS there is also a Wiki page in the Garden [1] from which you can straighforwardly copy-paste the setups. The EuScript setup works in the same spirit but the TFM names and the skewchar are different.

Keep in mind that the math script alphabet of Latin Modern Math in OpenType is simply the EuScript alphabet but slanted, so there is a high change of confusion! You could either use a different math font or use a fallback to a different font for script. Of course you can just load yet another legacy font for \mathcal as well. In the MWE below I load the Computer Modern script font.

CAVEAT: All of this completely falls apart if you need bold or lowercase.


[1] https://wiki.contextgarden.net/Rsfs Only the section “Improper ways to use the font” applies here. The first section only works in MKII.

% Sans-serif math is there, it just has a different macro name

\let\mathsf=\mathss

% Load legacy fonts

\font\tensy  =cmsy10 at \mathstyleface\textstyle
\font\sevensy=cmsy7  at \mathstyleface\scriptstyle
\font\fivesy =cmsy5  at \mathstyleface\scriptscriptstyle

\font\tenscr  =rsfs10 at \mathstyleface\textstyle
\font\sevenscr=rsfs7  at \mathstyleface\scriptstyle
\font\fivescr =rsfs5  at \mathstyleface\scriptscriptstyle

\font\teneuscr  =eusm10 at \mathstyleface\textstyle
\font\seveneuscr=eusm7  at \mathstyleface\scriptstyle
\font\fiveeuscr =eusm5  at \mathstyleface\scriptscriptstyle

% \skewchar

\skewchar\tensy  ='60
\skewchar\sevensy='60
\skewchar\fivesy ='60

\skewchar\tenscr  ='177
\skewchar\sevenscr='177
\skewchar\fivescr ='177

\skewchar\teneuscr  ='60
\skewchar\seveneuscr='60
\skewchar\fiveeuscr ='60

% Allocate family

\newfam\calfam
\newfam\scrfam
\newfam\euscrfam

% Assign font families

\textfont        \calfam=\tensy
\scriptfont      \calfam=\sevensy
\scriptscriptfont\calfam=\fivesy

\textfont        \scrfam=\tenscr
\scriptfont      \scrfam=\sevenscr
\scriptscriptfont\scrfam=\fivescr

\textfont        \euscrfam=\teneuscr
\scriptfont      \euscrfam=\seveneuscr
\scriptscriptfont\euscrfam=\fiveeuscr

% Make a macro wrapper

% Backup original definition of \cal and \mathcal
\let\normalcal\cal
\let\normalmathcal\mathcal

\def\cal{\fam\calfam}
\unexpanded\def\mathcal#1{{\cal#1}}

\def\scr{\fam\scrfam}
\unexpanded\def\mathscr#1{{\scr#1}}

\def\euscr{\fam\euscrfam}
\unexpanded\def\EuScr#1{{\euscr#1}}

\starttext
\startformula
\mathrm{A} % for Roman font
\mathcal{B} % for default calligraphic font
\mathscr{C} % for RSFS calligraphic font
\mathfrak{D} % for default fraktur / gothic font
\mathsf{E} % for default sans-serif font
\EuScr{F} % for Euler script calligraphic font
\stopformula
\stoptext

enter image description here

  • Beautiful! I think examining this helps demystify fonts for me, at least a bit. – Joe Berner Sep 6 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.