Short introduction to L A T EX Christensen A tour of features with - - PowerPoint PPT Presentation

short introduction to l a t ex
SMART_READER_LITE
LIVE PREVIEW

Short introduction to L A T EX Christensen A tour of features with - - PowerPoint PPT Presentation

Short introduction to L T EX A A. D. Short introduction to L A T EX Christensen A tour of features with many examples Outline Introduction Differences to WYSIWYG editors Anders Damsgaard Christensen Required software Writing with


slide-1
SLIDE 1

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Short introduction to L

AT

EX

A tour of features with many examples Anders Damsgaard Christensen anders.damsgaard@geo.au.dk April 28, 2010

slide-2
SLIDE 2

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Outline

1 Introduction

Differences to WYSIWYG editors Required software

2 Writing with L

AT

EX Document structure Formatting

3 Useful packages 4 Bibliography management 5 External resources

slide-3
SLIDE 3

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Introduction

T EX is a low-level markup and programming language, created to typeset documents attractively and consistently L

AT

EX is a package based on T EX, its purpose is to simplify TeX typesetting Today widely used for publications

slide-4
SLIDE 4

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Differences to WYSIWYG editors

You can’t see the final result straight away. Everything is controlled with written commands. The document is written in a self-chosen text editor and saved in a .tex-file. L

AT

EX converts .tex-file into a .pdf-file. Advantages: The layout, fonts, tables etc. are consistent throughout. Mathematical formulae can be easily typeset. Indexes, footnotes and references are generated easily.

slide-5
SLIDE 5

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Software examples

Requirements:

1 Text Editor 2 L AT

EX-binaries

3 Output viewer for DVI/PDF files

Windows:

1 (Notepad), TeXnicCenter 2 MiKTeX 3 Sumatra PDF

OS X:

1 TeXShop 2 MacTeX or TeX-live

Linux:

1 Emacsen, gvim, Texmaker, Kile 2 TeX-live

slide-6
SLIDE 6

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

The document environment

The structure of a .tex-file:

\ documentclass [11 pt , a4paper , oneside ]{ report} % Preamble : A c t i v a t i o n

  • f

e x t r a packages , etc . % Top matter : T i t l e , author , etc . \begin{document} . . . % Document t e x t . . . \end{document}

slide-7
SLIDE 7

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Page layout

The document class command:

\ documentclass [ options ]{ class}

Example:

\ documentclass [11 pt , a4paper , oneside ]{ report}

  • r

. . . [ a4paper , twoside , twocolumns ]{ article}

Some document classes: article, report, letter, beamer, book

slide-8
SLIDE 8

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Title

Title (inserted right after \begin{document}):

\title{A LaTeX Document} \author{Anders Damsgaard Christensen \\ Aarhus University } \date {\ today} \maketitle

A LaTeX Document

Anders Damsgaard Christensen Aarhus University April 25, 2010

Figure: Example of title

slide-9
SLIDE 9

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Sections and hierarchy

Sectioning commands:

\part{title} \chapter{title} % Only used i n books and r e p o r t s \section{title} \ subsection {title} \ subsubsection {title} \paragraph{title} \ subparagraph {title}

slide-10
SLIDE 10

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Table of contents

Table of contents1:

\ tableofcontents \ listoffigures \ listoftables

Contents

1 About the course 3 2 Framework of climate science 4 2.1 Climate systems – forcing and response . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.1.1 Feedbacks in the climate system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.2 Climage archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.2.1 Dating climate records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.3 Climatic data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.3.1 Biotic data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.3.2 Geological and geochemical data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 Atmospheric circulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3 Tectonic-scale climate change 8 3.1 Carbon dioxide and long-term climate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.1.1 The greenhouse effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.1.2 Faint young Sun paradox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.1.3 Carbon exchange between rocks and the atmosphere . . . . . . . . . . . . . . . . . 8 3.1.4 The Gaia hypothesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1.5 Snowball Earth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.2 Plate tectonics and long-term climate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1Two compilations required

slide-11
SLIDE 11

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Formatting

Paragraph spacing & -indenting

Document text placed between \begin{document} and \end{document} Line break: \\ (2×backslashes) Paragraph separation: Two breakspaces (2×enter) Line of comment: Begins with % Indent of first line vs. vertical paragraph spacing Modified in the preamble: \setlength{\parskip}{1cm plus4mm minus3mm} \setlength{\parindent}{0mm}

slide-12
SLIDE 12

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Formatting

Text styles and -size

\emph{...} I want to emphasize \textbf{...} Bold \texttt{...} Fixed width teletypefont \textsc{...} Small Capitals \tiny{...}

sample text

\scriptsize{...}

sample text

\footnotesize{...}

sample text

\small{...}

sample text

\normalsize{...} sample text \large{...}

sample text

\Large{...}

sample text

\LARGE{...}

sample text

\huge{...}

sample text

\Huge{...}

sample text

slide-13
SLIDE 13

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Footnotes

Footnotes are added to the text via the \footnote{...} command. Inserting a footnote:

Bla bla bla\ f o o t n o t e {Footnote text} bla blaaa\ f o o t n o t e {Second footnote}

Footnote example Bla bla blaa bla blaaab

aFootnote text bSecond footnote

Margin text is added to the text via the \marginpar{...} command.

slide-14
SLIDE 14

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Mathematics

$ math $: Math in text paragraph \[ math \]: Math centered, separated from text \begin{equation} math \end{equation}: Math centered, separated from text and labelled Math typesetting example:

