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?
\newfontfamily\myfontA{font1},\newfontfamily\myfontB{font2}. – Ulrike Fischer Mar 28 '22 at 09:14\DeclareTextFontCommand{\textmyfont}{\myfontA}command to recognizemyfontAbut the command\textmyfontstays the same. If I put it before some text, the command will choosemyfontinstead ofmyfontA. So how would I modify the actual command? Or I can rename\textmyfontcommand to anything I want like\textmyfontA? – tryingout Mar 28 '22 at 09:23