I use the class memoir, the packages polyglossia, fontspec, compile in XeLaTeX in Linux and on macOS.

Based on XeTeX package fontspec: Use previously defined \newfontfamily with \setmainfont (there were not available answers to this), I would like to set an extra font coming from a new command of newfontfamily to setmainfont and setsansfont because I find unnecessary to multiply the same path/localization of the fonts in each macro. I want to economise and optimise the codes. Here is the MWE:

\documentclass[12pt, a4paper, oneside, oldfontcommands, dvipsname]{memoir}


\newfontfamily\alegreya{Alegreya}[Path = ./fontes/,
  FontFace = {xb}{n}  {* Black},
  FontFace = {xb}{it} {* Black Italic},
  UprightFont = * Regular,
  ItalicFont = * Regular Italic,
  BoldFont = * Bold,
  BoldItalicFont = * Bold Italic,


Only my newfontfamily part works, but the set*font does accept the defined newcommand.

  • 2
    That won't work. Create a fontspec-file if you want to reuse font settings, see section 2.3 By custom file name in the fontspec documentation. Nov 30, 2018 at 11:09

1 Answer 1


You can do it by assigning the family name. The string is essentially arbitrary, so long as it doesn't refer to an existing font family.

(I had to adapt the font setup to my machine.)



  %Path = ./fontes/,
  FontFace = {xb}{n}  {*-Black},
  FontFace = {xb}{it} {*-BlackItalic},
  UprightFont = *-Regular,
  ItalicFont = *-Italic,
  BoldFont = *-Bold,
  BoldItalicFont = *-BoldItalic,



This should be Alegreya

\textsf{This too}

{\normalfont\alegreya Check}


enter image description here

  • Thank you a lot, I also have tested fontspec-file as Ulrike has suggested and it worked too. But what is the renewcommand for default maths font, similar to setmathsfont: mathnormal, mathrm or mathsf?
    – Oo'-
    Nov 30, 2018 at 12:06
  • 1
    @GustavoReis Since there is no math font compatible with Alegreya, I'd not bother. But \setmathrm{Alegreya-Regular} should work.
    – egreg
    Nov 30, 2018 at 12:10
  • Then I will use Charter BT Math or GFS Neohellenic Math or Linux Libertinus Math.
    – Oo'-
    Nov 30, 2018 at 12:13

You must log in to answer this question.

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