You are on page 1of 14

RuG LaTEX Course 2012

Additional topics
Contents
1 Tabulars
1.1 Basics . . . . . . . . . . . . . . .
1.2 Partial rules . . . . . . . . . . . .
1.3 Multicolumn . . . . . . . . . . .
1.4 Decimal alignment . . . . . . .
1.5 Text columns . . . . . . . . . . .
1.6 Shortcuts . . . . . . . . . . . . .
1.7 Practice documents for tables .

.
.
.
.
.
.
.

2
2
3
3
3
3
4
4

2 Graphics for LaTEX


2.1 External graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Producers of graphic files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Including an external graphics file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4
5
6
6

3 Floating figures and tables


3.1 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Practice documents for graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7
8
9

4 Presentations
4.1 Alternatives . . . . . . . . . . .
4.2 Getting started with Beamer
4.3 Slides are frames . . . . . . .
4.4 Themes . . . . . . . . . . . . .
4.5 Modes . . . . . . . . . . . . . .
4.6 What about sections? . . . . .
4.7 Practice . . . . . . . . . . . . .

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

9
9
9
10
10
10
10
10

5 Changing the appearance


5.1 Empty lines instead of paragraph indentation . .
5.2 Double-spacing . . . . . . . . . . . . . . . . . . . .
5.3 Display math alignment . . . . . . . . . . . . . . .
5.4 Page dimensions . . . . . . . . . . . . . . . . . . . .
5.5 Font size . . . . . . . . . . . . . . . . . . . . . . . . .
5.6 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7 Using system fonts with XeLaTeX and LuaLaTeX

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

11
11
11
11
11
12
12
12

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

6 Language support
13
6.1 Babel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.2 Non-western scripts with XeTeX and LuaTeX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Documentation and online resources

13

Introduction
This weeks topics include tables, graphics and floats, objects which may be placed out of
sequence. The final main topic is presentations. Practice consists of:

Fall 2012

creating various LaTEX tables with help of the examples in section 1

recreating some non-LaTEX tables in LaTEX

including external graphics files in a LaTEX document

creating and modifying a presentation, starting out from a supplied sample presentation

ADDITIONAL TOPICS

This sessions zipfile 2more.zip contains sample code, a file with table examples to be recreated
and a subdirectory with graphics suitable for inclusion in LaTEX; see sections 1.7, 3.2 and 4.2.
Bonus topics are section 5, which contains some simple recipes for changing the appearance of
your document, and section 6 on typesetting in other languages.

1 Tabulars
1.1

Basics
Outside math mode, the tabular environment provides tables, which can be considered the
text counterpart of multicolumn arrays. As with math arrays, columns are separated with &
and rows with \\.
TeXstudio has a tabular wizard, but it is not much help when things get hairy.
A very basic table:
\begin{tabular}{lcr}
small & whatever & 1 \\
big
& huh?
& 10000
\end{tabular}

small
big

whatever
huh?

1
10000

There is a preamble {lcr} which defines the alignment of the columns.


A table with some empty cells:
\begin{tabular}{lcr}
small & whatever \\
big
&
& 10000
\end{tabular}

small
big

whatever
10000

You do not need to put in an ampersand & for empty cells at the end.
You can add vertical rules in the preamble and horizontal rules with an \hline command:
\begin{tabular}[t]{|l|r|r|}
\hline
& \textit{Butter} & \textit{Cheese} \\
\hline
2000 & 9.1 & 5.7 \\
\hline
2001 & 11.7 & 6.3 \\
\hline
2002 & 12.2 & 6.5 \\
\hline
\end{tabular}

2000
2001
2002

Butter
9.1
11.7
12.2

Cheese
5.7
6.3
6.5

If you use horizontal rules at all, you should include commands


\usepackage{array}
\setlength\extrarowheight{1pt}

in the preamble, to get a little bit of space between rules and the cells below. You can also issue
an \extrarowheight command in the middle of your document.
Fewer rules is probably better; see table 1 (from now on, \extrarowheight is set to 1pt):

2000
2001
2002

Butter
9.1
11.7
12.2

Cheese
5.7
6.3
6.5

Table 1. Fewer rules are better

RUG LATEX COURSE

Tabulars

1.2

