Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use regular sans-serif italic/upright greek letter in math mode? #620

Open
Firestar-Reimu opened this issue Aug 17, 2023 · 8 comments

Comments

@Firestar-Reimu
Copy link

Description

Unicode-math does not support sans-serif italic/upright greek letter

Add info or delete as appropriate:

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}% filename only please!
\begin{document}
\[
  \alpha \mathsf{\alpha}
\]
\end{document}

You can try STIX Two Math, still do not support

Further details

https://mirrors.zju.edu.cn/CTAN/macros/unicodetex/latex/unicode-math/unimath-symbols.pdf

@stone-zeng
Copy link
Contributor

Sans-serif italic/upright greek letters are not defined in Unicode.

@stone-zeng
Copy link
Contributor

Some fonts may support these letters alternatively. For XITS, you can use ss02 to load the sans-serif version:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont[StylisticSet=2]{XITSMath-Regular.otf}
\begin{document}
\[ \alpha + \beta + \Gamma \]
\end{document}
Screenshot 2023-08-17 at 16 43 35

@Firestar-Reimu
Copy link
Author

Firestar-Reimu commented Aug 18, 2023

What can I do if I want some greek letters be sans-serif but a lot more others don't?

For example:

$$ X^\mu_\nu = X^{\mu\rho} \eta_{\rho_\nu} = \mathsf{X \eta} $$

X^\mu_\nu = X^{\mu\rho} \eta_{\rho_\nu} = \mathsf{X \eta}

@stone-zeng
Copy link
Contributor

It's clearly impossible to use a glyph that doesn't exist in a font, unless you modify the font and add the things you need.

@khaledhosny
Copy link
Contributor

No unicode-math issue here.

@HolgerGerhardt
Copy link

What can I do if I want some greek letters be sans-serif but a lot more others don't?

For example:

X^\mu_\nu = X^{\mu\rho} \eta_{\rho_\nu} = \mathsf{X \eta}

Here is a suggestion that relies on the XITS Math fonts and makes use of StylisticSet = 2, as @stone-zeng suggested:

% !TeX program = xelatex

\documentclass{article}

\usepackage[mathsf=sym]{unicode-math}
\setmathfont{XITSMath-Regular.otf}[BoldFont = XITSMath-Bold.otf]

\newcommand{\mitsanseta}{%
  \textit{%
    \fontspec{XITSMath-Regular.otf}[
      StylisticSet = 2,
      Color = red
    ]%
    \miteta%
  }%
}

\newcommand{\msanseta}{%
  \textit{%
    \fontspec{XITSMath-Regular.otf}[
      StylisticSet = 2,
      Color = blue
    ]%
    \mupeta%
  }%
}

\begin{document}

\[ X^\mu_\nu = X^{\mu\rho} \eta_{\rho_\nu} = \mathsf{X \eta \msanseta} \mathsfit{X \eta \mitsanseta} \mathsfup{X \eta \msanseta} \mathbfsf{X \eta} \mathbfsfit{X \eta} \]

\boldmath

\[ X^\mu_\nu = X^{\mu\rho} \eta_{\rho_\nu} = \mathsf{X \eta \msanseta} \mathsfit{X \eta \mitsanseta} \mathsfup{X \eta \msanseta} \mathbfsf{X \eta} \mathbfsfit{X \eta} \]

\end{document}

Result:

mathsf

I have made use of the Color attribute only for the purpose of illustration, of course.

@hvoss49
Copy link

hvoss49 commented Jul 15, 2024

You can use FiraSans:

\documentclass{article}
\usepackage{firamath-otf}

\newcommand{\mitsanseta}{%
	\textit{%
	\fontspec{FiraMath-Regular.otf}[
	StylisticSet = 2,
	Color = red
	]%
	\miteta%
	}%
}

\newcommand{\msanseta}{%
	\textit{%
	\fontspec{FiraMath-Regular.otf}[
	StylisticSet = 2,
	Color = blue
	]%
	\mupeta%
	}%
}

\begin{document}

