Department of Engineering

IT Services

Colors and fonts

Colored text

Commands that control foreground and background colors need

   \usepackage{color}

after the \documentclass line but before \begin{document}.

  • \textcolor{colorname}{text} writes text in a color which can be specified by name (black, white, red, green, blue or a color name you've defined), RGB components, or grayscale.
  • \colorbox{colorname}{text} writes text in a box with a colored background.
  • \fcolorbox{framecolor}{boxcolor}{text} writes text in a colored frame.
  • \pagecolor{colorname} sets the color of the page's background.
  • \definecolor{colorname}{color specification} lets you define new color names.

\definecolor{gold}{rgb}{0.85,.66,0}
This is in \textcolor{red}{red} and this box is \colorbox{gold}{gold}.
Text color can be set using RGB values 
(\textcolor[rgb]{0,1,0}{like so}), or \textcolor[gray]{0.2}{shades} 
\textcolor[gray]{0.5}{of} \textcolor[gray]{0.8}{grey}.

produces

This is in red and this box is gold. Text color can be set using RGB values (like so), or shades of grey.

Special characters

\dag is created by \dag, \ddag by \ddag, § by \S, ¶ by \P, £ by \pounds, ö by \"{o}, © by \copyright. Many others are available in the math environment, including all the lower case greek letters and most of the upper case ones. If you only want to use a few characters you can bracket the symbols using $ and $ rather than \begin{math} and \end{math}. You can put a slash through any of these characters by prefacing them with \not

$\sqrt{i} $ \sqrt{i} $\sqrt[5]{x+iy} $ \sqrt[5]{x+iy} $\ldots $ \ldots
$\cdots $ \cdots $\vdots$ \vdots $\ddots$ \ddots
$\alpha$ \alpha $\beta$ \beta $\gamma$ \gamma
$\delta$ \delta $\omega$ \omega $\Gamma$ \Gamma
$\Theta$ \Theta $\Omega$ \Omega $\pm$ \pm
$\mp$ \mp $\times$ \times $\div$ \div
$\ast$ \ast $\star$ \star $\circ$ \circ
$\bullet$ \bullet $\cdot$ \cdot $\cap$ \cap
$\bigcap$ \bigcap $\cup$ \cup $\bigcup$ \bigcup
$\uplus$ \uplus $\biguplus$ \biguplus $\sqcap$ \sqcap
$\sqcup$ \sqcup $\bigsqcup$ \bigsqcup $\vee$ \vee
$\bigvee$ \bigvee $\wedge$ \wedge $\bigwedge$ \bigwedge
$\setminus$ \setminus $\wr$ \wr $\diamond$ \diamond
$\bigtriangleup$ \bigtriangleup $\bigtriangledown$ \bigtriangledown $\triangleleft$ \triangleleft
$\triangleright$ \triangleright $\oplus$ \oplus    
$\bigoplus$ \bigoplus $\ominus$ \ominus $\otimes$ \otimes
$\bigotimes$ \bigotimes $\oslash$ \oslash $\odot$ \odot
$\bigodot$ \bigodot $\bigcirc$ \bigcirc $\amalg$ \amalg
$\leq$ \leq $\prec$ \prec $\preceq$ \preceq
$\ll$ \ll $\subset$ \subset $\subseteq$ \subseteq
$\in$ \in $\vdash$ \vdash    
$\geq$ \geq $\succ$ \succ $\succeq$ \succeq
$\gg$ \gg $\supset$ \supset $\supseteq$ \supseteq
$\sqsupseteq$ \sqsupseteq $\ni$ \ni $\dashv$ \dashv
$\equiv$ \equiv $\sim$ \sim $\simeq$ \simeq
$\asymp$ \asymp $\approx$ \approx $\cong$ \cong
$\neq$ \neq $\doteq$ \doteq $\propto$ \propto
$\models$ \models $\perp$ \perp $\mid$ \mid
$\parallel$ \parallel $\bowtie$ \bowtie $\smile$ \smile
$\frown$ \frown $\leftarrow$ \leftarrow $\Leftarrow$ \Leftarrow
$\rightarrow$ \rightarrow $\Rightarrow$ \Rightarrow $\leftrightarrow$ \leftrightarrow
$\Leftrightarrow$ \Leftrightarrow $\mapsto$ \mapsto $\hookleftarrow$ \hookleftarrow
$\leftharpoonup$ \leftharpoonup $\leftharpoondown$ \leftharpoondown $\rightleftharpoons$ \rightleftharpoons
$\longleftarrow$ \longleftarrow $\Longleftarrow$ \Longleftarrow $\longrightarrow$ \longrightarrow
$\Longrightarrow$ \Longrightarrow $\longleftrightarrow$ \longleftrightarrow $\Longleftrightarrow$ \Longleftrightarrow
$\longmapsto$ \longmapsto $\hookrightarrow$ \hookrightarrow $\rightharpoonup$ \rightharpoonup
$\rightharpoondown$ \rightharpoondown $\uparrow$ \uparrow $\Uparrow$ \Uparrow
$\downarrow$ \downarrow $\Downarrow$ \Downarrow $\updownarrow$ \updownarrow
$\nearrow$ \nearrow $\searrow$ \searrow $\swarrow$ \swarrow
$\nwarrow$ \nwarrow $\aleph$ \aleph $\hbar$ \hbar
$\imath$ \imath $\jmath$ \jmath $\ell$ \ell
$\wp$ \wp $\Re$ \Re $\Im$ \Im
$\prime$ \prime $\empty$ \empty $\nabla$ \nabla
$\surd$ \surd $\top$ \top $\bot$ \bot
$\Vert$ \| $\angle$ \angle $\forall$ \forall
$\exists$ \exists $\neg$ \neg $\flat$ \flat
$\natural$ \natural $\sharp$ \sharp $\backslash$ \backslash
$\partial$ \partial $\infty$ \infty $\triangle$ \triangle
$\clubsuit$ \clubsuit $\diamondsuit$ \diamondsuit $\heartsuit$ \heartsuit
$\spadesuit$ \spadesuit $\sum$ \sum $\prod$ \prod
$\coprod$ \coprod $\int$ \int $\oint$ \oint

Font Sizes

These are the available sizes.

tiny scriptsize footnotesize small normalsize
large Large LARGE huge Huge

If, for example, you want to use the smallest size, do

{\tiny ... }

If Huge isn't big enough for you, you can scale a postscript font up using the commands in the graphicx package. \resizebox{!}{5cm}{BIG} produces

\resizebox{!}{5cm}{BIG}

Font Types

Independent of size, these font types are at your disposal :- \textrm (roman), textit(italic), \textsc (SMALL CAPS), \emph (emphasis, but note that if you use emph within emphasized text, you will get roman text), \textsl (slanting), \texttt (teletype), \textbf (boldface), \textsf (sans serif). As long as there's no conflict, these commands can be combined so that, for instance, this is bold sans serif can be produced by \textsf{\textbf{this is bold sans serif}}.

Postscript Fonts

It is easy to write a document that has postscript fonts. We have package support for helvetica (helvetic), utopia, times, optima, newcentury (newcentu), palatino and courier. To use palatino, for instance, all you need to do is add

\usepackage{palatino}

to your file. The pifont package has special commands for using the Zapf Dingbats font. \dingfill{40} completes the line with the specified symbol and \dingline{36} draws a whole line of symbols.

It's a good idea to use a font that's installed in the printer you intend to use.

Font attributes

The commands above should give you sufficient control over fonts. If you don't want to know more at the moment then turn to section 4

Every text font in LATEX has five attributes:

encoding
This specifies the order that characters appear in the font. The most common values for the font encoding is OT1.
family
The name for a collection of fonts, usually grouped under a common name by the font foundry. For example, `Adobe Times' and Knuth's `Computer Modern Roman' are font families. There are far too many font families to list them all, but some common ones are:

 
Internal fontname Fontname In ljmr1?
cmr Computer Modern Roman No
cmss Computer Modern Sans No
cmtt Computer Modern Typewriter No
cmm Computer Modern Math Italic No
cmsy Computer Modern Math Symbols No
cmex Computer Modern Math Extensions No
ptm Adobe Times Yes
phv Adobe Helvetica Yes
pcr Adobe Courier Yes
pun Univers No
ppl Palatino Yes
pagk AvantGarde-Book Yes
pagd AvantGarde-Demi Yes
pbk Bookman Yes
put Utopia No
pop Optima No
pnc New Century Schoolbook Yes
pzd ZapfDingbats Yes
rpad Garamond No

series
How heavy or expanded a font is. For example, `medium weight', `narrow' and `bold extended' are all series. The most common values for the font series are:

m Medium
b Bold
bx Bold extended
sb Semi-bold
c Condensed


shape
The form of the letters within a font family. For example, `italic', `oblique' and `upright' are all font shapes. The most common values for the font shape are:

n Normal (that is `upright' or `roman')
it Italic
sl Slanted (or `oblique')
sc Caps and small caps


size
The design size of the font, for example `10pt'.

These five parameters specify every LATEX font, for example:

  Font
OT1 cmr m n 10pt Computer Modern Roman 10pt
OT1 cmss m sl 12pt Computer Modern Sans Oblique 12pt
OML cmm m it 10pt Computer Modern Math Italic 10pt
T1 ptm b it 18pt Adobe Times Bold Italic 18pt

Selection commands

There are commands to set attributes one at a time:

Command Attribute Value in article class, 10pt
\textrm{..} or \rmfamily family cmr
\textsf{..} or \sffamily family cmss
\texttt{..} or \ttfamily family cmtt
\textmd{..} or \mdseries series m
\textbf{..} or \bfseries series bx
\textup{..} or \upshape shape n
\textit{..} or \itshape shape it
\textsl{..} or \slshape shape sl
\textsc{..} or \scshape shape sc
\tiny size 5pt
\scriptsize size 7pt
\footnotesize size 8pt
\small size 9pt
\normalsize size 10pt
\large size 12pt
\Large size 14.4pt
\LARGE size 17.28pt
\huge size 20.74pt
\Huge size 24.88pt

The low-level commands used to change font attributes are as follows.

\fontencoding{encoding}
\fontfamily{family}
\fontseries{series}
\fontshape{shape}
\fontsize{size}{baselineskip}

Each of these commands sets one of the font attributes; \fontsize also sets \baselineskip. The actual font in use is not altered by these commands, but the current attributes are used to determine which font to use after the next \selectfont command.

\selectfont selects a text font, based on the current values of the font attributes. There must be a \selectfont command immediately after any settings of the font parameters by (some of) the five \font<parameter> commands, before any following text. For example, it is legal to say:

   \fontfamily{ptm}\fontseries{b}\selectfont Some text.

to select bold Times Roman, but it is not legal to say:

   \fontfamily{ptm} Some \fontseries{b}\selectfont text.

\usefont{encoding}{family}{series}{shape}

is short hand for the equivalent \font... commands followed by\selectfont.