# Upright sans-serif math capital Greek using [lua|xe]latex

Feeding the code

\documentclass{article}
\pagestyle{empty}
\usepackage[ngerman]{babel}
\usepackage{mathtools}%%% loads amsmath internally
\mathtoolsset{mathic=true} %%% See http://tex.stackexchange.com/a/3496
\usepackage[math-style=ISO]{unicode-math}%%% In general, we wish to have ISO style.
\setmainfont[Ligatures=TeX]{TeX Gyre Termes}%%% Times in general.
\setsansfont{TeX Gyre Heros}[Scale=0.88]%%% scaling somewhat ok.
\setmonofont{TeX Gyre Cursor}%%% no explicit turning on ligatures for the monospaced font.
\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}%%% Times-like math font.
\newcommand{\concreteSort}[1]{\mathsf{#1}}
\begin{document}
\begin{tabular}{ll}
Normal math italic Latin:& $$Sigma$$.\\ %%% product of five variables S, i, g, m, a.
Normal math italic Greek:& $$\Sigma$$.\\ %%% a single variable.
Upright sans-serif math Latin:&$$\concreteSort{Sigma}$$.\\%%% a constant with a fixed meaning.
Upright sans-serif math Greek:&$$\concreteSort{\upSigma}$$.%%% another constant with a fixed meaning. Where to get an upright sans-serif math Σ without changing the rest?
\end{tabular}
\end{document}


to xelatex leads to

As you see above, the last Σ has serifs. How to get rid of the serifs for upright math capital Greek without changing the rest, i.e., maintaining the formatting of the remaining text and math? Yes, we wish to stay with [xe|lua]latex. I expect that a different font is needed, but which one? How to switch to it only for the upright capital Greek math letters? Ideally, \concreteSort should produce the same (upright, sans-serif) formatting for Latin and capital Greek, but it doesn't.

EDIT: Inspired by http://tex.stackexchange.com/a/537218, I fed

\documentclass{standalone}
\usepackage[ngerman]{babel}
\usepackage{mathtools}%%% loads amsmath internally
\mathtoolsset{mathic=true} %%% See http://tex.stackexchange.com/a/3496
\usepackage[math-style=ISO]{unicode-math}%%% In general, we wish to have ISO style.
\setmainfont[Ligatures=TeX]{TeX Gyre Termes}%%% Times in general.
\setsansfont{TeX Gyre Heros}[Scale=0.88]%%% %%% this scaling factor is a middle way between MatchUppercase and MatchLowercase.
\setmonofont{TeX Gyre Cursor}%%% no explicit turning on ligatures for the monospaced font.
\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}%%% Times-like math font.
\setmathfontface\mathsans{TeX Gyre Heros}%%% suggested by http://tex.stackexchange.com/a/537218
\begin{document}\noindent%
\begin{tabular}{@{}rl@{}}
\verb!$$\mathsf{\mupSigma}$$!:&$$\mathsf{\mupSigma}$$\\
\verb!$$\mathsans{\mupSigma}$$!:&$$\mathsans{\mupSigma}$$
\end{tabular}
\end{document}


to xelatex and obtained that \mathsans{\mupSigma} is larger than \mathsf{\mupSigma}:

Why? Which one do I need for an identifier Σ with a fixed meaning? Here is some test code:

\documentclass{article}
\pagestyle{empty}
\usepackage[ngerman]{babel}
\usepackage{mathtools}%%% loads amsmath internally
\mathtoolsset{mathic=true} %%% See http://tex.stackexchange.com/a/3496
\usepackage[math-style=ISO]{unicode-math}%%% In general, we wish to have ISO style.
\defaultfontfeatures{Scale=MatchUppercase}
\setmainfont[Ligatures=TeX]{TeX Gyre Termes}%%% Times in general.
\setsansfont{TeX Gyre Heros} %[Scale=0.88]%%% this scaling factor is a middle way between MatchUppercase and MatchLowercase.
\setmonofont{TeX Gyre Cursor}%%% no explicit turning on ligatures for the monospaced font.
\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}%%% Times-like math font.
\setmathfontface\mathsans{TeX Gyre Heros}%%% suggested by http://tex.stackexchange.com/a/537218
\newcommand{\concreteSortSf}[1]{\mathsf{#1}}
\newcommand{\concreteSortSfup}[1]{\mathsfup{#1}}
\newcommand{\concreteSortSans}[1]{\mathsans{#1}}
\begin{document}\noindent%
\begin{tabular}{@{}rl@{}}
\verb!\mathsf!: & Serif $$\mathsf{sans}$$ serif.\\
\verb!\mathsans!: & Serif $$\mathsans{sans}$$ serif.
\end{tabular}

With \verb!\mathsf!:\\
Consider the sort $$\concreteSortSf{Queue}\,\concreteSortSf{\mupSigma}$$ and the function signature
$f\colon\ \,\concreteSortSf{Queue}\,\concreteSortSf{\mupSigma}\ \to\ \concreteSortSf{Stack}\,\concreteSortSf{\mupSigma}\ .$

With \verb!\mathsfup!:\\
Consider the sort $$\concreteSortSfup{Queue}\,\concreteSortSfup{\mupSigma}$$ and the function signature$f\colon\ \,\concreteSortSfup{Queue}\,\concreteSortSfup{\mupSigma}\ \to\ \concreteSortSfup{Stack}\,\concreteSortSfup{\mupSigma}\ .$

With \verb!\mathsans!:\\
Consider the sort $$\concreteSortSans{Queue}\,\concreteSortSans{\mupSigma}$$ and the function signature$f\colon\ \,\concreteSortSans{Queue}\,\concreteSortSans{\mupSigma}\ \to\ \concreteSortSans{Stack}\,\concreteSortSans{\mupSigma}\ .$
\end{document}


The result is good for \mathsf and \mathsans (and the question still remains as which one to use, at least conventionally) and bad for \mathsfup, as it produces a slanted 𝛴 with serifs:

• Your \mathsf is smaller because you loaded \setsansfont with a Scale= parameter. See my answer for a recommendation on how to handle that. Apr 7, 2020 at 18:49
• That is, either add \defaultfontfeatures{Scale=MatchUppercase} as I did, or add the [Scale=MatchUppercase] option to each font command, except \setmainfont. Apr 7, 2020 at 18:53
• In this case, \mathsf and \mathsans both get you the Σ from TeX Gyre Heros, and there are no problems with either in practice. I think \mathsans is semantically cleaner, but \mathsfup is.more standard. Apr 7, 2020 at 18:57
• Also, you should delete the definition of \sansmath if you do not define a version=sans. Apr 7, 2020 at 19:01
• Yes, you can add font options to \setmathfontface. The details are in the link in my answer. Apr 7, 2020 at 19:48

You can define \concreteSort to also modify the meaning of the Greek letter commands.

The list in the definition of \changegreek is incomplete, fill in the missing letters.

The idea is to change \Sigma into \symsfupx{\mupSigma}, which will use the letter in the sans font (assuming it has it, of course; otherwise you need another clone of Helvetica that does).

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{mathtools}

\usepackage[math-style=ISO]{unicode-math}

\setmainfont{TeX Gyre Termes}
\setsansfont{TeX Gyre Heros}[Scale=MatchLowercase]
\setmonofont{TeX Gyre Cursor}
\setmathfont{TeX Gyre Termes Math}
\setmathfontface{\symsfupx}{TeX Gyre Heros}[Scale=MatchLowercase]

\mathtoolsset{mathic=true}

\newcommand{\concreteSort}[1]{\symsfup{\changegreek#1}}

\ExplSyntaxOn
\cs_new_protected:Npn \changegreek
{
\clist_map_inline:nn { \Alpha,\Beta,\Gamma,\Delta,\Sigma } % <--- add
{
\cs_set_protected:Npn ##1 { \symsfupx{\use:c{mup \cs_to_str:N ##1 }} }
}
}
\ExplSyntaxOff

\begin{document}

\begin{tabular}{ll}
Normal math italic Latin:& $$Sigma$$.\\
Normal math italic Greek:& $$\Sigma$$.\\
Upright sans-serif math Latin:&$$\concreteSort{Sigma}$$.\\
Upright sans-serif math Greek:&$$\concreteSort{\Sigma}$$.\\
\end{tabular}

\end{document}


There is no sans-serif Greek math alphabet in Unicode, but unicode-math allows you to define a new math alphabet with \setmathfontface. See §4.4 of the manual for details.

Another option is to select a sans-math version.

A MWE showing both methods:

\documentclass{book}
\usepackage{amsmath} % Only older installations need this.
\usepackage[math-style=ISO]{unicode-math}

\defaultfontfeatures{Scale=MatchUppercase}
\setmainfont{TeX Gyre Termes}[Scale=1.0]
\setsansfont{TeX Gyre Heros}
\setmathfont{TeX Gyre Termes Math}
\setmathfontface\mathsans{TeX Gyre Heros}
\setmathfont[version=sans]{FiraMath-Regular.otf}

\newcommand\sansmath{\mathversion{sans}}
\newcommand\sanssymbol[1]{\text{\mathversion{sans}\ensuremath{#1}}}

\begin{document}

Text Sigma: {\mupSigma} (TeX Gyre Termes)

Math upright Sigma: $$\symup\Sigma$$ (TG Termes Math)

Summation symbol: $$\sum$$

Sans face: $$\mathsans{\mupSigma}$$ (TeX Gyre Heros)

Sans version: $$\sanssymbol{\symup\Sigma}$$ (Fira Math)

\end{document}


This adds a new command \mathsans analogous to \mathsfup, \sansmath analogous to \boldmath and \sanssymbol analogous to \boldsymbol. You might need to wrap this version of \sanssymbol in a command such as \mathbin or \mathrel to get correct spacing for things other than letters.

In particular, \mathop{\sanssymbol{\sum}} works. If you just want all summation symbols to be sans-serif, you could use \setmathfont{Fira Math}[range=\sum] instead of [version=sans].

P.S.: You select ISO style when you load unicode-math, but in ISO style, upright Greek capital letters should be slanted, unless they are constants.

P.P.S.: The \mathsfup command would work in this case. It loads the font you loaded with \setsansfont. In theory, it’s intended for words and short phrases in math mode, and for example, if you tried to use it for consecutive symbols, you might get ligatures.

The command intended for tensor symbols and the like is \symsfup, but it will not work for this because there is currently no Greek mathematical sans-serif alphabet in Unicode.

## ETA

A better definition of \sansmath and \sanssymbol, based on amsbsy.sty:

\makeatletter
\newcommand\sansmath{\mathversion{sans}}
%% Based on the definition of \boldsymbol from amsbsy.sty"
\DeclareRobustCommand{\sanssymbol}[1]{%
\begingroup%
\let\@nomath\@gobble \mathversion{sans}%
\math@atom{#1}{%
\mathchoice%
{\hbox{$\m@th\displaystyle#1$}}%
{\hbox{$\m@th\textstyle#1$}}%
{\hbox{$\m@th\scriptstyle#1$}}%
{\hbox{$\m@th\scriptscriptstyle#1$}}}%
\endgroup}
\makeatother

• @Juat_A_Man Agreed. I think the information about summation is useful enough to someone else who wants to know about a Sigma in math mode to leave in. Do you think I should reword it? Apr 7, 2020 at 8:07
• @Just_A_Man You don’t have the Fira Math package installed on your system. On Ubuntu, this would be in the system package texlive-fonts-extra. Otherwise, make sure you have an up-to-date TeX installation and install the firamath package from CTAN. Apr 7, 2020 at 17:32
• @Just_A_Man \mathsf changes the font to the sans-serif text font. It works here, but is intended for words and short phrases in math mode. If you try to use it for consecutive symbols, you will for example get ligatures. The \symsfup command is what you theoretically want for tensor symbols and the like, but there is no Greek math sans-serif on Unicode, so it will just give you serifs. Apr 7, 2020 at 17:44
• @Just_A_Man In that case, does changing {Fira Math} to {FiraMath-Regular.otf} work? Apr 7, 2020 at 17:46
• @Just_A_Man I’m not sure why you get different output, but you might be loading the \setsansfont with different options, such as scaling or optical sizes. The symbols should come from TeX Gyre Heros either way. Apr 7, 2020 at 17:48