Sie sind auf Seite 1von 34

A Introduction to L T EX: A Document Preparation System

A Produced with L T EX by G Baker and G Moloney

Presented by Gavin Baker The University of Melbourne

p. 1

Overview
This course will cover: A How L T EX works Document classes and styles Chapters, sections, TOC, etc Title pages Lists: enumerated and bulleted Basic tables Exercises A Running L T EX And more...
p. 2

A L TEX in Action
A L T EX can produce sophisticated documents Lets look at a demonstration document...

p. 3

A What is L TEX?
A L T EX is very good at: Mathematics Long documents (books and theses) Complex typesetting Tables and Graphics Separating content from stylistic considerations Managing bibliographies and internal cross-references A T L EX is not a WYSIWYG word processor!

p. 4

LaTeX Philosophy
Describe the logical structure as text Focus on the content and structure Logical design encourages better writing Document design is for readability, not aesthetics Use text markup to describe content Styles determine appearance change in one place Leave formatting and layout to the stylesheet Avoid typographical errors
p. 5

The Simplest Example


A L T EX les are simple text les, that can be edited with any text editor Special commands are embedded in the text to describe the formatting

\documentclass{article} \begin{document} It was a dark and stormy night. The wind howled through the trees, and blew cold and lonely down the empty streets of the city. \end{document}

p. 6

Anatomy of a LaTeX Document


All documents have a preamble... ...followed by a body The preamble declares: document class other used packages more... The body is the actual content

p. 7

Document Class
\documentclass[options]{class}
First command of any document - required Place at start of preamble Declares what sort of document we wish to create Determines the look or style of the document There are many useful predened classes, including: report, article, letter, book . . . Options may be specied, such as a4paper

\documentclass[a4paper,twocolumn]{report}

p. 8

Installing the TEX Live! CD


Insert the CD, and wait for the TEX Live! window From the menu, select: Install -> Editors -> WinShell Select Yes then answer Next to all the prompts At the Finish window, deselect the option to run WinShell at end of install From the T EX Live menu, select: Explore -> Select Text Editor Browse to: C:\Program Files\WinShell\WinShell.exe Now the installation is complete To run T EX Live!: Explore -> Run from CD
p. 9

A The L TEX Processor


A The L T EX processor reads your .tex le... ...and produces a Device Independent le (.dvi) The dvi le can be viewed online, printed, converted...

How to process your document: A Press the L T EX button on your TeX Live! toolbar If there are no errors :-): Press the DVI button on your TeX Live! toolbar
p. 10

A The L TEX Processor 2

Preview

PostScript

tex LaTeX processor

dvi

HTML

Acrobat PDF

others...

p. 11

First Exercise
Exercise1:: Type in this le. . .
\documentclass{article} \begin{document} It was a dark and stormy night. The wind howled through the trees, and blew cold and lonely down the empty streets of the city. \end{document}
A . . . and then process it with L T EX

p. 12

Running Text
Most documents consist almost entirely of running text Running text consists of words, sentences, paragraphs Paragraphs separated by one or more blank lines Words are separated by one or more spaces Extra spaces are ignored Formatted according to document class (eg. margins, indentation, etc.)
p. 13

A L TEX Commands
A In L T EX, formatting is done with commands: A L T EX commands always start with a backslash \

I love \LaTeX{}. There were \textbf{many} solutions. \chapter{Methodology}

Commands may have: Options in square brackets: [ ] Arguments in curly braces: { } Command names are case-sensitive

p. 14

Special Characters
A L T EX gives special meaning to some characters:

\ : backslash, begin a command { } : braces, arguments to a command % : percent, begin a comment # : hash, macro parameters $ : dollar, begin/end math mode & : ampersand, separate columns in tables
You should not use these symbols in regular text without escaping them with a backslash, such as \$.

p. 15

Comments
Comments begin with a percent sign (%) and continue to the end of the line. A Comments are ignored by the L T EX processor Useful for notes, reminders, editorial markup, copyright notices, etc
% NB : check the grammar of this paragraph ! Wear did eye go, they said -- for I did get hit right on my ed.

p. 16

Dashes
A L T EX has support for several types of dashes; hyphenation, numerical ranges and sentence breaks:

quasi-surreal See pages 2342 Alas they vanished!

quasi-surreal \\ See pages 23--42 \\ Alas --- they vanished!

p. 17

Quotes
A L T EX has support for proper quotes, both single and double.

An easy task Youre joking! he cried.

An easy task \\ Youre joking! he cried.

p. 18

Title Page
Call the \maketitle command to generate Declare the title, author and date Title styles depend on the document class
\documentclass{book} \title{The Long Dark Winter} \author{Wilbur Hogglefarm} \date{14 July 1684} \begin{document} \maketitle \chapter{Summer closes} As the last rays of summer cast their long tendrils of warmth across the land...

p. 19

Document Structure
A L T EX is especially good for structured documents. \chapter \section \subsection \subsubsection ...

\section{Maintenance} This section describes the maintenace procedures for your vehicle. \subsection{Lubrication} The oil should be topped up on a regular basis...
p. 20

Table of Contents
Use the \tableofcontents command Any sectioning commands will be included Document class determines TOC style A This requires running the L T EX processor twice Why? To resolve forward page references...

p. 21

Environments
Frequently need to typeset blocks of text Quotations, lists, foreign languages, theorems etc All environments have the form:
\begin[options]{environment} content... \end{environment}

p. 22

Quotation

Nelson Mandela, in his inaugural speech, said: \begin{quote} Our worst fear is not that we are inadequate. Our is that we are powerful beyond measure.

It is our Light, not our darkness that most frigh ourselves, Who am I to be brilliant, gorgeous, fabulous? Actually, who are you not to be. \end{quote}
Nelson Mandela, in his inaugural speech, said: Our worst fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure. It is our Light, not our darkness that most frightens us. We ask ourselves, Who am I to be brilliant, gorgeous, talented and fabulous? Actually, who are you not to be.

p. 23

Center
On the cover of the book, in large friendly letters, read: \begin{center} Dont Panic! \end{center} Ford was most perplexed by this. He decided to panic anyway.
On the cover of the book, in large friendly letters, read: Dont Panic! Ford was most perplexed by this. He decided to panic anyway.

p. 24

Lists
Several types of lists are available: itemize: bulleted lists enumerate: numbered lists Lists can be nested, to produce a hierarchy They are bracketed with \begin{} and \end{} commands Each point is introduced with the \item command

p. 25

Lists Example
\begin{enumerate} \item Itemized lists are very useful \item But dont forget that: \begin{itemize} \item Enumerated lists are handy \item Lists can be nested too \end{itemize} \item Lists are easy to create \end{enumerate}
1. Itemized lists are very useful 2. But dont forget that: Enumerated lists are handy Lists can be nested too 3. Lists are easy to create
p. 26

Symbols
A massive library of symbols is available Over 2,500 are documented in the symbol reference Simply put the appropriate \usepackage in the preamble... ...then insert the symbol by name (eg. \suitclubs) where you need it

c $ ... A

p. 27

Font Styles
We can use \textbf{bold text}, or we can use \textit{italicised text} for extra emphasis. For special terms, there is \textsc{Small Capitals}. An alternative to italic emphasis is the \textsl{slanted text}.
We can use bold text, or we can use italicised text for extra emphasis. For special terms, there is Small Capitals. An alternative to italic emphasis is the slanted text.

p. 28

Font Sizes
tiny

small

normalsize

large

Large

LARGE Huge

{\tiny tiny} \\ {\small small} \\ {\normalsize normalsize} \\ {\large large} \\ {\Large Large} \\ {\LARGE LARGE} \\ {\Huge Huge}

p. 29

Font Faces
The three basic font families are the \textrm{roman family}, \textsf{sans serif}, and \texttt{typewriter}. Many more fonts are available, as we will see in the next course.
The three basic font families are the roman family, sans serif, and typewriter. Many more fonts are available, as we will see in the next course.

p. 30

Simple Mathematics
$360^\circ$ is equivalent to $2\pi$ radians 360 is equivalent to 2 radians \begin{eqnarray} x^2 + y^2 = 1 \\ f(x) = \sum_{i=0}^{\infty}\frac{f^{(i)}(x)}{i!} \end{eqnarray}
(1) (2)

x2 + y 2 = 1 f (i) (x) f (x) = i! i=0


p. 31

Simple LOTE
A L T EX has support for many languages. For example:

\textbf{French}: Jai trouv\{e} lH\^{o}tel de Ville; plus \c{c}a change! \\ \textbf{German:} Die Stra{\ss}e war besch\"aftigt, also ich w\"ohlte einige Blumen aus. \\ \textbf{Esperanto:} Mi \^san\^gis la musiko, kar \^gi ne estis bona.
French: Jai trouv e lH otel de Ville; plus c a change! German: Die Strae war besch aftigt, also ich w ohlte einige Blumen aus. Esperanto: Mi san gis la musiko, kar gi ne estis bona.
p. 32

Tables
\begin{tabular}{|r|l|c|}\hline First Name & Surname & House \\ \hline Harry & Potter & Gryffindor Draco & Malfoy & Slytherin Colin & Creevey & Hufflepuff \hline \end{tabular}
First Name Harry Draco Colin Surname Potter Malfoy Creevey House Gryndor Slytherin Huepu

\\ \\ \\

p. 33

Moving on. . .
You can learn more about LaTeX from: A L T EX A Document Preparation System, Leslie Lamport A The intermediate L T EX session: Bibliographics, Mathematics, Tables, Cross-references, . . . Online support newsgroup: comp.text.tex A Happy L T EXing!

p. 34

Das könnte Ihnen auch gefallen