This example defines $a 1$ as the ratio $\ frac {2 \ cdot b}{c}$ minus $\ beta $: \[ a 1 = \frac {2 \ cdot b}{c} − \ beta \]

This example defines a1 as the ratio 2·b

c

minus β: a1 = 2 · b c − β

slide-15
SLIDE 15

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Mathematics – continued

More math typesetting examples: ⇒ δ2φ δx2 ∀x ∈ X lim

x→∞ exp(x) 10

  • i=1

ti ∞ e−x dx Am,n =      a1,1 a1,2 · · · a1,n a2,1 a2,2 · · · a2,n . . . . . . ... . . . am,1 am,2 · · · am,n      http://en.wikibooks.org/wiki/LaTeX/Mathematics

slide-16
SLIDE 16

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Floats

Free, floating objects; position is only partly defined by the user (here, bottom, top, p: separate page) Automatically numbered, label used for referencing Captions can be added Float syntax:

\begin{figure

  • r table }[ placement

specifier ] . . . figure contents . . . \end{figure

  • r table}
slide-17
SLIDE 17

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Floats: Tables

Table code example:

\begin{table }[ htpb ] \begin{tabular }{l c} % Two columns Product & C o s t \\ \hline % A h o r i z o n t a l l i n e Egg & 4 kr \\ Tomato & 2 kr \\ \hline \end{tabular} \caption{Products for sale} \label{tab : productlist } \end{table}

slide-18
SLIDE 18

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Floats: Tables

The result: Product Cost Egg 4 kr Tomato 2 kr

Table: Products for sale

slide-19
SLIDE 19

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Floats: Figures

Supported image file types: JPG, PNG and PDF Figure code example:

Have a look at figure \ref{ samplepicture }: \begin{figure }[ htbp ] \begin{center} \ includegraphics [ width =0.5\ textwidth ]{ file} % 50% of the l i n e width \caption{Sample picture} \label{ samplepicture } \end{center} \end{figure}

slide-20
SLIDE 20

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Document structure

Floats: Figures

Figure example Have a look at figure 2:

Figure: 2 Sample picture

slide-21
SLIDE 21

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Useful packages

Packages: Extensions of L

AT

EX, added in the preamble with \usepackage{...} Name Usage Example mhchem \ce{(NH4)2SO4} (NH4)2SO4 hyperref \url{a@dc.dk} a@dc.dk graphicx Needed for images amsmath Advanced math t1enc Danish symbols (æø˚ a) [danish]{babel} E.g. danish autotext a4wide Narrower margins geometry Custom margins All packages are distributed with documentation on usage.

slide-22
SLIDE 22

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Bibliography management

BibTeX

Storage of all references in an external database (.bib) Linkage to database possible from several .tex-files Citation style flexible Reference management software as helpful tools Sample entry in .bib-file:

@article{Bennett :2003 , % C i t e key Author = {Bennett , M . R . } , Journal = {Earth−Science Reviews } , Number = {3−4}, Pages = {309−−339}, Publisher = {Elsevier } , Title = {Ice streams as the arteries

  • f an ice ←

֓ sheet : their mechanics , stability and ← ֓ significance } , Volume = {61} , Year = {2003}}

slide-23
SLIDE 23

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Bibliography management

BibTeX – continued

Inclusion of .bib-file into .tex-file:

\ bibliographystyle {plain} \ bibliography {database} % I . e . : ./ database . bib

Citation done with the command: \cite{key} Reference list is automatically generated from cited entries and included into the output PDF. When referring to a new reference in the bib-file:

1 Compile tex-file with LaTeX 2 Compile bib-file with BibTeX 3 Compile tex-file with LaTeX

slide-24
SLIDE 24

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Bibliography management

BibTeX – continued

Example: Litteratur

Baird, C., Cann, M., 2005. Environmental chemistry. WH Freeman. Fairbridge, R., 1967. Phases of diagenesis and authigenesis. Diagenesis in sediments , 19–89. Galloway, W., 1984. Hydrogeologic regimes of sandstone diagenesis. Clastic diagenesis: AAPG Memoir 37, 3–13. Gill, R., 1996. Chemical Fundamentals of Geology. Chapman & Hall. 2. udgave. Hendry, J., Trewin, N., 1995. Authigenic quartz microfabrics in cretaceous turbidites: evidence for silica transformation processes in sandstones. Journal of Sedimentary Research-Section A-Sedimentary Petrology and Processes 65, 380–392.

Custom bibliography style sheet used for natural sciences- standard referencing (e.g. Bennett et al. 2003):

http://cs.au.dk/~adc/files/adc1-en.bst http://cs.au.dk/~adc/files/adc1-da.bst

slide-25
SLIDE 25

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

External resources for further learning

Internet: Wikibook: http://en.wikibooks.org/wiki/LaTeX IMF: http://www.imf.au.dk/system/latex/ L

AT

EX-bog, Lars Madsen: http://www.imf.au.dk/system/latex/bog/ Official page: http://www.latex-project.org/ L

AT

EX Cheat Sheet: http://www.stdout.org/~winston/latex/

slide-26
SLIDE 26

Short introduction to L

A

T EX

  • A. D.

Christensen Outline Introduction

Differences to WYSIWYG editors Required software

Writing with L

A

T EX

Document structure Formatting

Useful packages Bibliography management External resources Conclusions

Conclusions

Learning L

AT

EX is done by doing Use external resources for command- & syntax help Use document templates in the beginning Compile the PDF frequently: Helps error debugging in the code Let the floats (tables, figures) position themselves Create a dedicated directory for each project

This slideshow can be downloaded from: http://cs.au.dk/~adc/files/LaTeX-Presentation.pdf