How to get started in L A T EX Florence Bouvet 2 Introduction L - - PowerPoint PPT Presentation

how to get started in l a t ex
SMART_READER_LITE
LIVE PREVIEW

How to get started in L A T EX Florence Bouvet 2 Introduction L - - PowerPoint PPT Presentation

1 How to get started in L A T EX Florence Bouvet 2 Introduction L A T EX is a document preparation system for high-quality typesetting. L A T EX is not a word processor! Instead, L A T EX encourages authors not to worry too much about


slide-1
SLIDE 1

1

How to get started in L

AT

EX

Florence Bouvet

slide-2
SLIDE 2

2

Introduction

L

AT

EX is a document preparation system for high-quality typesetting. L

AT

EX is not a word processor! Instead, L

AT

EX encourages authors not to worry too much about the appearance of their documents, but to concentrate on getting the right content.

slide-3
SLIDE 3

3

Disadvantages

◮ One can’t see the final result straight away. ◮ One needs to know the necessary commands for LaTeX

markup.

◮ It can sometimes be difficult to obtain a certain ’look’.

slide-4
SLIDE 4

4

Advantages

On the other hand, there are certain advantages to the markup language approach:

◮ The document looks professional. The layout, fonts, tables,

  • etc. is consistent throughout.

◮ Mathematical formulae can be easily typeset. ◮ Indexes, footnotes, references, etc., are generated easily. ◮ It encourages correctly structured documents. ◮ It is available (and transportable) across many platforms

(Windows, Mac, Unix and Linux are all supported).

slide-5
SLIDE 5

5

◮ Typesetting journal articles, technical reports, books, and slide

presentations.

◮ Control over large documents containing sectioning,

cross-references, tables and figures.

◮ Typesetting of complex mathematical formulae. ◮ Advanced typesetting of mathematics with AMS-L AT

EX.

◮ Automatic generation of bibliographies and indexes. ◮ Multi-lingual typesetting. ◮ Inclusion of artwork, and process or spot color. ◮ Using PostScript or Metafont fonts.

slide-6
SLIDE 6

6

Some very Basics

What you need to get started:

