In a standard document class I can use something like \texttt{foobar} to get the word "foobar" in a monospace font. How can I make my own macros that specify the font of my choice, for example I want \tag{foobar} to print "foobar" in Carlito font. The \tag macro should not affect anything else such as the document font or class, it's just a macro and it only applies to the text inside the braces (here it's "foobar", nothing changes after that). Is this possible?
This macro is suggested by another answer (see comments), but has no effect in my document:
\newcommand*{\carlito}{\fontfamily{Carlito}\selectfont}
There are no errors, the usage \carlito{foobar} simply prints "foobar" in the main text font.
\usepackage{fontspec}\definefontfamily\myfont{TheFontToBeChosen}\newcommand{\usemyfont}[1]{{\myfont #1}}in XeTeX/LuaTeX – Jul 01 '20 at 17:00Carlito-TLF,Carlito-LF,CarlitoOsForCarlitoTOsFinstead. They are listed in the .sty file – Jul 01 '20 at 19:09\itshapenot like\textit{...}so would make the rest of the document (or current group) in that font. If it does not change the font there will be warnings in the log file. It can not do nothing and leave no warning. – David Carlisle Jul 01 '20 at 22:48