I started to set up a template document with Alegreya
as font which is supposed to be compilable on all three engines, PDFLaTeX, XeLaTeX, and LuaLaTeX. To also set Alegreya
as the math font, I have chosen mathastext
package because this works for all three engines. But I don't get numbers and greek symbols in math mode to be taken from the font. I tried several things, this is what I have at the moment:
(Please note, that I want all greek letters in math to appear in italics. I just used \mathit
for demonstration purposes.)
MWE 1: Using Alegreya
package
\documentclass{scrbook}
\usepackage{Alegreya}
\usepackage[
LGRgreek,% use greek letters from main font
italic,
itgreek,
]{mathastext}
\begin{document}
abcdef + αβγδεζ + 12345\\
\textit{abcdef + αβγδεζ + 12345}\\
$abcdef + \alpha\beta\gamma\delta\zeta + 12345$\\
$\mathit{abcdef + \alpha\beta\gamma\delta\zeta} + 12345$
\end{document}
- PDFLaTeX:
- text: greek: yes
- math: numbers: yes, upright greek: yes*, italic greek: no*
- LuaLaTeX & XeLaTeX:
- text: greek: yes
- math: numbers: no, upright greek: yes*, italic greek: no*
*The 3rd line in the document gives upgright greek which does not look like the default font but differs from the upright text greek. The 4th line gives latin letters.
MWE 2: Using fontspec
package to at least compile with Lua/XeLaTeX
\documentclass{scrbook}
\usepackage[no-math]{fontspec}
\setmainfont[
%Path={Fonts/Alegreya/},% required to get italic text greek in XeLaTeX
%Extension = .otf,% .ttf,% no difference
Ligatures=TeX,
UprightFont = *-Regular,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic,
]{Alegreya}
\usepackage[
LGRgreek,% use greek letters from main font
italic,
itgreek,
]{mathastext}
\begin{document}
abcdef + αβγδεζ + 12345\\
\textit{abcdef + αβγδεζ + 12345}\\
$abcdef + \alpha\beta\gamma\delta\zeta + 12345$\\
$\mathit{abcdef + \alpha\beta\gamma\delta\zeta} + 12345$
\end{document}
- LuaLaTeX: same as in MWE 1 with correct numbers in math now.
- XeLaTeX: same as in MWE 1 with correct numbers but missing italic greek in text mode. Defining the path to the font files in my directory is required to get the italic greek characters in text althought font is installed on my system.
Before installing I checked that the font contains greek letters. I tried the true type and the open type font versions and I tried to specify the extension. But this makes no differences in the output.
MWE 3: Using unicode-math
instead of mathastext
I changed \usepackage[...]{mathastext}
in MWE 2 to:
\usepackage{unicode-math}
\setmathfont{Alegreya}
This is of course not working, the output is math in default font with missing signes for the greek letters inside \mathit
. So, I changed the unicode-math
part to this:
MWE 4: Modified unicode-math
solution
\usepackage[math-style=TeX]{unicode-math}
\setmathfont{latinmodern-math}
\setmathfont[range=\mathit/{latin,Latin,greek,Greek,Digits},Numbers={Lining}]{Alegreya-Italic}
\setmathfont[range=\mathup/{latin,Latin,greek,Greek,Digits},Numbers={Lining}]{Alegreya}
- LuaLaTeX:
- textgreek and mathgreek: yes
- numbers: no
- XeLaTeX: same as MWE 3.
I do know that it is possible for XeLaTeX to get Alegreya
in math with mathspec
. But since my document is planned as a template for all three engines it would be nice to have a more general solution. If this is not possible, I'd like to, at least, get the numbers work for LuaLaTeX and MWE 4. Somehow it seems, I only get the correct greek OR correct numbers, but not both.
Probably related:
- Italic greek letters become latin letters in math mode. I don't feel well with this solution. I don't want to 'fake' a slanted version when the font definitely contains italic greek. In addition this is only a local solution that requires placing the command everytime, whereas I am looking for a global option.
- Get font Alegreya working with greek letters. This is a combination of two different fonts to substitute the greek in
Alegreya
, but I don't want to combine two fonts. - How to use Alegreya Sans for math mode on pdfLaTeX. In this example (like MWE 1), the greek looks wrong to me, too. (I am not sure about the numbers, because they are in exponents.)
- Mimicking mathspec practices in LuaLaTeX. In this solution (like MWE 2), greek letters are not discussed.
The font can be downloaded here. After selection it is possible to costumize the font shapes and greek letters.