Introduction to LaTeX

17 downloads 39939 Views 1MB Size Report
Feb 9, 2012 ... Preface Examples Alternatives Gains and Losses. Introduction to LATEX ... General structure Language elements Behind the scene. Outline.
Preface Examples Alternatives Gains and Losses

Introduction to LATEX Petrik Galvosas MacDiarmid Institute for Advanced Materials and Nanotechnology, SCPS, Victoria University of Wellington, New Zealand

Postgraduate Summer Workshop, 9th February 2012

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

Outline 1

2

3

4

Preface Some History What you need Before you start Examples General structure Language elements Behind the scene Alternatives LATEXbased Others Gains and Losses

Thanks to Matthias Meyer John Ryan

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

Some History What you need Before you start

TEX vs. LATEX TEX First release in 1978 by Donald E. Knuth Typesetting system Programming language Requires expert knowledge LATEX First release in 1985 by Leslie Lamport Set of macros on top of TEX Document classes and expandable style options Expert knowledge is compiled in

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

Some History What you need Before you start

Basic philosophy and workflow

LATEX source

latex file.tex

dvips file.dvi DVI File

Postscript

Separate drafting text from typesetting (that usually does not work) Do not be bothered by typesetting at all! (does not work either)

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

Some History What you need Before you start

Bits and pieces you need

Bare essentials Editor TEX binaries, LATEX macros and style files Viewers (for DVI, PS, PDF) Perhaps useful TEXdistribution, including LATEX Integrated environment (editor supporting macro skeletons, LATEX calls, viewer calls)

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

Some History What you need Before you start

Desktop environment

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

Some History What you need Before you start

WYGIWYW (What you get is what you want)

Consider your needs What operating system do I have What are my tasks What is my working style Chose the solution Command line vs. GUI based Right editor Necessary packages and add-ons

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Outline 1

Preface Some History What you need Before you start

2

Examples General structure Language elements Behind the scene

3

Alternatives LATEXbased Others

4

Gains and Losses Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Document classes

Standard classes book

Provided or “user” defined classes elsart.cls

article

powerdot.cls

report

beamer.cls

letter

vuwthesis.cls

proc

and more, more, more...

slides

my own.cls

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Working Example Source code

Result

\ documentclass [ f i n a l ] { a r t i c l e }

\ begin {document}

\end{document} Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Working Example Source code

Result

\ documentclass [ f i n a l ] { a r t i c l e } Some text for fun

\ begin {document}

Some t e x t f o r f u n

\end{document} Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Working Example Source code

Result

\ documentclass [ f i n a l ] { a r t i c l e }

1

Cool things to do

Some text for fun

\ begin {document} \ s e c t i o n { Cool t h i n g s t o do } Some t e x t f o r f u n

\end{document} Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Working Example Source code

Result

\ documentclass [ f i n a l ] { a r t i c l e }

1

Cool things to do

Some text for fun Figure 1: A sample

\ begin {document} \ s e c t i o n { Cool t h i n g s t o do } Some t e x t f o r f u n \ begin { f i g u r e } [ ht b ] \ centering \ c a p t i o n {A s a m p l e } \end{ f i g u r e } \end{document} Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Working Example Source code

Result

\ documentclass [ f i n a l ] { a r t i c l e } \ usepackage { g r a p h i c x }

1

Cool things to do

Some text for fun

\ begin {document} \ s e c t i o n { Cool t h i n g s t o do } Some t e x t f o r f u n

Figure 1: A sample

\ begin { f i g u r e } [ ht b ] \ centering \ includegraphics{ capsule } \ c a p t i o n {A s a m p l e } \end{ f i g u r e } \end{document} Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Environments vs. macros Environments

Macros aka commands

\ begin { something}

\command{ a rgument }

Body o f e n v i r o n m e n t

argument can be optional \ date

\end{ something}

argument can be content

Can be nested Used for

\ textbf { bold t ex t }

lists minipages tables and figures ...

or several arguments \ t e x t c o l o r { c o l o r }{ t e x t } Make your own...

Make your own... Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Document structure

Front-, main- and backmatter Document class “book” Provides main document skeleton \frontmatter

Sections Structure of the text body \part{} \chapter{} \section{}

Title page TOC, TOF,...

\subsection{}

\mainmatter

\subsubsection{}

\backmatter

\paragraph{}

References Index

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Packages (aka style files) Frequently used packages \usepackage{amsmath} ⇒ Enhanced math-mode \usepackage{graphicx} ⇒ Includes graphic files (e.g. EPS) Special packages \usepackage{mhchem} ⇒ Write chemical formula \usepackage{SIunits} ⇒ Support for SI units \usepackage{listings} ⇒ Pretty print of source code Bottom line Need a special feature? I guess your problem is already solved. Make your own package if there is really nothing out there. Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

Example for macro definitions Source code \ usepackage { P i c L i b } \ begin { p i c t u r e }(700 ,240)( −60 , −120) \ Achse {0 ,0}{1 ,0}{700}{0 , − 10}{$ t $} \ Achse {0 , − 120}{0 ,1}{240}{0 ,0}{$G z $} \PFGGrad {130 ,0}{ Pos }{60}{100}{ 9 }{ 0 ,0}{$ g $} \PFGGrad {430 ,0}{ Neg }{60}{100}{6}{0 ,0}{$ − g $} \end{ p i c t u r e } Gz



g ✲

t −g Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

How TEX does things

Everything is arranged in boxes. “Badness” is the magic word, distribution of “ink” the measure. Objects float! Labels and references. Characters fuse to ligatures: fish vs. fish

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

How TEX changes things (beamer.cls ⇒ article.cls) Outline

Contents 1 Preface 1.1 Some History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 What you need . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Before you start . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 1 1 2

2 Examples 2.1 General structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Language elements . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Behind the scene . . . . . . . . . . . . . . . . . . . . . . . . . . .

2 2 8 11

3 Alternatives 11 3.1 LATEXbased . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.2 Others . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4 Gains and Losses

1 1.1

13

Preface Some HistoryPetrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

General structure Language elements Behind the scene

How I do things

Software “TeX Live”

Workflow and project structure latex ⇒ dvips ⇒ ps2pdf

Emacs with AUCTeX

One project, one directory

Xdvik, GV

Recycle, reuse ⇒ use symbolic links

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

LATEXbased Others

Outline 1

Preface Some History What you need Before you start

2

Examples General structure Language elements Behind the scene

3

Alternatives LATEXbased Others

4

Gains and Losses Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

LATEXbased Others

TeXnicCenter (GUI based source editor for Windows)

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

LATEXbased Others

Preview-Latex (Hybrid between source and WYSIWYG ed.)

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

LATEXbased Others

LyX (WYSIWYG )

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

LATEXbased Others

Libreoffice, Openoffice, MS Word & co.

WYSIWYG “Text processors” with all bells and whistles Consider price, performance and convenience Fair choice if used correctly!

Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

Outline 1

Preface Some History What you need Before you start

2

Examples General structure Language elements Behind the scene

3

Alternatives LATEXbased Others

4

Gains and Losses Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

MS Word (& co.) ”I finished writing, I only need to do the formatting...” Problems Layout depends on printer driver Becomes sluggish when producing big projects No column balance Floating objects are possible but cumbersome Can’t handle ligatures (only in Word 2010) Never, ever... format elements directly type in table, figure, heading numbers directly use empty paragraphs for spaces between paragraphs Petrik Galvosas

Introduction to LATEX

Preface Examples Alternatives Gains and Losses

LATEX Advantages LaTeX forces you to structure the document. Make presentations, articles, posters from the same source. No binary format. Source is human readable. Flexible. Build your own environment. Problems LaTeX forces you to structure the document. Flexible. Build your own environment. Some learning curve. Never, ever... try to force the layout to look the way you like it. Petrik Galvosas

Introduction to LATEX