Introduction to LATEX

Introduction to LATEX
1. Getting started
Markus Harju
Mathematical Sciences
About LATEX
a
I LATEX
is a document preparation system to easily create
beautiful documents that contain mathematics
I
I
Origins in TEX system developed by D. Knuth in 1970s. LATEX
is a macro collection developed by Leslie Lamport to simplify
the use of TEX.
Books/manuals:
I
I
I
Oetiker T et.al. : "The Not So Short Introduction to
LATEX 2ε ". Freely available in internet.
Kopka H, Daly P W: "A Guide to LATEX".
Mittelbach F, Goossens M: "The LaTeX Companion".
1. Getting started
Johdatus LaTeXiin
(2/10)
Technical aspects
a
I LATEX
is available to nearly all computer environments
(Windows, Mac, Linux, Unix,...) and even free of charge.
I
In Windows there is the MiKTeX distribution
(http://miktex.org), in Mac OSX there is MacTeX
I
typesetting environments: Texmaker, TeXnicCenter,
TeXworks,...
I
All these can be found in internet by searching
Availability at university campus:
I
I
I
I
I
classrooms MA336, MA337 and MA343
IT services: PC Hall PR106, TellUs, Pegasus
student Unix machines paju and haapa. Also staff Unix
machines koivu and honka.
Instructions for home installation on the course homepage.
1. Getting started
Johdatus LaTeXiin
(3/10)
a
Name of the game
I
Document preparation consists of two steps:
1. Create an input file in plain text (e.g. thesis.tex)
2. Use LATEX program to produce the document (thesis.dvi) by
issuing the command latex thesis.tex
I
Typesetting is easier by using buttons in typesetting
environments:
(a) TexnicCenter
I
I
(b) Texmaker
DVI is preview file, not a real electronic document
You can also try other profiles in TeXnicCenter. For example,
”LaTeX => PDF” produces a PDF document ready for
printing. Schematically:
.dvi
.ps
.pdf
.tex
.pdf
I
Create a separate folders for each individual document.
1. Getting started
Johdatus LaTeXiin
(4/10)
a
Input files 1/2
I
The input files (.tex) have two-part structure:
I
I
I
I
I
preamble
body
Input file contains actual text and commands of the form
(note the backslash, braces and brackets)
\commandname
\commandname{arguments} \commandname[optional
arguments]{arguments}
For example, \LaTeX is a command which outputs: LATEX
Input file is started with the command
\documentclass{class}, where class specifies the
document class to be used, e.g. \documentclass{article}.
Preamble starts here.
You can load macro packages in the preamble by using the
command \usepackage and so extend the basic
functionalities of LATEX.
1. Getting started
Johdatus LaTeXiin
(5/10)
Input files 2/2
a
I
The command \begin{document} ends the preamble and
starts the body (the actual content of the document).
I
Body is ended with the command \end{document}. Any
subsequent commands are ignored by LATEX.
I
The document is prepared by typing text and entering
formatting commands (cf. HTML markup language).
I
A minimal document:
\documentclass{article}
\begin{document}
Hello World!
\end{document}
I
Demo: Prepare a simple document.
1. Getting started
Johdatus LaTeXiin
(6/10)
Finnish language
a
I
By default, LATEX supports only documents in English
language
I
To type Finnish umlauts (dieresis) and activate Finnish
hyphenation one must load packages in the preamble:
\documentclass{article}
\usepackage[finnish]{babel}
\usepackage[ansinew]{inputenc}% tai ansinew->utf8
\usepackage[T1]{fontenc}
\begin{document}
Päivää maailma!
\end{document}
I
Demo: Prepare a simple document in Finnish.
1. Getting started
Johdatus LaTeXiin
(7/10)
a
Typing the text
I
The body text is typed into the input file in usual fashion
(nearly)
I LATEX
handles the text formatting (font face, font size, line
spacing, margins, etc.) via its document classes
I
The user needs only to provide content and structure
I
Words are separated with a single white space (blank). Any
additional white spaces are ignored. A line break is a white
space. Sometimes a forced white space is needed. This is
achieved by a backslash followed by white space.
I
A blank line in input file starts a new paragraph. Any
additional blank lines are again ignored.
I
Commenting using percent sign %
I
Demo: Illustrate white spaces (blanks), line breaks and
comments.
1. Getting started
Johdatus LaTeXiin
(8/10)
Specialities 1/2
a
I
Certain special characters are reserved for LATEX’s own
purposes. They are:
# $ % ˆ & _ { } ˜ \
These can be printed by the following commands:
\# \$ \% \ˆ \& \_ \{ \}
\textasciitilde or \˜{}
\textbackslash
See also \textasciicircum which outputs ^
I
"Quotation marks" can be printed using one or two
‘left-quotes‘ or ’right-quotes’. ”Two right-quotes”, “two
left-quotes“ to produce double quotes. Try them out to find
the ones that suit you best.
1. Getting started
Johdatus LaTeXiin
(9/10)
Specialities 2/2
a
I
I
Horizontal lines of varying length are produced by hyphen key:
input
usage
example
hyphen
daughter-in-law
-en-dash
pages 13–34
--em-dash
I think — therefore I am.
$-1-2$ minus sign
−1 − 2
Foreign accents are produced by dedicated commands:
\’ o ó \‘ o ò \ˆo ô \˜ o õ
\= o ō \. o ȯ \"o ö \c c ç
\u o ŏ \v o ǒ \d o o. \b o o
¯
\o
ø
\O
Ø \ae æ \oe œ
\i
ı
\j

!‘
¡
?‘
¿
1. Getting started
Johdatus LaTeXiin
(10/10)