How to get started in L A T EX Document Structure Formatting and - - 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 Document Structure Formatting and - - PowerPoint PPT Presentation

Introduction Some very basics How to get started in L A T EX Document Structure Formatting and Page Layout Florence Bouvet Tables Department of Economics Importing Images and Sonoma State University creating Figures Mathematics


slide-1
SLIDE 1

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

How to get started in L

AT

EX

Florence Bouvet Department of Economics Sonoma State University March 26, 2009

1 / 29

slide-2
SLIDE 2

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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.

2 / 29

slide-3
SLIDE 3

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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).

3 / 29

slide-4
SLIDE 4

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

Disadvantages

❼ One can’t see the final result straight away. PDF is the

final result.

❼ One needs to know the necessary commands for LaTeX

markup.

❼ It can sometimes be difficult to obtain a certain ’look’. ❼ It might be less convenient to add comments to one’s

coauthors.

4 / 29

slide-5
SLIDE 5

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

Some very Basics

What you need to get started:

❼ MikTex (http://www.miktex.org/): it’s free! ❼ an Editor, such as WinEdt. (http://www.winedt.com/):

✩40 for an individual educational license.

❼ an example of a TeX file to follow.

5 / 29

slide-6
SLIDE 6

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

Document Structure

L

AT

EX 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} produce \setlength{\topmargin}{-0.8in} \setlength{\textwidth}{6.6in} \usepackage{hyperref} \usepackage{indentfirst} \renewcommand{\baselinestretch}{1.24}

6 / 29

slide-7
SLIDE 7

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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} \date{today } \maketitle

7 / 29

slide-8
SLIDE 8

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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).

8 / 29

slide-9
SLIDE 9

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

For example, at the end of the introduction:

”The remainder of the paper is organized as follows. The Beveridge curve is derived in Section \ref{model}. Section \ref{conclusion} concludes.” And later in the paper : \section{Derivation of the Beveridge curve} \label{model} \section{National and regional Beveridge curves in Europe} \label{figures}

9 / 29

slide-10
SLIDE 10

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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:

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

10 / 29

slide-11
SLIDE 11

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

Getting your 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}

11 / 29

slide-12
SLIDE 12

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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)

12 / 29

slide-13
SLIDE 13

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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

13 / 29

slide-14
SLIDE 14

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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}

14 / 29

slide-15
SLIDE 15

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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, otherwise Latex will process that space and will leave the output not looking as intended.

15 / 29

slide-16
SLIDE 16

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

Tables

❼ One of my biggest frustrations in Word and Powerpoint! ❼ The tabular is an environment, designed for formatting

your data into nicely arranged tables.

❼ Use the macro Excel2Latex in Excel to convert your Excel

table into L

AT

EX.

❼ 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 16 / 29

slide-17
SLIDE 17

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References 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 17 / 29

slide-18
SLIDE 18

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References 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} 18 / 29

slide-19
SLIDE 19

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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 4. Need for to DVI the file and then DVI to PDF.

19 / 29

slide-20
SLIDE 20

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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.

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.

20 / 29

slide-21
SLIDE 21

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

Mathematics

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

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

21 / 29

slide-22
SLIDE 22

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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

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

  • 22 / 29
slide-23
SLIDE 23

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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}

23 / 29

slide-24
SLIDE 24

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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) 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} 24 / 29

slide-25
SLIDE 25

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

Presentation with Beamer

❼ Beamer is a L

AT

EX class for creating presentations.

❼ A beamer presentation is created like any other L

AT

EX document: It has a preamble and a body, the body contains sections and subsections, the different slides (called frames in beamer) are put in environments (maths, figures, etc), they are structured using itemize and enumerate environments, and so on.

❼ The layout, the colors, and the fonts used in a

presentation can easily be changed globally.

25 / 29

slide-26
SLIDE 26

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

❼ Easy to convert your paper (if written with L

AT

EX) into a presentation.

❼ The final output is typically a pdf-file. So you do not have

to worry about which version of the presentation program might be installed there. Also, your presentation is going to look exactly the way it looked on your computer.

26 / 29

slide-27
SLIDE 27

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

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

27 / 29

slide-28
SLIDE 28

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

“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

28 / 29

slide-29
SLIDE 29

Introduction Some very basics Document Structure Formatting and Page Layout Tables Importing Images and creating Figures Mathematics Presentation with Beamer Some References

❼ “The Not So Short Introduction to L

AT

EX2: Or L

AT

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.

❼ to learn more about Beamer to create presentations:

http://latex-beamer.sourceforge.net/

29 / 29