0

I am using the tgheros and sansmath package for my document. That changes the text font to sans-serif and all the parts of the math that are supported, meaning greek letters are still typeset with serifs. Here is a working minimal example:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{tgheros,sansmath}

\renewcommand{\familydefault}{\sfdefault}
\sansmath

\begin{document}
a                                  %a is sans-serif.
$$\alpha a$$                       %a is sans-serif, \alpha is not - I'd like it to be.
\end{document}

I would like to use cmbright for greek letters only as it is close enough of a match that it looks alright with the other sans-serif math (meaning just importing the cmbright package doesn't work as it changes the font for all the maths).

How would I go about this?

I am even happy for this not to happen automatically and having to manually set greek letters to cmbright with some command akin to \MakeThisCMBright{\alpha}. Note: I am using pdftex.

2
  • 2
    Show your code ...
    – user187802
    Commented Jun 29, 2023 at 15:52
  • I have added some code to show what I've been doing.
    – nsnfn
    Commented Jun 29, 2023 at 17:00

2 Answers 2

0

In the Modern Toolchain

If you can use LuaLaTeX or XeLaTeX, this will get you the specific fonts you requested, with other sans-serif math symbols from Fira Math.

\documentclass{article}

\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}

\setmainfont{TeX Gyre Heros}[Scale=1.0]
\setsansfont{TeX Gyre Heros}
\setmathfont{Fira Math}
\setmathfont{TeX Gyre Heros}[range=up/{Latin,latin,Num}]
\setmathfont{TeX Gyre Heros Italic}[range=it/{Latin,latin}]
\setmathfont{TeX Gyre Heros Bold}[range=bfup/{Latin,latin,Num}]
\setmathfont{TeX Gyre Heros Bold Italic}[range=bfit/{Latin,latin}]
\setmathfont{CMU Bright}[range=up/{Greek,greek}]
\setmathfont{CMU Bright Oblique}[range=it/{Greek,greek}]
\setmathfont{CMU Bright Bold}[range=bfup/{Greek,greek}]
\setmathfont{CMU Bright Bold Oblique}[range=bfit/{Greek,greek}]

\begin{document}
a
$\alpha a$
\end{document}

TeX Gyre Heros + CMU Bright sample

If what you really want is a consistent set of sans-serif fonts for text and math, a much simpler way is

\usepackage[fira]{fontsetup}

Note that this also only works in LuaLaTeX or XeLaTeX. (And that I got beaten to it while writing this answer.)

With Legacy Fonts

Another frame challenge: if what you want is to use sans-serif math throughout your document, not to switch between serif and sans-serif math versions, you may get better results with a sans-serif math package, such as sansmathfonts or newtxsf—or even cmbright—and no longer feel the need to use CM Bright for Greek only.

If you still do, you have to load the cmbr family as a math font in OML encoding, and redefine all the Greek letters. The sansmath package breaks this, but it works with sansmathfonts.

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{sansmathfonts}
\usepackage{tgheros}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[italic]{mathastext}

\DeclareSymbolFont{cmbright}{OML}{cmbr}{m}{it}
\SetSymbolFont{cmbright}{bold}{OML}{cmbr}{bx}{it}

\DeclareMathSymbol{\alpha}{\mathalpha}{cmbright}{"0B}
\DeclareMathSymbol{\beta}{\mathalpha}{cmbright}{"0C}
% etc.

\begin{document}
a
$\alpha a \boldsymbol{\alpha a}$
\end{document}

qhv + cmbr + sansmathfonts sample

Note that TeX Gyre Heros and Computer Modern Bright do not have the same x-height.

You can look up and manually-enter the slot of every Greek letter in the seven-bit OML encoding, keeping in mind that it reuses several Latin letters such as A, B, H, etc. as Greek capitals.

Both of these problems would be possible to fix by copying and editing a lot of boilerplate (see OMLcmbr.fd), if you really, truly want to go that route.

0

Run with xelatex or better with lualatex

\documentclass{article}
\usepackage{firamath-otf}
\usepackage[default]{FiraSans}

\begin{document}
    a\textit{a}                                %a is sans-serif.
    $\alpha\beta a$                       %a is sans-serif.
\end{document}

enter image description here

You must log in to answer this question.

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