\[ X^\mu_\nu = X^{\mu\rho} \eta_{\rho_\nu} = \mathsf{X \eta \msanseta} 
  \mathsfit{X \eta }\mitsanseta \mathsfup{X \eta \msanseta} \mathbfsf{X \eta} 
  \mathbfsfit{X \eta} \]

\boldmath

\[ X^\mu_\nu = X^{\mu\rho} \eta_{\rho_\nu} = \mathsf{X \eta \msanseta} 
   \mathsfit{X \eta}\mitsanseta \mathsfup{X \eta \msanseta} 
    \mathbfsf{X \eta} \mathbfsfit{X \eta} \]

\end{document}

Bildschirmfoto 2024-07-15 um 13 51 16

@HolgerGerhardt
Copy link

You can use FiraSans:

Sure, but @Firestar-Reimu wants math to be serif in general and only select symbols to be sans-serif:

What can I do if I want some greek letters be sans-serif but a lot more others don't?

It is true, though, that one take the upright sans-serif glyphs out of many different math (or even text fonts) that include Greek letters. For instance,

% !TeX program = xelatex

\documentclass{article}

\usepackage{xcolor}

\usepackage[mathsf=text]{unicode-math}
\setmainfont{XITS-Regular.otf}[
  ItalicFont = XITS-Italic.otf,
  BoldFont = XITS-Bold.otf,
  BoldItalicFont = XITS-BoldItalic.otf,
]
\setsansfont{FiraSans-Regular.otf}[
  ItalicFont = FiraSans-Italic.otf,
  BoldFont = FiraSans-Bold.otf,
  BoldItalicFont = FiraSans-BoldItalic.otf,
  Scale = 0.9,
]
\setmonofont{FiraMono-Regular.otf}[
  BoldFont = FiraMono-Bold.otf,
  Scale = 0.9,
]
\setmathfont{XITSMath-Regular.otf}[BoldFont = XITSMath-Bold.otf]

\setmathfontface{\mathsf}{FiraMath-Regular.otf}[
  BoldFont = FiraMath-Bold.otf,
  Color = cyan
]
% FiraMath-Bold.otf is NOT included in CTAN; it must be downloaded from
% https://github.com/firamath/firamath/releases/tag/v0.4-beta-3.
\setmathfont{FiraMath-Regular.otf}[
  BoldFont = FiraMath-Bold.otf,
  range = {sfup, sfit->it},
  Color = teal,
]
\setmathfont{FiraMath-Bold.otf}[
  range = {bfsfup->up, bfsfit->it},
  Color = orange,
]

\newcommand{\mitsanseta}{%
  \textit{%
    \fontspec{FiraMath-Regular.otf}[
      Color = red
    ]%
    \miteta%
  }%
}
\newcommand{\msanseta}{%
  \textup{%
    \fontspec{FiraMath-Regular.otf}[
      Color = blue
    ]%
    \mupeta%
  }%
}
\AtBeginDocument{%
  \renewcommand{\mbfsanseta}{%
    \textbf{%
      \fontspec{FiraMath-Bold.otf}[
        Color = green
      ]%
      \mupeta%
    }%
  }%
  \renewcommand{\mbfitsanseta}{%
    \textbf{%
      \fontspec{FiraMath-Bold.otf}[
        Color = magenta
      ]%
      \miteta%
    }%
  }%
}

\begin{document}

Test \texttt{\textbackslash mathversion[normal]}:
\[
  X^\mu_\nu = X^{\mu\rho} \eta_{\rho_\nu} =
  \mathsf{X \eta \msanseta} \mathsfit{X \eta \mitsanseta} \mathsfup{X \eta \msanseta} \mathbfsf{X \eta \mbfsanseta} \mathbfsfit{X \eta \mbfitsanseta}
\]

\bfseries\boldmath
Test \texttt{\textbackslash mathversion[bold]}/\texttt{\textbackslash boldmath}:
\[
  X^\mu_\nu = X^{\mu\rho} \eta_{\rho_\nu} =
  \mathsf{X \eta \msanseta} \mathsfit{X \eta \mitsanseta} \mathsfup{X \eta \msanseta} \mathbfsf{X \eta \mbfsanseta} \mathbfsfit{X \eta \mbfitsanseta}
\]

\end{document}
mathsf-fira

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants