Vous êtes sur la page 1sur 41

The LATEX document

preparation system

Dr Engelbert
Buxbaum

Introduction
The LATEX document preparation Structure of a LATEX
document
system Basic commands

Structuring text

Maths

Changing the layout


Dr Engelbert Buxbaum
Specialties

The departmental
Department of Biochemistry, RUSM handout

July 2008

1
The LATEX document
Name of the game preparation system

Dr Engelbert
Buxbaum

Introduction
Advantages and
disadvantages
Resources

TEX typesetting system developed by Donald Structure of a LATEX


document
E. Knuth (Stanford University) to create Basic commands

beautiful documents, especially those Structuring text

containing maths. TEX is free software with Maths

copyright vested in the American Changing the layout

Specialties
Mathematical Society.
The departmental
LATEX TEX-macroprocessor written by Leslie handout

Lamport, which implements a


markup-language. Users can concentrate
on the structure of their document rather
than on formatting.

2
The LATEX document
Typographic design preparation system

Dr Engelbert
Buxbaum

Introduction
Advantages and
disadvantages
Resources

Structure of a LATEX
document

Basic commands

Structuring text

Maths
É craft that needs to be learned
Changing the layout
É not about esthetics but about function: Books are Specialties
read, not displayed in a museum The departmental
handout

3
The LATEX document
Advantages preparation system

Dr Engelbert
Buxbaum
É Several professional styles are available that make
Introduction
documents look “like printed”. Changing style Advantages and

requires changing one single line in the document, disadvantages


Resources

consistency is ensured. Structure of a LATEX


document
É High quality math typesetting
Basic commands
É Only a few commands to define the structure of Structuring text
text, no knowledge of typography or book design Maths
required. Changing the layout
É Complex scientific documents can be created Specialties

automatically: The departmental


handout
É bibliography
É index
É crossreferences
É table of contents, lists of figures, tables etc.
É ...
É Operating-system independent
É Long-term storage of documents: ASCII rather than
binary
É Free software with source code available: Errors are
corrected rapidly
The LATEX document
Disadvantages preparation system

Dr Engelbert
Buxbaum

Introduction
Advantages and
disadvantages
Resources

Structure of a LATEX
document

Basic commands

Structuring text
É Learning curve
Maths
É Major changes in layout may require rewriting the Changing the layout

style file (blessing in disguise) Specialties

The departmental
É One gets an eye for all the bad documents out handout

there

5
The LATEX document
Resources preparation system

Dr Engelbert
Buxbaum

Introduction
Advantages and
disadvantages
Resources

Structure of a LATEX
document

Basic commands
Software CTAN, i.e. www.tug.org for the US Structuring text

Help Usenet: comp.text.tex Maths

Changing the layout


Introduction l2short available in various languages
Specialties
Literature The LATEX-companion (Mittelbach et al, The departmental
handout
2004)
Symbols Comprehensive symbol list from CTAN

6
The LATEX document
Boxes and glue preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document
classes

Basic commands

Structuring text

Maths
É Box (letter) + Glue (space) + Box + ... = larger Box
Changing the layout
(word) Specialties
É Words are treated as boxes to form lines, lines The departmental
handout
paragraphs and paragraphs pages
É Glue can shrink and expand within limits

7
The LATEX document
Structure of a LATEX-document preparation system

Dr Engelbert
Buxbaum

% -*- TeX:US -*- % for text-editor


Introduction

\NeedsTeXFormat{LaTeX2e} % for TeX-system


Structure of a LATEX
document
\documentclass[options]{style} classes

Basic commands

Structuring text
\usepackage[latin1]{inputenc}
Maths
\usepackage[T1]{fontenc} Changing the layout

Specialties
\author{} The departmental
handout
\title{}
\date{}

\begin{document}
\maketitle

\chapter{}
...
\end{document}

8
The LATEX document
Document classes preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document
LATEX Koma-Script purpose classes

Basic commands
article scrartcl journal papers, short re-
Structuring text
ports Maths
report scrreprt longer text with several Changing the layout
chapters, e.g. thesis Specialties

book scrbook books The departmental


