[Tex/LaTex] How to use a particular font for a small section of text in the document


The standard font packages make global changes to the fonts in my document. What if I want to use a particular font for just a portion of my text?

  1. How do I find the right name of the font?
  2. How do I select the font?
  3. How do I restrict the scope of the font change?

There are separate answers for different flavors of TeX (quick links):

Best Answer

Regular LaTeX

Finding the font name

This is actually the hardest part. When you load a regular font package like helvet (which sets the default sans serif font to a Helvetica clone) it issues commands to set up the font using an internal name, which is hidden to regular users. These names traditionally use a system of three or four letter lower case names for each font family. Usually these names are documented in documentation associated with the font.

Here is a list of the most common fonts, and their codes:

Family                 Font Name
pag                    Avant Garde
fvs                    Bitstream Vera Sans
pbk                    Bookman
bch                    Charter
ccr                    Computer Concrete
cmr                    Computer Modern
pcr                    Courier
mdugm                  Garamond
phv                    Helvetica
fi4                    Inconsolata
lmr                    Latin Modern
lmss                   Latin Modern Sans
lmtt                   Latin Modern Typewriter
LinuxBiolinumT-OsF     Linux Biolinum (formerly 'fxb' in older package versions)
LinuxLibertineT-OsF    Linux Libertine (formerly 'fxl' in older package versions)
pnc                    New Century Schoolbook
ppl                    Palatino
qag                    TeX Gyre Adventor 
qbk                    TeX Gyre Bonum 
qzc                    TeX Gyre Chorus
qcr                    TeX Gyre Cursor
qhv                    TeX Gyre Heros
qpl                    TeX Gyre Pagella 
qcs                    TeX Gyre Schola
qtm                    TeX Gyre Termes
ptm                    Times
uncl                   Uncial
put                    Utopia
pzc                    Zapf Chancery

For some greek fonts the codes are:

Artemisia              artemisia 
Baskerville            gfsbaskerville 
Bodoni                 bodoni 
Complutum              complutum 
Didot                  udidot 
Neohellenic            neohellenic 
Porson                 porson 
Solomos                solomos 
Greek Times            txr 
Kerkis                 mak 
LX                     llcmss 
Default                lmr

If you don't find any documentation for the font, as a last resort (or a first resort once you know what you're doing) you can open the .sty file that actually loads the font and see for yourself what the internal font family name is (or you could search inside it with grep). Here are two examples:

From helvet.sty: at the end of the package is the line:


This sets the default sans font (\sfdefault) to the phv family, so phv is the internal name of the font.

From PTSansCaption.sty, you will find the following line:


Here, the internal name is closer to its file name: PTSansCaption-TLF.

Both of these examples have shown the code for changing the default sans serif font. If the font package changes the roman or mono font you would look for the following commands respectively


Selecting the font

To select a font, you use the following commands:


It's often useful to wrap this in a macro:


Restricting the scope of the selection

You can always restrict the scope of font changing commands by enclosing the text in braces:

{\fontfamily{<familyname>}\selectfont ...}

or if using a command

{\myfont ...}

or, to make the scope of the command more visible in your file if you don't have a brace-matching editor

  \myfont ...

If this is something you will be doing a lot, it would make more sense to turn it into a proper environment:


Then you use it like any other environment:

  Some text in the new font.

You can also define a command corresponding to the standard font changing commands such as \textrm or \textsf, but using your particular font:


Use this like the standard commands:

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

An advantage of this command over the simpler version described above is automatic italic correction, cf. Why use \DeclareTextFontCommand vs. just \newcommand?.

Common fonts rendered

(except ccr Compute Concrete).

Common fonts

Related Question