Partial rules
\begin{tabular}{|lrr|}
\hline
& \textit{Butter} & \textit{Cheese} \\
\cline{2-3}
2000 & 9.1 & 5.7 \\
2001 & 11.7 & 6.3 \\
2002 & 12.2 & 6.5 \\
\hline
\end{tabular}

1.3

2000
2001
2002

Butter
9.1
11.7
12.2

Cheese
5.7
6.3
6.5

Multicolumn
the \multicolumn macro lets you join columns, or change the alignment of a column:
\begin{tabular}{|lrr|}
\hline
& \multicolumn{2}{c|}{Products} \\
\cline{2-3}
& \multicolumn{1}{c}{\textit{B.}}
& \multicolumn{1}{c|}{\textit{C.}} \\
\cline{2-3}
...

1.4

2000
2001
2002

Products
B.
C.
910.1
5.7
1111.7
6.3
1112.2 66.5

Decimal alignment
Often, you can simply right-align, since typically all data in a column are specified with the
same number of decimal digits. This is the case with the Butter / Cheese examples above.
If this isnt the case, you can put the following code in your preamble:
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}

This lets you use column types d{n.m} with n digits before the decimal point and m after:
\begin{tabular}{|l|d{4.2}|d{4.1}|}
\hline
2000 & 910.1 & 5.7 \\
2001 & 1111.77 & 6 \\
2002 & 1112.2 & 6666.5 \\
\hline
\end{tabular}

1.5

2000
2001
2002

910.1
1111.77
1112.2

5.7
6
6666.5

Text columns
For multiline texts, there is the p{...} column specification:

\begin{tabular}{|lp{2.2in}|}
\hline
array
& An improved implementation of \LaTeXs
tabular and array environment\\
dcolumn & Provides decimal and other alignment
for tabular- and array environments\\
\hline
\end{tabular}

array

dcolumn

An improved implementation of
LaTEXs tabular and array environment
Provides decimal and other alignment
for tabular- and array environments

Usually, text cells are far too narrow for good justification. Here, ragged right would be much
better. This can be done with the array package, which provides syntax for adding LaTEX code
before (and after) each column entry:

Fall 2012

