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

    LGRgreek,% use greek letters from main font

abcdef + αβγδεζ + 12345\\
\textit{abcdef + αβγδεζ + 12345}\\ 
$abcdef + \alpha\beta\gamma\delta\zeta + 12345$\\
$\mathit{abcdef + \alpha\beta\gamma\delta\zeta} + 12345$
  • 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

    %Path={Fonts/Alegreya/},% required to get italic text greek in XeLaTeX
    %Extension = .otf,% .ttf,% no difference
    UprightFont = *-Regular,
    ItalicFont = *-Italic,
    BoldFont = *-Bold,
    BoldItalicFont = *-BoldItalic,

    LGRgreek,% use greek letters from main font

abcdef + αβγδεζ + 12345\\
\textit{abcdef + αβγδεζ + 12345}\\ 
$abcdef + \alpha\beta\gamma\delta\zeta + 12345$\\
$\mathit{abcdef + \alpha\beta\gamma\delta\zeta} + 12345$
  • 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:


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

  • 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:

The font can be downloaded here. After selection it is possible to costumize the font shapes and greek letters.

  • when trying fonts.google.com/specimen/Alegreya the Firefox window remains despairingly blank. Same for fonts.google.com ... – user4686 Mar 30 '18 at 12:46
  • Both links work for me. The window is loaded after a few seconds. – Lysanne Mar 30 '18 at 15:29
  • waiting for 20 seconds now and page remains blank. Does one need some kind of google account? Or is private browsing mode the problem? or perhaps the sandboxing of recent firefox which already caused problems for rendering of some pages like wikipedia because I had configured Firefox to use DejaVu from TeXLive? back to fonts.google.com/specimen/Alegreya still waiting... – user4686 Mar 30 '18 at 18:53
  • The problem appears to be that TeX Live ships with an old TTF version of Alegreya that doesn’t contain any Greek letters. I’m putting the finishing touches on a solution. – Davislor Mar 31 '18 at 4:48

One problem you were having was that TeX Live currently ships with an old version of Alegreya that doesn’t contain any Greek letters. If you download and install the newer version of the OTF files, you will be able to load them in either XeLaTeX or LuaLaTeX, by their filenames. (This should still work if your TeX distribution ever updates its version of the font.)

Additionally, the commands you were using to load the partial math font in unicode-math do not appear to be correct as of version 0.8l. You might want to make sure you have up-to-date documentation.

Here is a solution for Greek and Latin letters in upright, italic, bold and bold italic alphabets, as well as numbers in upright and bold (italic digit symbols are not in Unicode 10.0).

\RequirePackage{luatex85} % Workaround for standalone 1.2 and LuaTeX.



{\Alegreya Alegreya: abcxyzαβγδ123 \textit{abcxyzαβγδ} \textbf{abcxyzαβγδ123} \textbf{\textit{abcxyzαβγδ}}}


Alegreya test

That defines \Alegreya for compatibility with the package. It does not completely set up the font family, such as the different weights, small caps, sans-serif, or the sans-serif math alphabets, but the unicode-math documentation will show how to do that if you need it.

If you have a mostly-working preamble for PDFLaTeX, the way to make a template that will work in PDFLaTeX, XeLaTeX or LuaLaTeX is to use the package iftex to detect your TeX engine and wrap the fallback version in a conditional block. So, \ifPDFLaTeX ... \else ... \fi.


As of March 2019, alegreya has been updated and now makes everything easier.

It supports the LGR encoding, if you compile with PDFLaTeX or load the [type1] option. This means that you can now load \usepackage[LGR, T1]{fontenc}, \usepackage[type1]{alegreya}, and use its LGR encoding for your Greek math letters with mathastext or isomath.

The package will set up fontspec if compiled with LuaLaTeX or XeLaTeX. You can still use the technique above with unicode-math (which I recommend), or load alegreya and then mathastext in LuaLaTeX or XeLaTeX, or use mathspec in XeLaTeX.

The Rest of the Original Answer

The Alegreya package cannot support Greek letters like you want, according to the documentation, because under NFSS, Greek text letters are in the LGR encoding, and you told mathastext to take its math symbols from that. However, Alegreya only supports the OT1, T1, TS1 and LY1 encodings.

The following preamble mostly works for loading another font that does support Greek, GFS Bodoni: (It does not include an italic face, but another could be substituted.)

\RequirePackage{luatex85} % Workaround for standalone 1.2 and LuaTeX.

%\usepackage[english,greek]{babel} % Use this if you are writing in Greek.
\usepackage[italic, LGRgreek, itgreek]{mathastext} % or upgreek, or upGreek.



{abcxyzαβγδ123 \textit{abcxyzαβγδ} \textbf{abcxyzαβγδ123} \textit{\textbf{abcxyzαβγδ}}}

\[ abcxyzαβγδ123 \quad
  \mathup{abcxyz}\greekup{αβγδ}\mathup{123} \quad

enter image description here

The one thing this breaks is Greek letters in \mathit, \mathbf and the other math alphabets. With mathastext and the legacy T1 and LGR font encodings, these set the alphabet to the T1 encoding, not the LGR encoding. So, \mathit{α} will become a, \mathrm{γ} will become g, and \mathbf{δ} will become d. If you need multiple styles of Greek math symbols in the same document, or you want to use µ and π according to ISO style, you need to use the workaround. It’s inspired by jfbu’s answer here.

Also note that that is correct for ISO style, but to get the default behavior of TeX, which is slanted lowercase and upright uppercase Greek, use the upGreek option.

  • 2
    mentioning tex.stackexchange.com/a/401534/4686 for Greek letters, mathastext, and math alphabets (which are misnomers because they are meant to use the text fonts in math mode) – user4686 Mar 31 '18 at 21:04
  • 1
    @jfbu And also: tex.stackexchange.com/questions/398440/… – Davislor Mar 31 '18 at 21:08
  • 1
    more upvotes needed here ;-) – user4686 Apr 1 '18 at 6:05
  • 1
    Thank you! I now managed to implement Alegreya and AlegreyaSans completely for XeLaTeX and LuaLaTeX. Btw, it is a very good idea to define compatibility commands (\Alegreya, etc.). I had not thought about that. Did that for all package commands, now. I already use ifxetex, ifluatex and iftex. I'd just left them out to keep the MWEs minimal. (Is there some advantage of using iftex compared to the other packages?) For PDFLaTeX I am going to use your workaround. I don't find it really satisfying but I get the problem with the math fonts now, and for that seems the best solution. – Lysanne Apr 1 '18 at 12:58
  • 1
    @Lysanne You probably thought of this already, but if you want the same code to work in the modern solution and the workaround, you’d need to have the unicode-math version define \greekup as \symup, \greekit as \symit and so on, then use them in the document itself if you need a non-default glyph. You might try just skipping the workaround and loading lmodern before Alegreya so at least you’ll get consistent results. There are a few GFS packages, such as Artemisia, that set up the math alphabets too. – Davislor Apr 1 '18 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.