Font and Font Selection in LaTeX

Fonts

You will need to define your fonts at the beginning of any LaTeX document. After defining them, you'll only need to use font commands to change the font, for instance to bold or italicize a word or words.

In LaTeX, there are generally three styles within any font family, which are distinguished as font family, font shape, and font series. The commands for family, shape, and series are commutative, so they can be combined as with the command:
{\bfseries\itshape\sfffamily text you want in bold, italics, and sans-serif}

The above command would make the type in bold, italic, and sans-serif. The commands for font can only be combined as long as they aren't contradictory. Contradictory font commands would be trying to get slanted italics, or attempting to combine different font families.

LaTeX expects three font families:
Font Family Code Command
Roman (serif, with tails on the uprights) as the default rm \textrm{text}
Sans-serif, with no tails on the uprights sf \textsf{text}
Monospace (fixed-width or typewriter) tt \texttt{text}

For the common type shape and series commands, use the simplified syntax in the table below.

Type Style Command Example

Style Name
Syntax Example
Italic
\textit{words in italics}
Slanted
\textsl{words to be slanted}
Small Capitals
\textsc{words to be in small capitals}
Bold
\textbf{words to be in bold}
Sans-serif
\textsf{words to be in sans-serif}
Monospace
\texttt{words to be in monospace}
Emphasis
\emph{word} italicizes word(s)
Monospace
{\tt words}
Italics
{\it words}

Font Size

Font size in LaTeX is controlled with font size commands. Please note that you will need to reset the font size with one of these commands after changing it. Also, note that certain commands may overrule the font size commands; for instance, the \end{center} will cancel the font size commands. If you want to select just some text for a size change, use the following commands in the bracket, command, bracket words, close bracket, close bracket syntax; like this: {\huge{short}}. The commands and their sizes are listed in the table below.

Command Nominal
Point Size
Exact Point Size
\tiny
5
5
\scriptsize
7
7
\footnotesize
8
8
\small
9
9
\normalsize
10
10
\large
12
12
\Large
14
14.40
\LARGE
18
17.28
\huge
20
20.74
\Huge
24
24.88

Changing Fonts

If you use any packages that change the font, those packages will change the default of the same type. For instance, using the Bookman font (which is done by using this command in the preamble: \usepackage{bookman})makes the default Roman font Bookman, but leaves the sans-serif and monospace fonts alone. Similarly, using the Helvetica font (done with this command in the preamble: \usepackage{helvet}) changes the default sas-serif font to Helvetica, but leaves the Roman and Monospace fonts alone. When changing fonts, you can do so like this, using the command and calling the particular font, or you can change all of the default fonts at once with the following commands.
Command Changes the defaults to
times Times, Helvetica, Courier
pslatex same as Times, but uses a specially narrowed Courier. This is preferred over Times because of the way it handles Courier.
newcent New Century Schoolbook, Avant Garde, Courier
palatino Palatino, Helevetica, Courier
palatcm changes the Roman to Palatino only, but uses CM mathematics

For more on the fonts available with a typical LaTeX installation, please see the documentation in the IMAGE Lab (page 75 in A Beginner's Guide to Typsetting with LaTeX). Also, please note that there are many more fonts available for download.

Changing Fonts Temporarily

To change the font temporarily, first group the text where you want the font changed in curly braces. Then, use the commands \fontencoding, \fontfamily, and \selectfont. These commands should be used immediately inside the opening curly braces, like:

{\fontfamily{phv}\selectfont Helvetica looks like this}
and {\fontencoding{OT1}\fontfamily{ppl} Palatino looks like this}.
}

The above commands would make a sentence where "Helvetica looks like this" would be in the Helvetica font (phv is the code for Helvetica) and "and" would be in the default font and "Palatino looks like this" would be in the Palatino font (denoted with the Palatino code, which is ppl). This example would be very rare, but it shows how the fonts can be changed in the most extreme circumstances.

Font Color

Using the color package (which must be called in the Preamble), you can typeset LaTeX in any color. To add the color package in the Preamble, use the command:
\usepackage{color}

The color package makes a default color package available. The colors available with this are: red, green, and blue (for screen display) and cyan, magenta, and yellow (to go with black for the CMYK color model for printing). To make a single word or phrase in color, use the command:
\textcolor{color}{words to be in color}
For example, \textcolor{red}{text in red}

For more on color and how to use 255 colors, please see the documentation in the IMAGE Lab.

No comments:

Post a Comment