Options for Greek letters in sansmath
25 May 2017
For presentations and labels in figures I like sans-serif fonts, TeX Gyre Heros being my default choice. The default math font doesn't go together with sans-serif fonts:
Which math font should you choose? An overview and comparison of free math fonts was done by Stephen G. Hartke and is available here.
Using sansmath
I'm using sansmath. With package enabled, the above example becomes
from
\documentclass[border=2,convert={density=600}]{standalone} \usepackage{tgheros} \renewcommand{\familydefault}{\sfdefault} \usepackage{sansmath} \sansmath \begin{document} A $\varepsilon$ character. Math is $\sum_{i=1}^{n} \alpha_n x^{\gamma_n}$. Also $\beta$, $\varrho$ and $\varphi$. \end{document}
You notice that this is better, but not good enough yet. Greek letters are not by default part of sansmath
. In the following I'm showing three options for Greek letters in sansmath
.
1. eulergreek
The most straight forward solution is to provide the eulergreek
option to sansmath, obtaining
from
\documentclass[border=2,convert={density=600}]{standalone} \usepackage{tgheros} \renewcommand{\familydefault}{\sfdefault} \usepackage[eulergreek]{sansmath} \sansmath \begin{document} A $\varepsilon$ character. Math is $\sum_{i=1}^{n} \alpha_n x^{\gamma_n}$. Also $\beta$, $\varrho$ and $\varphi$. \end{document}
2. bm
Another option is to use the bm package. With the package we get
from
\documentclass[border=2,convert={density=600}]{standalone} \usepackage{tgheros} \renewcommand{\familydefault}{\sfdefault} \usepackage{sansmath} \sansmath \usepackage{bm} \begin{document} A $\bm{\varepsilon}$ character. Math is $\sum_{i=1}^{n} \bm{\alpha}_n x^{\bm{\gamma}_n}$. Also $\bm{\beta}$, $\bm{\varrho}$ and $\bm{\varphi}$. \end{document}
Note that in this case every greek letter needed to bolded separately using \bn{ }
.
3. supplying Greek letters from a different font
In an answer to a question on tex.stackexchange.com on the topic, the following was suggested. One can get, for example,
by supply the greek letter definitions from another font - in this case iwona - manually:
\documentclass[border=2,convert={density=600}]{standalone} \usepackage{tgheros} \renewcommand{\familydefault}{\sfdefault} \usepackage{sansmath} \sansmath \DeclareSymbolFont{Greekletters}{OT1}{iwona}{m}{n} \DeclareSymbolFont{greekletters}{OML}{iwona}{m}{it} \DeclareMathSymbol{\alpha}{\mathord}{greekletters}{"0B} \DeclareMathSymbol{\beta}{\mathord}{greekletters}{"0C} \DeclareMathSymbol{\gamma}{\mathord}{greekletters}{"0D} \DeclareMathSymbol{\varepsilon}{\mathord}{greekletters}{"22} \DeclareMathSymbol{\varrho}{\mathord}{greekletters}{"25} \DeclareMathSymbol{\varphi}{\mathord}{greekletters}{"27} \begin{document} A $\varepsilon$ character. Math is $\sum_{i=1}^{n} \alpha_n x^{\gamma_n}$. Also $\beta$, $\varrho$ and $\varphi$. \end{document}
If you want to use this solution, make sure you use the full definition of Greek symbols as presented by user egreg in the LaTeX Stack Exchange post.
Comparison
Here a comparison of the three solutions in the order that they were presented
There's a GitHub repository with all the above code.