handout
letter scrlettr letters
beamer slide presentations
sciposter conference posters
Apart from Koma-Script another alternative style
package is memoir. Also publisher-specific styles (e.g.
Springer, Elsevier, Teubner etc.

9
The LATEX document
Class options preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document
classes

Basic commands

Structuring text
Font size 10pt | 11pt | 12pt... Maths

Paper size a4paper | legalpaper... Changing the layout

Specialties
equations fleqn, leqno
The departmental
title titlepage | notitlepage handout

columns onecolumn | twocolumn


printing oneside | twoside

10
The LATEX document
Input characters preparation system

Dr Engelbert
Buxbaum

Some characters have special meaning in TEX, if you Introduction

Structure of a LATEX
need them they have to be entered as TEX-commands: document

Basic commands
Special characters
\ start command $\backslash$ Hypens & Cie

note: \\ = newline Structuring text

$ toggle math modus \$ Maths

Changing the layout


& tabulator \&
Specialties
% rest of line comment \% The departmental
# \# handout

~ \textasciitilde
| vert. lines in table \textbar
_ start subscript \_
^ start superscript \textasciicircum
{} command delimiter \{ \}
[] command delimiter $[ ]$
“” quotation marks ‘‘ ’’
>< tabbing $> <$
The LATEX document
Hypen, minus ... preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands
Special characters
Hypens & Cie
A horizontal line can mean a lot of things, depending
Structuring text
on length and thickness: Maths

Changing the layout

O-legs O-legs Specialties

10–18 o’clock 10--18 o’clock The departmental


handout
ja – oder nein? ja -- oder nein?
yes—or no? yes---or no?
0, 1 and –1 0, 1 and --1

12
The LATEX document
Sectioning commands preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

Structuring text
Sectioning
É \part{} Fonts
Lists
É \chapter{} Tables and stuff
Graphics

É \section{} Maths

Changing the layout


É \subsection{}
Specialties
É \subsubsection{} The departmental
handout
É \paragraph{}

13
The LATEX document
Breaking down large documents preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

Structuring text
Sectioning
Fonts
Use separate files for, say, each chapter. One main file Lists

with limbo and commands to include the others: Tables and stuff
Graphics

\input{} reads file “as is” Maths

Changing the layout


\include{} equiv. to \clearpage \input{} \clearpage Specialties

\includeonly{} used in limbo to limit files \included The departmental


handout

14
The LATEX document
What is where? preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

É \tableofcontents Structuring text


Sectioning

É \listoffigures Fonts
Lists
Tables and stuff
É \listoftables Graphics

É Maths

Changing the layout


É \bibliographystyle{plainnat} Specialties

É \bibliography{references} The departmental


handout
É

É \printindex

15
The LATEX document
Emphasizing preparation system

Dr Engelbert
Buxbaum

\textit{} italics, used for foreign words, species Introduction

Structure of a LATEX
names etc: Staph. aureus document

\textsl{} slanted Basic commands

Structuring text
\emph{} used for emphasizing: this is not the case Sectioning
Fonts

\textsc{} small caps, used for names of persons: Lists


Tables and stuff
Neil Armstrong was the first man on the Graphics

moon. Maths

Changing the layout


\textbf{} bold face: used to make something really Specialties
stick out. The departmental
handout
\textsf{} sans serif, often used as base font on
slides. Also used for chemical equations.
\texttt{} typewriter, used for computer related
material like code or URLs:
http://www.rossmed.edu.dm/
Note: Slides use sanserif font: No small caps, slanted
instead of italics!
16
The LATEX document
Font sizes preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document
\tiny microscopic font
Basic commands
\scriptsize very tiny font (subscripts)
Structuring text
\footnotesize tiny font (footnotes) Sectioning
Fonts
\small small font Lists

\normalsize normal font Tables and stuff


Graphics

\large large font Maths

\Large larger font Changing the layout

Specialties

\LARGE very large font The departmental


handout

\huge huge font


\Huge very huge font
Note: not a command: {\small foo bar}
The LATEX document
Simple lists preparation system

Dr Engelbert
Buxbaum
Please believe me:
Introduction
É Few swallows can turn winter into summer.
Structure of a LATEX
É Inside it’s colder than in the night. document

Basic commands
É In the morning it pulls.
Structuring text
É At noon he pushes. Sectioning
É In the evening she goes. Fonts
Lists
É Every nonsense must find an end. Tables and stuff
Graphics

Maths
Please believe me: Changing the layout
\begin{itemize} Specialties
\item{Few swallows can turn winter into summer.} The departmental
\item{Inside it’s colder than in the night. handout

\begin{itemize}
\item{In the morning it pulls.}
\item{At noon he pushes.}
\item{In the evening she goes.}
\end{itemize} }
\item{Every nonsense must find an end.}
\end{itemize}

18
The LATEX document
Descriptive lists preparation system

Dr Engelbert
Buxbaum

Three animals you should know about are:


Introduction
gnat: A small animal, found in the North Woods, Structure of a LATEX
document
that causes no end of trouble.
Basic commands
gnu: A large animal, found in crossword puzzles, Structuring text

that causes no end of trouble. Sectioning


Fonts
Lists
armadillo: A medium-sized animal, named after a Tables and stuff

medium-sized Texas city which causes no Graphics

Maths
end of trouble. Changing the layout

Specialties
\begin{description} The departmental
\item[gnat:]{A small animal, found in the North handout

Woods, that causes no end of trouble.}


\item[gnu:]{A large animal, found in crossword
puzzles, that causes no end of trouble.}
\item[armadillo:]{A medium-sized animal, named
after a medium-sized Texas city which causes
no end of trouble.}
\end{description}

19
The LATEX document
Enumerated lists preparation system

Dr Engelbert
Buxbaum

These are the main points: Introduction

Structure of a LATEX
1. first item document

2. second item Basic commands

Structuring text
3. third item Sectioning
Fonts
3.1 first sub-item Lists
Tables and stuff
3.2 second sub-item Graphics

Maths

These are the main points: Changing the layout

\begin{enumerate} Specialties

\item{first item} The departmental


handout
\item{second item}
\item{third item
\begin{enumerate}
\item{first sub-item}
\item{second sub-item}
\end{enumerate} }
\end{enumerate}

20
The LATEX document
Tabbing preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document
If it’s raining
Basic commands
then put on boots, Structuring text
take hat; Sectioning
Fonts
else smile. Lists

Leave house. Tables and stuff


Graphics

Maths

Changing the layout


\begin{tabbing} Specialties
If \= it’s raining \\ The departmental
\> then \= put on boots, \\ handout

\> \> take hat; \\


\> else \> smile. \\
Leave house.
\end{tabbing}
The LATEX document
Tabular preparation system

Dr Engelbert
Buxbaum

GG&A Hoofed Stock Introduction

Year Price Comments Structure of a LATEX


document
1971 97–245 Bad year for farmers in the west. Basic commands

72 245–245 Light trading due to a heavy winter. Structuring text


Sectioning
73 245–2001 No gnus was very good gnus this Fonts

year. Lists
Tables and stuff
Graphics

\begin{tabular}{|r||c|p{2.5in}|} Maths
\hline Changing the layout
\multicolumn{3}{|c|}{\sc GG\&A Hoofed Stock} \\
Specialties
\hline
\hline The departmental
handout
\multicolumn{1}{|c||}{\bf Year} & \bf Price & \multicolumn{1}{c|}{\bf Comments
\hline
1971 & 97--245 & Bad year for farmers in the west. \\
\hline
72 & 245--245 & Light trading due to a heavy winter. \\
\hline
73 & 245--2001 & No gnus was very good gnus this year. \\
\hline
\end{tabular}

22
The LATEX document
Table (a float: not used on slides) preparation system

Dr Engelbert
Buxbaum

Introduction
\begin{table} Structure of a LATEX
\caption{The fastest man in the world: document

Some of his possibilities} Basic commands

\label{tab:fast} Structuring text


Sectioning
\centering Fonts

\begin{tabular}{|l|c|r|} Lists
Tables and stuff
\hline Graphics

Disciplin & distance (m) & time (min) \\ Maths

\hline Changing the layout

Running & 100 & 5 \\ Specialties

Swimming & 50 & 30 \\ The departmental


handout
Cycling & 1000 & 20 \\
\hline
\end{tabular}
\end{table}

In the text the table can be referenced with: see table


\ref{tab:fast} on page \pageref{tab:fast}.
23
The LATEX document
Graphics preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

Structuring text
Sectioning
Fonts
Lists
Tables and stuff
Graphics

Maths

\includegraphics[height=0.3\textheight]{Graphics/Campus3} Changing the layout

Specialties

The departmental
handout

É Requires \usepackage{graphicx}
É Several file formats possible depending on
dvi-driver. For pdfLaTeX pdf, png, jpg.
É Convert other formats e.g. with IrfanView or Gimp.
É other optional arguments like width, angle, size

24
The LATEX document
Figures preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

Structuring text
Sectioning
\begin{figure}
Fonts
\caption{A view of our campus. } Lists
\label{fig:Campus} Tables and stuff
\centering Graphics

\includegraphics[height=0.3\textheight]{Graphics/Campus3} Maths
\end{figure}
Changing the layout

Specialties

Like table, figure is a floating environment that has no The departmental


handout
meaning in slides. Cross-referencing works as with
tables.

25
The LATEX document
Text maths preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

Structuring text

if a and b are legs of a right-angled triangle and c the Maths


Math environments
hypotenuse, then c2 = a2 + b2 (Theorem of Pythagoras). Basic math commands

Changing the layout

if $a$ and $b$ are legs of a right-angled triangle Specialties

and $c$ the hypotenuse, then $c^2=a^2+b^2$ (Theorem The departmental


handout
of Pythagoras).

26
The LATEX document
Display maths preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document
if a and b are legs of a right-angled triangle and c the Basic commands

hypotenuse, then Structuring text

c2 = a2 + b2 (1) Maths
Math environments
Basic math commands
(Theorem of Pythagoras). Changing the layout

Specialties
if $a$ and $b$ are legs of a right-angled triangle
The departmental
and $c$ the hypotenuse, then handout

\begin{equation}
c^2=a^2+b^2
\end{equation}
(Theorem of Pythagoras).

27
The LATEX document
Formulas preparation system

Dr Engelbert
Buxbaum
q p
x5
Introduction
x1 x2 + 3
y Structure of a LATEX
document

Basic commands
x^5 x_1 \sqrt{x^2+\sqrt[3]{y}} Structuring text

Maths
Math environments
Basic math commands
‚ Œ
1 n Changing the layout

Specialties
x2 +y2 +z2 n−k The departmental
x +y handout

\frac{1}{\frac{x^2+y^2+z^2}{x+y}} {n\choose {n-k}}

Z∞ n
X
x3 ai
i=1
−∞

\int \limits_{-\infty}^{\infty}x^3 \sum_{i=1}^{n}a_i


28
The LATEX document
Aligning equations preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

f (x) = cos x (2) Structuring text

0 Maths
f (x) = − sin x (3) Math environments
Basic math commands
Z x
Changing the layout
f (y)dy = sin x (4) Specialties
0
The departmental
handout

\begin{align}
f(x) & = \cos x \\
f’(x) & = -\sin x \\
\int_{0}^{x} f(y)dy & = \sin x
\end{align}

29
The LATEX document
Internal Counter + parameters preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
Change parameters: document

Basic commands

\setlength{\parindent}{0pt} Structuring text

\setlength{\parskip}{5pt plus 2pt minus 1pt} Maths

Changing the layout


\addtolength{\textwidth}{60pt} Counters and
parameters
Distances
Text position

Set counters: Specialties

The departmental
handout
\setcounter{page}{0}
\addtocounter{page}{10}

Output counter content: This is page 30.


This is page \thepage .

30
The LATEX document
Horizontal distance preparation system

Dr Engelbert
Buxbaum

Here we have 2 cm distance. Introduction

Structure of a LATEX
document
Here we have \hspace{2cm} \SI{2}{cm} distance. Basic commands

Structuring text

Maths

left right Changing the layout


Counters and
parameters

left\hfill right Distances


Text position

Specialties

The departmental
\, very small distance handout

\enspace as wide as a number


\quad as wide as a letter is heigh
\qquad twice as wide as \quad
\hfill a distance that can expand from 0
to ∞

31
The LATEX document
Vertical distance preparation system

Dr Engelbert
Buxbaum
Here
Introduction

Structure of a LATEX
document

Basic commands

Structuring text

Maths

is 2 cm distance. Changing the layout


Counters and

Here parameters
Distances
Text position

\vspace{2cm} Specialties

The departmental
handout

is \SI{2}{cm} distance.

\smallskip about 1/ 4 line


\medskip about 1/ 2 line
\bigskip about 1 line
\vfill distance that can expand from 0
to ∞

32
The LATEX document
Centering text preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
In document

the Basic commands

Structuring text
middle I don’t
Maths
feel
Changing the layout
so marginalized Counters and
parameters
Distances
Text position

\begin{center} Specialties

The departmental
In\\ handout

the\\
middle I don’t\\
feel\\
so marginalized\\
\end{center}

33
The LATEX document
Flushright text preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

Structuring text

Maths
This is not a political statement Changing the layout
Counters and
parameters
Distances

\begin{flushright} Text position

Specialties
This is not a political statement
The departmental
\end{flushright} handout

34
The LATEX document
Indexing commands preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

Structuring text

Maths
simple gnat\index{gnat}
Changing the layout
subtopics gnat\index{gnat!size of} Specialties
The index
page range \index{gnat|(}...\index{gnat|)} List of acronyms
Bibliography
reference \index{gnat|see{mosquito}} Slide presentations
TeX-ing

font gnat\index{gnat@\textit{gnat}} The departmental


handout
After first LATEX run, start makeindx to sort the index.

35
The LATEX document
Acronyms preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
Assume the following list of acronyms: document

Basic commands
\begin{acronym} Structuring text

\acro{nfkb}[NF-$\upkappa$B]{nuclear factor Maths

$\upkappa$B}, protein in gene regulation Changing the layout

\end{acronym} Specialties
The index
List of acronyms
Bibliography
Slide presentations

This will print as TeX-ing

NF-κB: nuclear factor κB, protein in gene regulation The departmental


handout
Then
\acf{nfkb} nuclear factor κB (NF-κB)
\acs{nfkb} NF-κB
\acl{nfkb} nuclear factor κB

36
The LATEX document
BibTeX preparation system

Dr Engelbert
Buxbaum
Database for literature references in ASCII-format. Can
be produced from many programs like EndNote, also Introduction

from PubMed etc. Structure of a LATEX


document

@article{Alb-76, Basic commands

AUTHOR= {W.J. Albery and J.R. Knowles}, Structuring text

Maths
TITLE= {Evolution of enzyme function and the
Changing the layout
development of catalytic efficiency},
Specialties
JOURNAL= {Biochemistry}, The index

VOLUME= {15}, List of acronyms


Bibliography
YEAR= {1976}, Slide presentations

PAGES= {5631-5640}, TeX-ing

The departmental
ABSTRACT= {Catalytic efficiency constant kcat/Km handout
defined },
DOI= {10.1021/bi00670a032},
LANGUAGE= {engl}
}

Similar for books, chapters, reports, thesis etc. In the


text use \cite{Alb-76}. After first LATEX-run start bibtex
to create the bibliography.
37
The LATEX document
Beamer-slides preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

Structuring text

Maths

Changing the layout


\begin{frame} Specialties
\frametitle{} The index
List of acronyms
... Bibliography
Slide presentations
\end{frame} TeX-ing

The departmental
handout

38
The LATEX document
TEXing preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands
Always use the sequence: Structuring text

LATEX produces the necessary intermediate files Maths

Changing the layout


makeindx sort the index Specialties

bibtex create the bibliography The index


List of acronyms
Bibliography
LATEX include bibliography and index, resolve Slide presentations

cross-references TeX-ing

The departmental
LATEX resolve remaining cross-references handout

Note: using pdfLATEX instead of LATEX produces pdf-files


directly.

39
The LATEX document
Packets used in dept. handout preparation system

Dr Engelbert
Buxbaum
makeidx index generation
Introduction
natbib clean handling of bibliography
Structure of a LATEX
siunitx \SI{}{}, \num{}, \ang{} document

acronym administration of acronyms Basic commands

isotope \isotope[13]{C} = 13 C Structuring text

Maths
graphicx inclusion of diagrams
Changing the layout
color colored text Specialties
amsmath math fonts and characters The departmental
eufrak font for arrays + vectors handout

textcomp special characters


wasysym,marvosym, special symbols like ♂, ♀
chemarrow various types of arrows for equa-
tions
upgreek $\upalpha$ = α instead of α
thumb chapter thumbs
isodate standard conform typesetting of
dates
hyperref use of cross-referencing facilities
of pdf
40
The LATEX document
Getting consistent output preparation system

Dr Engelbert
Buxbaum

Introduction

Structure of a LATEX
document

Basic commands

É \chemical{CH_2\double CH\single OH} = Structuring text

CH2 =CH−OH Maths

Changing the layout


É \ph = pH, similar for \pkw, \pka, \poh, \pI Specialties
É \Name{Maude Leonora Menten} = Maude Leonora The departmental
handout
Menten
É \skalar{x} = x, similar for \array, \vektor, \set.
Note the list of variables used in the appendix.
É \SI{1}{cm} = 1 cm, \num{10000} = 10 000,
\ang{1;2;3} = 1°20 300 .

Vous aimerez peut-être aussi