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