◮ MikTex (http://www.miktex.org/) ◮ an Editor, such as WinEdt. (http://www.winedt.com/)

slide-7
SLIDE 7

7

Document Structure

Latex practically forces you to declare structure within your

  • documents. Let’s take the example of the structure of an article.

Preamble This is everything from the start of the Latex file to the \begin{document} command. It contains commands and packages that affect the entire document. Here is for example what I wrote to start this introduction to L

AT

EX.

\documentclass[12pt, letterpaper]{article} \setlength{\topmargin}{-0.8in} \setlength{\textwidth}{6.6in} \usepackage{hyperref} \usepackage{indentfirst} \renewcommand{\baselinestretch}{1.24}

slide-8
SLIDE 8

8 The class is given by the \documentclass{...} command. Valid LaTeX document classes include:

◮ article ◮ report ◮ letter ◮ book ◮ slides

Top Matter At the beginning of most documents will be information about the document itself, such as the title and date, and also information about the authors, such as name, address, email etc. \title {How to get started in L

AT

EX} \author {Florence Bouvet, based on http://en.wikibooks.org/wiki/L

AT

EX} \date{today } \maketitle

slide-9
SLIDE 9

9 Abstract Here is what the command looks like: \begin {abstract} blablabla..... \end {abstract }

slide-10
SLIDE 10

10 Main body and Sectioning Commands The commands for inserting sections are quite intuitive. Command Level \part{a title without number}

  • 1

\chapter{a title without number} \section{a title without number} 1 \subsection{a title without number} 2 \subsubsection{a title without number} 3 \paragraph{a title without number} 4 \subparagraph{a title without number} 5 Numbering will be done automatically. L

AT

EX has a command that makes it easy to manage references (for sections, tables, figures). To allow cross-referencing, you should assign a “key” to the element you want to refer to and then use that key to refer to that element.

slide-11
SLIDE 11

11 For example, at the end of the introduction:

\section{Literature Review} \label{Litreview} Then in the introduction you would write: “Section \ref{Litreview} summarizes the recent literature on European integration....”

slide-12
SLIDE 12

12 Bibliography Bibtex allows you to store all your references in an external, flat-file database. A Bibtex database is stored as a .bib

  • file. The structure of the file is also quite simple. An example of a

Bibtex entry:

@article{greenwade93, author = ”George D. Greenwade”, title = ”The Comprehensive Tex Archive Network (CTAN)”, year = ”1993”, journal = ”TUGBoat”, volume = ”14”, number = ”3”, pages = ”342–351” }

slide-13
SLIDE 13

13 If there are several authors: @book{goossens93, author = ”Michel Goossens and Frank Mittlebach and Alexander Samarin”, title = ”The Latex Companion”, year = ”1993”, publisher = ”Addison-Wesley”, address = ”Reading, Massachusetts” }

slide-14
SLIDE 14

14 Getting current Latex document to use your .bib file . At the end

  • f your Latex file (that is, after the content, but before

\end{document}), you need to place the following commands: \bibliographystyle{plain} \bibliography {sample} If you want your citation to have a different style, you should use the Natbib package. In fact, it can supersede Latex’s own citation commands, as Natbib allows the user to easily switch between Harvard or numeric. The first job is to add the following to your preamble in order to get Latex to use the Natbib package: \usepackage{natbib}

slide-15
SLIDE 15

15 Also, you need to change the bibliography style file to be used. Let’s say we want to use AER style. We need to edit the appropriate line at the bottom of the file so that it reads: \bibliographystyle{aer}. Once done, it is basically a matter of altering the existing \cite commands to display the type of citation you want:

Citation command Natbib output \citet{goossens93} Goossens et al. (1993) \citep{goossens93} (Goossens et al., 1993) \citet*{goossens93} Goossens, Mittlebach, and Samarin (1993) \citep*{goossens93} (Goossens, Mittlebach, and Samarin, 1993)

slide-16
SLIDE 16

16

Formatting

Text FormattingIf you use an editor such as WinEdt, it’s quite easy to find accents (in the “international” tool folder), maths symbols, Greek letters, etc... Getting the right font size is also quite easy:

Command Output \tiny

Size

\scriptsize Size \footnotesize

Size

\small

Size

\normalsize

Size

\large

Size

\Large

Size

\LARGE

Size

\huge

Size

\HUGE

Size

slide-17
SLIDE 17

17 Paragraph Formatting Here are the commands: Alignment Environment Command Left justified flushleft \raggedright Right justified flushright \raggedleft Center center \centering

slide-18
SLIDE 18

18 There are two ways to change the line spacing:

◮ Add \usepackage{setspace} to the document preamble. This

then provides the following environments to use within your document:

◮ doublespace - all lines are double spaced. ◮ onehalfspace - line spacing set to one-and-half spacing. ◮ singlespace - normal linespacing.

◮ Add \renewcommand{\baselinestretch}{number} to the

document preamble. Spacing 10pt 11pt 12pt

  • ne and one-half

1.25 1.21 1.24 double 1.67 1.62 1.66

slide-19
SLIDE 19

19 List Structure Lists often appear in documents, especially academic, as their purpose is often to present information in a clear and concise fashion. List structures in Latex are simply environments which essentially come in three flavors: itemize, enumerate and description. All lists follow the basic format: \begin {list type} \item The first item \item The second item \item The third item, etc . . . \end {list type}

slide-20
SLIDE 20

20 Footnotes The footnote facility is easy to use. The command you need is: \footnote{text}. Do not leave a space between the command the word where you wish the footnote marker to appear,

  • therwise Latex will process that space and will leave the output

not looking as intended.

slide-21
SLIDE 21

21

Page Layout

Geometrical Dimension of the Layout Here are some parameters controlling the page layout that I use for this

  • document. They should be put in the preamble of the document:

\setlength{\topmargin}{-0.8in} extra vertical space added at the top of the header \setlength{\textwidth}{6.6in} width of the text body \setlength{\textheight}{9.35in} height of the text body

slide-22
SLIDE 22

22 Pages Styles There are two commands at your disposal for changing the page style. \pagestyle{style} will apply the specified style to the current and all subsequent pages. \thispagestyle{style} will only affect the current page. The possible styles are:

empty Both header and footer are clear plain Header is clear, but the footer contains the page number headings Header displays page number and other information which the document class deems important, e.g., section headers myheadings Similar to above, however, is possible to control the information in the header

slide-23
SLIDE 23

23 An issue to look out for is that the major sectioning commands (\part, \chapter or \maketitle) specify a \thispagestyle{plain}. So, if you wish to suppress all styles by inserting a \pagestyle{empty} at the beginning of your document, then the style command at each section will override your initial rule, for those pages only. To achieve your intended result, you will have to follow the offending commands with \thispagestyle{empty}.

slide-24
SLIDE 24

24 Customizing with fancyhdr To begin, add the following lines to your preamble: \usepackage{fancyhdr} \pagestyle{fancy} Both the header and footer are comprised of three elements each according to its horizontal position (left, center or right). To set their values, the following commands are available: \lhead[lh-even]lh-odd \foot[lf-even]lf-odd \chead[ch-even]ch-odd \cfoot[cf-even]cf-odd \rhead[rh-even]rh-odd \rfoot[rf-even]rf-odd Here is an example of what I used in my dissertation

\thispagestyle{plain} \chead{} \lfoot{} \cfoot{} \rfoot{} \rhead[\ fancyplain{}{}]{\fancyplain{\thepage}{\thepage}} \lhead[]{\em Chapter \thechapter: Introduction}

slide-25
SLIDE 25

25 Manual Page Formatting Latex offers the following:

\newline Breaks the line at the point of the command. \linebreak Breaks the line at the point of the command, but also stretches the line to the margin. \newpage Ends the current page \pagebreak Breaks the current page at the point of the command. \nopagebreak Stops the page being broken at the point of the command. \clearpage Ends the current page and causes any floats encountered in the input, but yet to appear, to be printed.

slide-26
SLIDE 26

26

Tables

The tabular is an environment, designed for formatting your data into nicely arranged tables. The following symbols are available to describe the table columns:

l left-justified column c centered column r right-justified column pwidth paragraph column with text vertically aligned at the top mwidth paragraph column with text vertically aligned in the middle bwidth paragraph column with text vertically aligned at the bottom | vertical line

  • double vertical line

Once in the environment & column separator \\ start new row \hline horizontal line

slide-27
SLIDE 27

27

OLS OLS OLS 2SLS ERDF per capita 0.0005** 0.0002 0.0008** 0.0027** (0.0002) (0.0002) (0.0003) (0.0012) Interaction Poor*ERDF 0.0005 (0.0005) Initial GVA per capita

  • 0.032***
  • 0.032***
  • 0.211***
  • 0.0229

in each period (0.004) (0.004) (0.024) (0.036) Lagged GVA per capita 0.01*** (0.003) Lagged Unemployment rate 0.009** (0.004) Lagged Share of agriculture

  • 0.021***

in employment (0.003) regions dummies yes yes yes yes First Stage R-squared 0.671 R-squared 0.426 0.431 0.768 0.4978 Obs. 323 323 217 156

slide-28
SLIDE 28

28

Here is the code to make this table \begin{tabular}{ |lcccc|} \hline & OLS & OLS & OLS & 2SLS \\ ERDF per capita & 0.0005** & 0.0002 & 0.0008** & 0.0027**\\ & (0.0002) & (0.0002) & (0.0003) & (0.0012) \\ Interaction Poor*ERDF & & 0.0005 & & \\ & & (0.0005) & & \\ Initial GVA per capita & -0.032*** & -0.032*** & -0.211*** & -0.0229 \\ in each period & (0.004) & (0.004) & (0.024) & (0.036)\\ Lagged GVA per capita & & & 0.01*** & \\ & & & (0.003) & \\ Lagged Unemployment rate & & & 0.009** &\\ & & & (0.004) & \\ Lagged Share of agriculture & & & -0.021*** &\\ in employment & & & (0.003) &\\ regions dummies & yes & yes & yes & yes\\ First Stage R-squared & & & & 0.671\\ R-squared & 0.426 & 0.431 & 0.768 & 0.4978 \\

  • Obs. & 323 & 323 & 217 & 156 \\

\hline \end{tabular}

Use the macro Excel2Latex in Excel to convert your Excel table into L

A

T EX.

slide-29
SLIDE 29

29

Importing Images and creating Figures

In many respects, importing images is easy, once you have the right format. The most common format is Encapsulated Postscript (EPS). Once the pictures are in EPS, you need to put \usepackage{graphicx} in the preamble of your document. The syntax for using graphicx is: \begin{figure}[H] \centerline{\includegraphics[scale=0.5]{latexKopka.eps}} \caption{A Guide to LATEX}\label{kopka} \end{figure} This is what I wrote to add Figure 3. Need for to DVI the file and then DVI to PDF.

slide-30
SLIDE 30

30 One can also use PDF files for figures. Then, in the preamble, you need to replace the command \usepackage{graphicx} by \usepackage[pdftex]{graphicx}. You can specify where in the text you want the figure to be.

Specifier Permission h Place the float here, i.e., at the same point it occurs in the source text. t Position at the top of the page. b Position at the bottom of the page. p Put on a special page for floats only. ! Override internal parameters Latex uses for determining ‘good’ float positions.

slide-31
SLIDE 31

31 Use \listoffigures to add a list of the figures in the beginning of the document. When a label is declared within a float environment (table or figure), the \ref will return the respective fig/table number (although, it must occur after the caption). When declared

  • utside, it will give the section number.
slide-32
SLIDE 32

32

Mathematics

Latex needs to know beforehand that the subsequent text does in fact contain mathematical elements. This is because Latex typesets maths notation differently than normal text. Environment Latex shorthand Tex shorthand Text \begin{math}...\end{math} \(...\) $...$

slide-33
SLIDE 33

33 To create a fraction, you must use the \frac{numerator}{denominator} command. Here is an example: \frac{6xˆ{3}+36xˆ{2}}{(x+4)ˆ{2}}

6x3+36x2 (x+4)2

slide-34
SLIDE 34

34 Powers and indices are mathematically equivalent to superscripts and subscripts in normal text mode. The carat (ˆ) character is used to raise something, and the underscore ( ) is for lowering. How to use them is best shown by example: xˆ{2n} x2n n {i, j, t} ni,j,t xˆ{2i} {3j} x2i

3j

slide-35
SLIDE 35

35 You might need to use another type of brackets with maths: \frac{d}{dx}[\frac{f(x)}{g(x)}]

d dx [ f (x) g(x)]

\bigg(\frac{Y}{L}\bigg)\frac{L}{pop}

  • Y

L

  • L

pop

\left(\frac{2x}{5y}\right)

  • 2x

5y

slide-36
SLIDE 36

36 If you have an equation that fits on one line: d dx [f (x)n] = n(f (x)n−1)f ′(x) (1) this is the code you should use: \begin {equation} \label{...} \frac{d}{dx}[f (x) ˆ {n}] = n(f (x) ˆ {n − 1})f ′(x) \end {equation}

slide-37
SLIDE 37

37 If you have an equation that does not fit on one line, you should use \multline instead of the \equation command: ln ERDFi,t = βo + β1lnGVAi,t−1 + β2 ln Unemploymenti,t−1+ β3 ln Agriculturei,t−1 + µt + εi,t (2)

slide-38
SLIDE 38

38 this is the code you should use:

\begin {multline} \label{ERDF} \ln ERDF {i,t} =\beta {0} + \beta {1}\ln GVA {i,t-1} + \beta {2}\ln Unemployment {i,t-1}+ \\ \beta {3}\ln Agriculture {i,t-1} + \mu {t}+ \varepsilon {i,t} \end {multline}

slide-39
SLIDE 39

39

Some References

“A Guide to LATEX: Document Preparation for Beginners and Advanced Users”, Helmut Kopka. This book is exactly what it says

  • geared for both beginners and advanced users; it is especially

helpful for bibtex. ISBN 0201398257.

Figure: A Guide to LATEX

slide-40
SLIDE 40

40 “The Latex Companion” by Michel Goossens, Frank Mittelbach and Alexander Samarin. This one is also very good, but I found that it made more sense after I had been using Latex for a while. ISBN 0201541998.

Figure: Latex Companion Book

slide-41
SLIDE 41

41

◮ “The Not So Short Introduction to L AT

EX2: Or L

A

T EX2 in 90 minutes” by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth Schlegl: this PDF file is available on my website. It’s a great reference, easy to read.

◮ http://en.wikibooks.org/wiki/LaTeX: this website gives you

very basic stuff, but it’s quite useful for true beginners

◮ http://www.ctan.org/: if you are looking for a package, a

command, a bibliography style, this website provides you access to the Comprehensive T EX Archive Network.