The macros setmainfont and setsansfont do not accept the new command of a newfontfamily. Is there...











up vote
2
down vote

favorite












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}

usepackage{fontspec}

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

setmainfont{alegreya}
setsansfont{alegreya}


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










share|improve this question


















  • 1




    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.
    – Ulrike Fischer
    Nov 30 at 11:09















up vote
2
down vote

favorite












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}

usepackage{fontspec}

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

setmainfont{alegreya}
setsansfont{alegreya}


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










share|improve this question


















  • 1




    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.
    – Ulrike Fischer
    Nov 30 at 11:09













up vote
2
down vote

favorite









up vote
2
down vote

favorite











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}

usepackage{fontspec}

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

setmainfont{alegreya}
setsansfont{alegreya}


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










share|improve this question













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}

usepackage{fontspec}

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

setmainfont{alegreya}
setsansfont{alegreya}


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







fonts xetex memoir fontspec mac






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 30 at 10:59









Gustavo Reis

505




505








  • 1




    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.
    – Ulrike Fischer
    Nov 30 at 11:09














  • 1




    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.
    – Ulrike Fischer
    Nov 30 at 11:09








1




1




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.
– Ulrike Fischer
Nov 30 at 11:09




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.
– Ulrike Fischer
Nov 30 at 11:09










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










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.)



documentclass{article}

usepackage{fontspec}

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

renewcommand{rmdefault}{alegreyaot}
renewcommand{sfdefault}{alegreyaot}

begin{document}

This should be Alegreya

textsf{This too}

{normalfontalegreya Check}

end{document}


enter image description here






share|improve this answer





















  • 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?
    – Gustavo Reis
    Nov 30 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 at 12:10












  • Then I will use Charter BT Math or GFS Neohellenic Math or Linux Libertinus Math.
    – Gustavo Reis
    Nov 30 at 12:13











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462544%2fthe-macros-setmainfont-and-setsansfont-do-not-accept-the-new-command-of-a-newfon%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










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.)



documentclass{article}

usepackage{fontspec}

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

renewcommand{rmdefault}{alegreyaot}
renewcommand{sfdefault}{alegreyaot}

begin{document}

This should be Alegreya

textsf{This too}

{normalfontalegreya Check}

end{document}


enter image description here






share|improve this answer





















  • 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?
    – Gustavo Reis
    Nov 30 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 at 12:10












  • Then I will use Charter BT Math or GFS Neohellenic Math or Linux Libertinus Math.
    – Gustavo Reis
    Nov 30 at 12:13















up vote
2
down vote



accepted










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.)



documentclass{article}

usepackage{fontspec}

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

renewcommand{rmdefault}{alegreyaot}
renewcommand{sfdefault}{alegreyaot}

begin{document}

This should be Alegreya

textsf{This too}

{normalfontalegreya Check}

end{document}


enter image description here






share|improve this answer





















  • 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?
    – Gustavo Reis
    Nov 30 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 at 12:10












  • Then I will use Charter BT Math or GFS Neohellenic Math or Linux Libertinus Math.
    – Gustavo Reis
    Nov 30 at 12:13













up vote
2
down vote



accepted







up vote
2
down vote



accepted






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.)



documentclass{article}

usepackage{fontspec}

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

renewcommand{rmdefault}{alegreyaot}
renewcommand{sfdefault}{alegreyaot}

begin{document}

This should be Alegreya

textsf{This too}

{normalfontalegreya Check}

end{document}


enter image description here






share|improve this answer












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.)



documentclass{article}

usepackage{fontspec}

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

renewcommand{rmdefault}{alegreyaot}
renewcommand{sfdefault}{alegreyaot}

begin{document}

This should be Alegreya

textsf{This too}

{normalfontalegreya Check}

end{document}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 30 at 11:09









egreg

703k8618733147




703k8618733147












  • 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?
    – Gustavo Reis
    Nov 30 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 at 12:10












  • Then I will use Charter BT Math or GFS Neohellenic Math or Linux Libertinus Math.
    – Gustavo Reis
    Nov 30 at 12:13


















  • 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?
    – Gustavo Reis
    Nov 30 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 at 12:10












  • Then I will use Charter BT Math or GFS Neohellenic Math or Linux Libertinus Math.
    – Gustavo Reis
    Nov 30 at 12:13
















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?
– Gustavo Reis
Nov 30 at 12:06




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?
– Gustavo Reis
Nov 30 at 12:06




1




1




@GustavoReis Since there is no math font compatible with Alegreya, I'd not bother. But setmathrm{Alegreya-Regular} should work.
– egreg
Nov 30 at 12:10






@GustavoReis Since there is no math font compatible with Alegreya, I'd not bother. But setmathrm{Alegreya-Regular} should work.
– egreg
Nov 30 at 12:10














Then I will use Charter BT Math or GFS Neohellenic Math or Linux Libertinus Math.
– Gustavo Reis
Nov 30 at 12:13




Then I will use Charter BT Math or GFS Neohellenic Math or Linux Libertinus Math.
– Gustavo Reis
Nov 30 at 12:13


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462544%2fthe-macros-setmainfont-and-setsansfont-do-not-accept-the-new-command-of-a-newfon%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?