ADDITIONAL TOPICS
\usepackage{array}
\newcolumntype{P}[1]{%
>{\raggedright\hspace{0pt}\arraybackslash}p{#1}}
\begin{tabular}{|l|P{1.65cm}|}
\hline
What is \TeX? & \TeX{} is a programming
language for typesetting.\\
\hline
\end{tabular}

What is TEX?

TEX is a
programming
language
for typesetting.

See the documentation of the array- and dcolumn packages for additional details on typesetting
tabulars.

1.6

Shortcuts
Of course, nobody wants to re-key reams of numbers. There are several solutions:

If your data are in a simple text file, or at least in a reasonably simple binary format, it may
be a nice programming exercise to convert them into LaTEX.

There is an excel2latex plugin for Excel, available from CTAN, which can create a file with a
LaTEX tabular environment from a spreadsheet range.
There is a LaTEX package odsfile which can read OpenOffice/LibreOffice spreadsheets directly, e.g.:

\usepackage{odsfile}
...
\begin{tabular}{...}
\includespread[file=filename.ods,range=a3:f8]
\end{tabular}

This package requires the lualatex engine. It is or soon will be part of our TEX Live installation.

1.7

A quick-and-dirty method: you can export (part of) a spreadsheet in pdf format and include
it as a graphic; see the next section.

Practice documents for tables


The file 2more.zip contains the following table-related files:

sample_tabs.tex

sample_tabs.pdf

utp-tables.pdf with tables which you can try to reproduce.

The tables in utp-tables.pdf come from Unix Text Processing, an old Unix text which has been
republished in OReillys Open Book Project: http://oreilly.com/openbook/utp/1 .

2 Graphics for LaTEX


Broadly speaking, there are two ways to get pictures into your LaTEX output:
1. Create graphics externally, and load them with LaTEX commands
2. Add picture code directly to the LaTEX source.
The TikZ package offers a convenient general-purpose set of macros for programming diagrams,
and there are several other options. However, in this course we shall only look at external
graphics.
1. Dont worry about reproducing vertical centering within a row. Although this can be done with LaTEX, it will not be
discussed here and requires loading an additional package.

RUG LATEX COURSE

Graphics for LaTEX

Figure 1. Bitmapped- or raster graphics: above a photograph, below a screenshot, both


with an enlarged detail at the right

2.1

External graphics
Before we go any further, you should have some rudimentary understanding of graphics file
formats. The most important distinction is between bitmaps and vectors.
Bitmaps are built up from pixels, i.e. tiny blocks of solid color. The smaller the blocks, the
sharper the picture and the bigger the file. If you scale them up too far, the blocks become
apparent; see figure 1.
Vector graphics are built up from mathematical shapes: lines, arcs, bzier curves, text objects;
see figure 2. They scale well.
Pdflatex and the other TEX engines can only work with certain types of graphics:
pdf can contain both bitmapped and vector elements.
eps is closely related to pdf and can also contain both bitmapped and vector elements. It will
be converted behind the scenes to pdf, at least if the TEX installation allows it2 .
png is a bitmapped format. It is first choice for screenshots.
jpg or jpeg is a bitmapped format with lossy compression3 . It is first choice for photographic
images.
2. If you need more control over the eps to pdf conversion, or need conversion the other way, or need to crop margins,
have a look at the PostScript- and pdf conversions utility in the Utilities submenu of the RuG TEX Live menu.
3. To reduce file size, bitmapped images are usually compressed. For png this is done in a lossless way, i.e. the
decompressed image and the original image contain identical information. Jpeg is compressed in a lossy way, i.e.
information gets lost. However, jpeg compression works very well for photographic images, which can be reduced to
10% of their original file size without visible loss of quality.

Fall 2012

ADDITIONAL TOPICS

Figure 2. Vector art: a LibreOffice data plot, a drawing adapted from a Ghostscript
example file and a graphic generated with MetaPost

2.2

Producers of graphic files


Mathematical software (R, MATLAB, Octave, Gnuplot) can generate eps and sometimes pdf.
Professional illustration software can usually export to eps and pdf. Inkscape is a capable free
alternative.
OpenOffice/LibreOffice and MS Office can export documents and selections of documents to
pdf.
Figure 2 shows vector graphics created by various programs.
I am not going to list programs for bitmapped graphics. There are many good ones, often free
or inexpensive.
Download Figures in LaTEX (figlatex.pdf) for a more in-depth discussion.

2.3

Including an external graphics file


Graphics inclusion is not built into the LaTEX core. The graphicx package provides this facility.
You need to load it in the preamble with

RUG LATEX COURSE

he E
3

Floating figures and tables

The End
01/04/07

Figure 3. Raster and vector combined

\usepackage{graphicx}

You can place a figure in your document with code such as


\includegraphics{your_picture}

Normally, you dont need to specify the extension. Pdflatex will look for your_picture.jpg,
your_picture.png and your_picture.pdf.
With the above code, the graphic file should be in the same directory as your .tex file. With a
command
\includegraphics{graphics/your_picture}

pdflatex will look in the graphics subdirectory.


Make sure to use a relative path, forward slashes and no spaces or funny characters in file- or directory names: graphics/your_picture is fine, c:\Documents and Settings\your_name\your
picture is not. The TeXstudio Insert Graphics wizard tries to produce the right syntax.

01/04/07

If the picture is too large or too small, you can scale it to the desired size with a width or
height parameter:
\includegraphics[height=.3in]{graphics/mouse}

You can also rotate a picture with an angle parameter, see Figure 4 which has been inserted
with
\includegraphics[width=.7in,angle=180]{graphics/mouse}

3 Floating figures and tables


If you place large objects such as figures or tables at their natural position in the text stream,
you tend to get awkward page breaks.

Figure 4. An upside-down figure

Fall 2012

ADDITIONAL TOPICS

In LaTEX, the term float indicates an object which can be relocated, e.g. to the top or bottom of
a page. LaTEX defines two float environments: the table- and the figure environment. It is
possible to define more. Table 1 on page 2 has been placed with the following code:
\begin{table}[b]
\begin{tabular}[t]{lrr}
...
\end{tabular}
\caption{Fewer rules are better}
\label{tab:rules}
\end{table}

and Figure 4 on page 7 with:


\begin{figure}[b]
\centering
\includegraphics[width=.7in,angle=180]{mouse}
\caption{An upside-down figure}\label{fig:float}
\end{figure}

Codes [t] [b] or [tb] are optional placement specifiers. They indicate preferred placement of
the float: at the bottom of the page (b), the top (t), here (h) or on a float page (p). Default:
[tbp].
Within both environments, a \caption command is defined. In the examples above, there is a
\label command after the \caption command for cross-referencing.
Placing floats where you want them can be a bit easier with some or all of the following commands in the preamble:
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{3}
\setcounter{dbltopnumber}{2}
\renewcommand{\topfraction}{.9}
\renewcommand{\textfraction}{.1}
\renewcommand{\bottomfraction}{.75}
\renewcommand{\floatpagefraction}{.9}
\renewcommand{\dblfloatpagefraction}{.9}
\renewcommand{\dbltopfraction}{.9}

With these codes, LaTEX is more willing to put several floats on a single page and to devote a
larger portion of the page to floats without resorting to a dedicated float page.

3.1

Footnotes
Footnotes are another class of object that are placed out of order:

Here comes a footnote.\footnote{%


This is the footnote.}
And some more text.

Here comes a footnote.1 And


some more text.
1 This

is the footnote.

A special case is a footnote attached to the title or author of an article. Note that the footnote
should be inside the title- or author parameter.

RUG LATEX COURSE

Presentations

Sample title
A.U. Thor
\title{Sample title\thanks{%
Supported by a grant}}
\author{A.U. Thor\thanks{%
And another grant}}
\maketitle
First line of regular text.\footnote{%
With a regular footnote.} And some more text.

January 31, 2009


First line of regular text.1 And
some more text.
Supported

by a grant
another grant
1 With a regular footnote.
And

3.2

Practice documents for graphics


The file 2more.zip contains the following graphics-related files:

sample_text.tex, a latex file to which you can add figures, tables and footnotes. You can
also try out the tweaks from section 5. You can use a text of your own if you prefer.

sample_text.pdf

A graphics subdirectory with various pdflatex-compatible graphic files to include.

4 Presentations
Currently, the most popular presentations package is Beamer, and that is the package that we
are going to discuss.

4.1

Alternatives
However, there are alternatives. For instance, if you have minimalistic tastes then you could
simply set up suitable page dimensions with the geometry package:
\usepackage[%
paperwidth=108mm,
paperheight=81mm,
width=88mm,
height=62mm,
top=9mm,
footskip=20pt]{geometry}

Some
discussion
points

For my own presentation classfiles I start out along these lines.


Other presentation classfiles besides Beamer are seminar, foil, prosper, HA-prosper and
powerdot.

4.2

Getting started with Beamer


Beamer comes with elaborate but unwieldy documentation; file-search in Documentation /
texdoctk for beameruserguide. For a faster start, I added mybeamer.tex to the practice
files. You can also dig up the solutions files from the official documentation, in <TEX Live
root>\texmf-dist\doc\latex\beamer\solutions.

Fall 2012

10

ADDITIONAL TOPICS

4.3

Slides are frames


Your presentation consist of a series of frames:
\begin{frame}{Frame title}
some content
\end{frame}

Despite the use of curly braces, the frame title is actually optional.
There are various ways to display a frame progressively. In Beamer terminology, these successive
stages are overlays. A simple way to create them is with the \pause command:
Short title
First

\begin{frame}{Points}
\begin{itemize}
\item Some
\pause
\item discussion
\pause
\item points
\end{itemize}
\end{frame}

Points

Some
discussion
points

Chapter 9 of the Beamer manual gives more details.

4.4

Themes
Beamer uses themes to control different aspects of the presentation: layout, colors, headers and
footers, fonts. The manual shows examples of different themes such as the default theme (no
\usetheme command), Bergen, Madrid and CambridgeUS.
Instead of such a comprehensive theme you can also load component themes. Read Part III of
the manual for details.

4.5

Modes
Beamer makes it possible to combine an article and a presentation into a single source. There
is a \mode<thismode>{...} command to tell Beamer that the contents between braces only
applies to thismode, where thismode can be presentation or article.

4.6

What about sections?


You can use sectioning commands between frames. They may or may not be used in presentation mode, depending on your theme: some themes, such as Montpellier, will display them
in the page header. They will also be listed by a \tableofcontents command, which you can
put into a frame.

4.7

Practice
Play around with mybeamer.tex from the zipfile and with the solution templates from the
Beamer documentation. Things to try:

Display bulleted lists progressively by inserting \pause commands.

Include graphics. Do not use a figure environment; just use an \includegraphics command and add little or no text to the frame

Try out various themes.

See how sectioning commands show up in the output.

RUG LATEX COURSE

11

Changing the appearance

5 Changing the appearance


A few simple fixes:

5.1

Empty lines instead of paragraph indentation


Use the parskip package. Add the following line to the preamble:
\usepackage{parskip}

The left sample below is typeset without, the right one with this package:
On November 14, 1885, Senator & Mrs. Leland
Stanford called together at their San Francisco mansion the 24 prominent men who had been chosen as
the first trustees of The Leland Stanford Junior University.
They handed to the board the Founding Grant
of the University, which they had executed three days
before. This document with various amendments,
legislative acts, and court decrees remains as the
Universitys charter.

On November 14, 1885, Senator & Mrs. Leland Stanford called together at their San Francisco mansion
the 24 prominent men who had been chosen as the
first trustees of The Leland Stanford Junior University.
They handed to the board the Founding Grant of
the University, which they had executed three days
before. This document with various amendments,
legislative acts, and court decrees remains as the
Universitys charter.

This also takes care of vertical spacing of itemize- and enumerate environments. This is still
just a quick-and-dirty hack; for a professional result all measurements should be harmonized.

5.2

Double-spacing
This looks awful, but is often required for draft printouts. A line
\usepackage[doublespacing]{setspace}

or
\usepackage[onehalfspacing]{setspace}

in the preamble will do the trick.

5.3

Display math alignment


A documentclass option fleqn:
\documentclass[fleqn]{article}

ensures that displayed equations are not centered but left-aligned, with a fixed indentation from
the left. The left sample below has the default centered alignment of equations, the right one
has the option applied and has left-aligned equations:

ln

Q
L


= c0 +
0,T

IG
Q


+

(1)

0,T

The price and demand elasticities can now be calculated by:


C j
ln C
(2)
=
Cj =
ln j
j C

5.4

ln

Q
L


= c0 +
0,T

IG
Q


+

(1)

0,T

The price and demand elasticities can now be calculated by:


Cj =

ln C
C j
=
ln j
j C

(2)

Page dimensions
\usepackage[textwidth=10cm,textheight=17cm]{geometry}

There are a lot of options, also for page headers and -footers and for an asymmetric layout.
File-search for geometry with texdoctk.

Fall 2012

12

ADDITIONAL TOPICS

5.5

Font size
For a slightly larger font, use the 11pt- or 12pt document class option:
\documentclass[12pt]{article}

The default is 10pt. This only works for these predefined sizes. Anything else requires a lot
more coding.

5.6

Fonts
Several packages change the font for the entire document. However, good math fonts are in
short supply, so choices are limited if you want matching math typesetting. Check out A Survey of
Free Math Fonts for TEX and LaTEX (somewhat dated) and search for font in the CTAN Catalogue.
The typeset samples below have the required preamble commands on the left. Palatino:
ln
\usepackage[TS1,T1]{fontenc}
\usepackage{amsmath}
\usepackage{mathpazo}

Q
L

= c0 +
0,T

IG
Q

(1)

0,T

The price and demand elasticities can now be calculated by:


C j
ln C
=
(2)
Cj =
ln j
j C

We expect official free math fonts for Times before the end of the year, as part of the TeX Gyre
font project. These will be included in TEX Live. For now, you can use e.g. the mathptmx package:

ln
\usepackage[TS1,T1]{fontenc}
\usepackage{amsmath}
\usepackage{mathptmx}

 G
 
I
Q
= c0 +
+
L 0,T
Q 0,T

(1)

The price and demand elasticities can now be calculated


by:
lnC
C j
C j =
(2)
=
ln j
j C

The Bitstream Charter-based font setup of these notes:


ln
\usepackage{amsmath}
\usepackage[charter]{mathdesign}

5.7

 
Q
L

= c0 +
0,T

IG
Q

(1)

0,T

The price and demand elasticities can now be calculated


by:
ln C
C j
"C j =
=
(2)
ln j
j C

Using system fonts with XeLaTeX and LuaLaTeX


The xelatex- and lualatex TEX engines support system fonts, including non-latin scripts and
modern Unicode-based OpenType fonts. This requires the fontspec package.
XeTeX was originally developed to access Mac OS system fonts. Later, it was ported to Linux and
Windows.
LuaTeX has wider ambitions, but what matters here is that it has adopted XeTeXs support for
system fonts and modern font technologies. LuaTeX still has some rough edges and is slower
than XeTeX, but development mostly focuses on LuaTeX, so eventually it should become the
better choice and maybe it already is, depending on what you do. In many cases, you can
switch between the two without changing your LaTEX sources.
Both are available in TeXstudio via the Tools / Commands menu, but you can also set one of
these as the default via Options / Configure TeXstudio... / Build / Default Compiler.
Input encoding. There can be some ambiguity in the interpretation of accented characters. For
XeTeX and LuaTeX, either make sure that your editor knows that the source is UTF-8 (TeXstudio

RUG LATEX COURSE

13

Language support

displays this at the right end of the status bar at the bottom), or always write \e rather than .
And do not use the inputenc package.
Cambria. The Cambria font family is especially useful since it contains a full set of mathematical symbols. It is present on most Windows systems and is bundled with e.g. the free PowerPoint
viewer:
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}
\fontspec{Cambria}
\setmainfont{Cambria}
\setmathfont{Cambria Math}

ln ( ) = + ( ) +
,
,

(1)

The price and demand elasticities can now be calculated by:


ln

=
=
(2)
ln

6 Language support
This section is just to make you aware of LaTEXs support for non-english and multilingual typesetting. It contains no exercises.

6.1

Babel
TEX and LaTEX supports many languages, also within the same document. For LaTEX, language
support is provided by the Babel package. Its principal tasks are proper hyphenation and translation of text strings such as Table of Contents and Chapter.
For e.g. Dutch hyphenation and Dutch text strings, use the following code in the preamble:
\usepackage[dutch]{babel}

It is also possible to use several languages in one document:


\usepackage[english,dutch]{babel}
...
\selectlanguage{english}

See e.g. section 2.5 in The Not So Short Introduction for more particulars.

6.2

Non-western scripts with XeTeX and LuaTeX


Below an Arab example, typeset with XeLaTeX:

. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . (Calendar operations)
. . . . . . . . . . . . . . . . . . . . . . .
..


.
.

The Polyglossia package replaces Babel for XeTeX. At this moment, Polyglossia is not yet adapted
for LuaTeX, but this is hopefully a matter of time. In the meantime, use Babel.

Documentation and online resources


Array package (2011). A new implementation of LaTEXs tabular and array environment, included in most TEX distributions.

Fall 2012

14

DOCUMENTATION AND ONLINE RESOURCES

CTAN. The Comprehensive TEX Archive Network.


CTAN Catalogue.

URL :

URL :

http://mirror.ctan.org/.

http://mirror.ctan.org/help/Catalogue/brief.html.

Dcolumn package (2001). Provides decimal and other alignment for tabular- and array environments, included in most TEX distributions.
Hartke, Stephen G. (2006). A Survey of Free Math Fonts for TEX and LaTEX. URL: http://mirror.
ctan.org/info/Free_Math_Font_Survey/en/.
Kroonenberg, Siep (2012). Figures in LaTEX. URL: http://tex.aanhet.net/rugtex/figlatex.
pdf.
Oetiker, Tobias et al. (2011). The Not So Short Introduction to LaTEX2" . Included in most free TEX
distributions. URL: http://mirror.ctan.org/info/lshort/.
Tantau, Till, Joseph Wright, and Vedran Miletic (2011). The BEAMER class. Published as part of
the beamer package.
TeX Gyre font project.

URL :

http://www.gust.org.pl/projects/e-foundry/tex-gyre/.

Siep Kroonenberg
N dot S dot Kroonenberg at rug dot nl

RUG LATEX COURSE

You might also like