0

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:00
  • Does it work with plain pdflatex? I can't use XeTeX in my paper, it's not an option that I can have. – Byron Hawkins Jul 01 '20 at 17:03
  • Better: https://tex.stackexchange.com/questions/25249/how-do-i-use-a-particular-font-for-a-small-section-of-text-in-my-document –  Jul 01 '20 at 17:09
  • Thanks, I just found that answer actually, but it doesn't work at all in my document. No effect whatsoever. No errors. Nothing. – Byron Hawkins Jul 01 '20 at 17:22
  • 2
    Try Carlito-TLF, Carlito-LF, CarlitoOsF or CarlitoTOsF instead. They are listed in the .sty file –  Jul 01 '20 at 19:09
  • 1
    the command you show is the no-argument form like \itshape not 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
  • @JairoADelRio that works! – Byron Hawkins Jul 01 '20 at 23:41
  • @DavidCarlisle there was indeed an error in the log file, and I found it by searching exactly the same way I had before. Perhaps there was some other problem interfering. – Byron Hawkins Jul 01 '20 at 23:42

0 Answers0