0

I know this question has already been answered here
How do I use a particular font for a small section of text in my document?

I understand that in order to use additional font with XeLaTeX and LuaLaTeX one can choose to proceed with:

\newfontfamily\myfont{font name} 

then defining a command

\DeclareTextFontCommand{\textmyfont}{\myfont}

then using the command

Text in the default font. \textmyfont{Text in the new font.} Again text in the default font.

But what if I want to have multiple fonts throughout my document? How do I specify the use of a specific font I load with one \textmyfont command? How will it know which font to choose out of many I loaded?
Say, I loaded three fonts:

\newfontfamily\myfont{font1}
\newfontfamily\myfont{font2}
\newfontfamily\myfont{font3}

how would I modify \DeclareTextFontCommand{\textmyfont}{\myfont} command to recognize each font separately? \myfont2 and \myfont3 is not working! And then how would I use the actual \textmyfont command to reference a specific font to a specific part of the text?

tryingout
  • 115
  • 1
    if you want three font families you should give them different names, but don't use numbers, they are not allowed in command names, use letters, eg. \newfontfamily\myfontA{font1}, \newfontfamily\myfontB{font2}. – Ulrike Fischer Mar 28 '22 at 09:14
  • Then I define \DeclareTextFontCommand{\textmyfont}{\myfontA} command to recognize myfontA but the command \textmyfont stays the same. If I put it before some text, the command will choose myfont instead of myfontA. So how would I modify the actual command? Or I can rename \textmyfont command to anything I want like \textmyfontA? – tryingout Mar 28 '22 at 09:23
  • yes, you can also define \textmyfontA. – Ulrike Fischer Mar 28 '22 at 10:04

0 Answers0