Sei sulla pagina 1di 219

Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Workshop: A Simple Introduction to LATEX

Michael P. Fix
Susanne Schorpp
Georgia State University

142 October 2012


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Outline

1 Introduction

2 The Basics

3 Typesetting Text

4 Typesetting Math

5 Tables and Figures

6 Bibliography

7 Closing Statements
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

What is LATEX?

LATEX is an alternative to WYSIWYG word processors for


creating documents.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

What is LATEX?

LATEX is an alternative to WYSIWYG word processors for


creating documents.
LATEX allows you to focus on writing your document without
spending hours formatting.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

What is LATEX?

LATEX is an alternative to WYSIWYG word processors for


creating documents.
LATEX allows you to focus on writing your document without
spending hours formatting.
You simply provide a few logical commands to define the
structure of your document, and let LATEX design and TEX
typeset your work.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Why You Should Use LATEX

Your documents look professionally printed.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Why You Should Use LATEX

Your documents look professionally printed.


While it requires a bit of time investment upfront to learn, it
will save you many wasted hours later.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Why You Should Use LATEX

Your documents look professionally printed.


While it requires a bit of time investment upfront to learn, it
will save you many wasted hours later.
You can typeset elegant mathematical formulae with simple
commands.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Why You Should Use LATEX

Your documents look professionally printed.


While it requires a bit of time investment upfront to learn, it
will save you many wasted hours later.
You can typeset elegant mathematical formulae with simple
commands.
Everything is free!
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Basic Structure of the Input File

For a file to be correctly processed by LATEX there are a


few essential components that must be in the file.

1 Defining the document class


2 Loading Packages
3 Beginning and ending the document
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Document Class

Definition
The Document Class specifies the type of document you intent to
write. For example, most stuff can be done with the article
class, the book class is for longer documents, and the beamer class
is used for presentations (like this one).
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Document Class

Every file must begin by specifying the document class with


the following command:

\documentclass[options]{class}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Document Class

Every file must begin by specifying the document class with the
following command:

\documentclass[options]{class}

This can be as simple as defining the class:

\documentclass{article}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Document Class

Every file must begin by specifying the document class with the
following command:

\documentclass[options]{class}

This can be as simple as defining the class:

\documentclass{article}

Or can be used to specify font size, paper type, and title


page, among other options. For example:

\documentclass[11pt, letter]{article}

Would specify that you wanted to write an article in 11 point


font using letter paper. (Note: This is what I usually use.)
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Packages

Definition
Basic LATEX often does not include everything you need to include
in a document. For example, if you wish to include graphics, most
mathematical symbols, colored text or various other things, you
will have to use Packages. Packages allow you to expand the
functionality of LATEX.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Packages

To activate a package, the following command is used:

\usepackage[options]{package}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Packages

To activate a package, the following command is used:

\usepackage[options]{package}

For example, in order to typeset many mathematical symbols


and formulae you need to load the follow two packages:

\usepackage{amssymb}
\usepackage{amsmath}

Note: options are rarely used with packages.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Identifying Information

The last items generally included in the preamble to your file are
the identifying information.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Identifying Information

The last items generally included in the preamble to your file are
the identifying information.
This is done with the following three commands:

\title{The Title}
\author{Your Name}
\date{The Date}

or

\date{\today}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

The Body of the Document

With the preamble to your input file complete, you are now
ready to begin writing the body of the document. It is
important to tell LATEX when to begin the document with the
following command:

\begin{document}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

The Body of the Document

With the preamble to your input file complete, you are now ready
to begin writing the body of the document. It is important to tell
LATEX when to begin the document with the following command:

\begin{document}

. . . and when to end the document with this command:

\end{document}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

The Body of the Document

To put the title information at the top of your document,


you need only insert a simple command at the top of your
document.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

The Body of the Document

To put the title information at the top of your document, you need
only insert a simple command at the top of your document.

Simply insert the following command at the beginning of


your document:

\maketitle

Note: You have to insert the \maketitle command after


\begin{document} or your title and name will not appear.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Cover Pages

Alternatively, you may desire to create a cover page for your


document rather than simply having the title information at
the top of the first page.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Cover Pages

Alternatively, you may desire to create a cover page for your


document rather than simply having the title information at the
top of the first page.

This is very simple and requires only that you enter the
following series of commands:

\begin{titlepage}
\maketitle
\thispagestyle{empty} %To avoid page number on cover page
\end{titlepage}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Simple Document

Now that weve got the basics down, we can put it all together to
create a simple document. Try this:

\documentclass{article}
\title{A Short Paper}
\author{Me}
\date{\today}
\begin{document}
\maketitle
This is a very short paper! I should get an A for
being concise.
\end{document}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Simple Document
If you were successful your document should appear like this:

A Short Paper
Me
July 14, 2009

This is a very short paper! I should get an A for being concise.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Technical Note File Types

Each time you create a new document, several files will be created.
The most important of these is your input file (i.e. the file you
create in your text editor).
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Technical Note File Types

Each time you create a new document, several files will be created.
The most important of these is your input file (i.e. the file you
create in your text editor).

This file will look something like:

filename.tex
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Technical Note File Types

Each time you create a new document, several files will be created.
The most important of these is your input file (i.e. the file you
create in your text editor).

This file will look something like:

filename.tex

Your output file will be saved in the same folder as something like:

filename.pdf or filename.ps
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Technical Note File Types

Each time you create a new document, several files will be created.
The most important of these is your input file (i.e. the file you
create in your text editor).

This file will look something like:

filename.tex

Your output file will be saved in the same folder as something like:

filename.pdf or filename.ps

There will also be numerous other files created with extensions like:

filename.log, filename.snm, filename.vrb, etc.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Writing Text for Your Document

For me, one of the greatest things about creating LATEX is the
simplicity of writing your document.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Writing Text for Your Document

For me, one of the greatest things about creating LATEX is the
simplicity of writing your document.
Since you are working with a text editor, you are overwhelmed
with the graphical interface of WYSIWYG word processors.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Writing Text for Your Document

For me, one of the greatest things about creating LATEX is the
simplicity of writing your document.
Since you are working with a text editor, you are overwhelmed
with the graphical interface of WYSIWYG word processors.
It is not necessary to hunt through menu bars to find
everything you need to properly typeset your document.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Writing Text for Your Document

For me, one of the greatest things about creating LATEX is the
simplicity of writing your document.
Since you are working with a text editor, you are overwhelmed
with the graphical interface of WYSIWYG word processors.
It is not necessary to hunt through menu bars to find
everything you need to properly typeset your document.
All that is required is for you to learn a few simple (and easy
to look up) commands to instruct the program and it does all
the work for you.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Writing Text for Your Document

For me, one of the greatest things about creating LATEX is the
simplicity of writing your document.
Since you are working with a text editor, you are overwhelmed
with the graphical interface of WYSIWYG word processors.
It is not necessary to hunt through menu bars to find
everything you need to properly typeset your document.
All that is required is for you to learn a few simple (and easy
to look up) commands to instruct the program and it does all
the work for you.
That is what is section of the presentation is all about . . .
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Spacing

Spacing in LATEX is largely automatic. Like a


professionally printed book or journal, it ensures relatively
uniform spacing between characters, words, lines, and
paragraphs. Thus you do not need to worry about these
details. But there are a few things you must keep in
mind.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

The Essentials for Proper Spacing I

First, you must note that spacing between words is treat uniformly.
This regardless of whether you type:

The dog ran fast.

or

The dog ran fast.

or

The dog ran fast.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

The Essentials for Proper Spacing I

First, you must note that spacing between words is treat uniformly.
This regardless of whether you type:

The dog ran fast.

or

The dog ran fast.

or

The dog ran fast.

The output will be the same:


The dog ran fast.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

The Essentials for Proper Spacing II

For paragraphs, LATEX also automatically intents the first line and
provides proper spacing. You simply need to let it know you want
to start a new paragraph by leaving a blank line in your input file.
For example:

This is a paragraph.

This is the next paragraph.

instead of:

This is a paragraph.
This is the next paragraph.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

The Essentials for Proper Spacing III

Finally, note that while all of this spacing is automatic, you can tell
LATEX to do specific things when necessary.
To create a line break use:

\\

or

\\*

to start a new line without starting a new paragraph.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

The Essentials for Proper Spacing III

Finally, note that while all of this spacing is automatic, you can tell
LATEX to do specific things when necessary.
To create a line break use:

\\

or

\\*

to start a new line without starting a new paragraph.

For a page break, you need to use:

\newpage
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Emphasizing Text

Sometimes it is necessary to italicize or bold face text.


To do this you use the following commands:

\textit{ . . . } or {\it . . . }

for italicized text.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Emphasizing Text

Sometimes it is necessary to italicize or bold face text.


To do this you use the following commands:

\textit{ . . . } or {\it . . . }

for italicized text.


Or

\textbf{ . . . } or {\bf . . . }

for bold faced text.


Or

\texttt{ . . . } or {\tt . . . }

for typewriter style text.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters

LATEX has commands for almost any special character that


you could ever need. Here are some common examples.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Quotation Marks

For quotation marks you cannot use the " key as you would in
a word processor, or you will get a strange output.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Quotation Marks

For quotation marks you cannot use the " key as you would in
a word processor, or you will get a strange output.
Instead, you should use two characters to open a quotation
and two to close a quotation.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Quotation Marks

For quotation marks you cannot use the " key as you would in
a word processor, or you will get a strange output.
Instead, you should use two characters to open a quotation
and two to close a quotation.
Similarly, you use a single and for single quotes.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Hyphens and Dashes

Three types of dashes are recognized in LATEX.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Hyphens and Dashes

Three types of dashes are recognized in LATEX.


A normal hyphen (-) is made simply by typing - as normal
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Hyphens and Dashes

Three types of dashes are recognized in LATEX.


A normal hyphen (-) is made simply by typing - as normal
An en-dash (), is made by typing --.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Hyphens and Dashes

Three types of dashes are recognized in LATEX.


A normal hyphen (-) is made simply by typing - as normal
An en-dash (), is made by typing --.
An em-dash (), is made by typing ---.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Hyphens and Dashes

Three types of dashes are recognized in LATEX.


A normal hyphen (-) is made simply by typing - as normal
An en-dash (), is made by typing --.
An em-dash (), is made by typing ---.
Additionally, a negative sign is made simply by typing - while
in math mode (will discuss this later), or by putting it
between two $ marks.
For example, typing $-6$ will give you 6.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Others

\& &
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Others

\& &
\% %
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Others

\& &
\% %
\ldots . . .
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Special Characters Others

\& &
\% %
\ldots . . .
The Google is very useful for locating any symbols you might
ever need
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Section Headings

LATEX supports various ways to subdivide your document into


sections. The most common of these are:

\section{ . . . } or \section*{ . . . }
\subsection{ . . . } or \subsection*{ . . . }
\subsubsection{ . . . } or \subsubsection*{ . . . }
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Section Headings

LATEX supports various ways to subdivide your document into


sections. The most common of these are:

\section{ . . . } or \section*{ . . . }
\subsection{ . . . } or \subsection*{ . . . }
\subsubsection{ . . . } or \subsubsection*{ . . . }

Note: the section, subsection, and subsubsection


commands will automatically number the sections. The
section*, subsection*, and subsubsection* commands
print only the name of the section.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Footnotes

Inserting footnotes is extremely simple. Simply insert the following


command where you would like the footnote to appear.

\footnote{ . . . }
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Footnotes

Inserting footnotes is extremely simple. Simply insert the following


command where you would like the footnote to appear.

\footnote{ . . . }

. . . and simply type the text of the footnote inside the braces.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments

Definition
Environments are used in LATEX for writing special kinds of text.
Think of them as creating a special section of your document that
follows a different set of rules.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments

Definition
Environments are used in LATEX for writing special kinds of text.
Think of them as creating a special section of your document that
follows a different set of rules.
To use an environment, you use the following commands:

\begin{environment} and \end{environment}


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments

Definition
Environments are used in LATEX for writing special kinds of text.
Think of them as creating a special section of your document that
follows a different set of rules.
To use an environment, you use the following commands:

\begin{environment} and \end{environment}

. . . with the text entered between the two commands.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists

Making lists in LATEX is very quick and easy.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists

Making lists in LATEX is very quick and easy.


Additionally, you control the nesting of lists, so you never
have to deal with the auto-formatting errors in MS Word.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists

Making lists in LATEX is very quick and easy.


Additionally, you control the nesting of lists, so you never
have to deal with the auto-formatting errors in MS Word.
The two most common types of lists use the enumerate
environment (for a numbered list) or the itemize
environment (for items where item are identified by a symbol).
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists

To make a list simply begin the environment:

\begin{itemize}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists

To make a list simply begin the environment:

\begin{itemize}

Then, note each item with the \item command. For example:

\item Item 1
\item Item 2
\item Item 3
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists

To make a list simply begin the environment:

\begin{itemize}

Then, note each item with the \item command. For example:

\item Item 1
\item Item 2
\item Item 3

Finally, end the environment:

\end{itemize}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists

enumerate works the same as itemize except the list will be


numbered.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists

enumerate works the same as itemize except the list will be


numbered.
Additionally, lists can be easily nested. Simply add another
\begin{itemize} command where you would like to begin
the nested list.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists

enumerate works the same as itemize except the list will be


numbered.
Additionally, lists can be easily nested. Simply add another
\begin{itemize} command where you would like to begin
the nested list.
Further, enumerate lists can be nested within itemize lists
and vise versa.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists
Try the following example:
\documentclass{article}
\title{A Simple List}
\author{Me}
\begin{document}
\maketitle
\begin{enumerate}
\item This is the first item.
\item This is the second item.
\begin{itemize}
\item I like the second item.
\item {\it It is good}.
\end{itemize}
\item This is the third --- and last --- item.
\end{enumerate}
\end{document}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Lists
You document should look like this:

A Simple List
Me
October 11, 2011

1. This is the first item.


2. This is the second item.
I like the second item.
It is good.

3. This is the third and last item.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Quote

The quote environment is useful for long quotes that need to be


set off from the rest of the text.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Quote

The quote environment is useful for long quotes that need to be


set off from the rest of the text.

\begin{quote}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Quote

The quote environment is useful for long quotes that need to be


set off from the rest of the text.

\begin{quote}

Enter the text you are quoting.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Quote

The quote environment is useful for long quotes that need to be


set off from the rest of the text.

\begin{quote}

Enter the text you are quoting.

Then, end the quote environment:

\end{quote}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Abstract

The abstract environment is used for making abstracts for


scholarly papers.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Abstract

The abstract environment is used for making abstracts for


scholarly papers.
It works just like the other environments.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Abstract

The abstract environment is used for making abstracts for


scholarly papers.
It works just like the other environments.
Simply write the text of your abstract between the commands
to begin and end the environment.

\begin{abstract}
This is an abstract
\end{abstract}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Others

There are many additional environments available


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Others

There are many additional environments available


Excluding ones for mathematics (to be discussed in the next
section) some of the more common are:
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Others

There are many additional environments available


Excluding ones for mathematics (to be discussed in the next
section) some of the more common are:
flushleft, flushright, and center change the alignment
of the text inside the environment.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Environments Others

There are many additional environments available


Excluding ones for mathematics (to be discussed in the next
section) some of the more common are:
flushleft, flushright, and center change the alignment
of the text inside the environment.
tabular is used to create tables. We will discuss this later.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Introduction to Typesetting Math in LATEX

As Im sure you are well aware, the ability to typeset


mathematical formulae with an elegance unmatched by any
other program is the greatest strength of LATEX.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Introduction to Typesetting Math in LATEX

As Im sure you are well aware, the ability to typeset


mathematical formulae with an elegance unmatched by any
other program is the greatest strength of LATEX.
It would be impossible to show you everything you can
possibly do, without spending days waking through example
after example.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Introduction to Typesetting Math in LATEX

As Im sure you are well aware, the ability to typeset


mathematical formulae with an elegance unmatched by any
other program is the greatest strength of LATEX.
It would be impossible to show you everything you can
possibly do, without spending days waking through example
after example.
Thus, I am simply going to provide a brief overview to show
you how its done.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Introduction to Typesetting Math in LATEX

As Im sure you are well aware, the ability to typeset


mathematical formulae with an elegance unmatched by any
other program is the greatest strength of LATEX.
It would be impossible to show you everything you can
possibly do, without spending days waking through example
after example.
Thus, I am simply going to provide a brief overview to show
you how its done.
Fortunately, there are countless reference sources available for
anything you could ever need to do.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Packages

Just about any mathematical symbol or formulae you could


ever need to created is contained in AMS-LATEX.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Packages

Just about any mathematical symbol or formulae you could


ever need to created is contained in AMS-LATEX.
This was created by the American Mathematical Society and
is as comprehensive as possible it is also how they create all
of their documents.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Packages

Just about any mathematical symbol or formulae you could


ever need to created is contained in AMS-LATEX.
This was created by the American Mathematical Society and
is as comprehensive as possible it is also how they create all
of their documents.
As it is included in any basic installation of LATEX, you do not
need to install anything extra.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Packages

Just about any mathematical symbol or formulae you could


ever need to created is contained in AMS-LATEX.
This was created by the American Mathematical Society and
is as comprehensive as possible it is also how they create all
of their documents.
As it is included in any basic installation of LATEX, you do not
need to install anything extra.
Just remember to load two package every time you start:

\usepackage{amssymb}
\usepackage{amsmath}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Environments

All mathematical formulae and equations must be written


inside special environments to appear correctly in your
output file.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Environments

All mathematical formulae and equations must be written inside


special environments to appear correctly in your output file.

The two most common are: equation for numbered


equations and equation* for unnumbered ones.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Environments

All mathematical formulae and equations must be written inside


special environments to appear correctly in your output file.

The two most common are: equation for numbered equations


and equation* for unnumbered ones.

Alternatively, if you wish to include mathematical symbols or


formulas in the body of your text, you should use:

$ . . . $
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Environments

These are only a few of the many environments for


typesetting mathematical formulae.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Environments

These are only a few of the many environments for


typesetting mathematical formulae.
Many others are available for special purposes, such as:
Aligning a series of equations (align)
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Environments

These are only a few of the many environments for


typesetting mathematical formulae.
Many others are available for special purposes, such as:
Aligning a series of equations (align)
Allowing a long equation to be split over multiple lines
(multiline)
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Environments

These are only a few of the many environments for


typesetting mathematical formulae.
Many others are available for special purposes, such as:
Aligning a series of equations (align)
Allowing a long equation to be split over multiple lines
(multiline)
. . . and many others
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Environments

These are only a few of the many environments for


typesetting mathematical formulae.
Many others are available for special purposes, such as:
Aligning a series of equations (align)
Allowing a long equation to be split over multiple lines
(multiline)
. . . and many others
The document A Short Math Guide to LATEX (Downs 2002),
provides details on these environments, and an extensive list
of commonly used mathematical symbols.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Math is Easy as

We now know everything we need to know to typeset simple


equations in LATEX.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Math is Easy as

We now know everything we need to know to typeset simple


equations in LATEX.

Lets try some examples.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Math is Easy as

We now know everything we need to know to typeset simple


equations in LATEX.

Lets try some examples.

First, open a new document in your text editor and create the
preamble:

\documentclass{article}
\usepackage{amssymb}
\usepackage{amsmath}
\title{Some Simple Math}
\author{Me}
\begin{document}
\maketitle
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Math is Easy as

Example 1: Lets say we want to include some math in the body


of a paragraph:

Einsteins most famous equation is $e = mc ^ 2$.\\


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Math is Easy as

Example 2: Lets say we want to set off an important equation,


but we do not want it to be numbered:

Another important contribution to scientific knowledge


is the Pythagorean Theorem.\\
\begin{equation*}
a^2 + b^2 = c^2
\end{equation*}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Math is Easy as

Example 3: Finally, lets say we need to use multiple equations


and we want to number them.

Since we know that:


\begin{equation}
3+3=6
\end{equation}
and we know that:
\begin{equation}
2*3 =6
\end{equation}
Then, from (1) and (2), we know that:
\begin{equation}
2*3 =3+3
\end{equation}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Math is Easy as

Now just remember to end your document:

\end{document}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Math is Easy as

Now just remember to end your document:

\end{document}

Now, typeset your document and compare it to the one on


the following slide.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Math is Easy as

Simple Math
Me
October 11, 2011

Einsteins most famous equation is e = mc2 .

Another important contribution to scientific knowledge is the Pythagorean The-


orem.

a2 + b2 = c2
Since we know that:
3+3=6 (1)
and we know that:
23=6 (2)
Then, from (1) and (2), we know that:

23=3+3 (3)
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands

There is an almost endless list of mathematical commands


that I could show you.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands

There is an almost endless list of mathematical commands


that I could show you.
However, the reality is that you will never need to use many of
them were not mathematicians after all!
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands

There is an almost endless list of mathematical commands


that I could show you.
However, the reality is that you will never need to use many of
them were not mathematicians after all!
So, in the next few slides, I will cover some of the ones that I
use the most frequently.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands

There is an almost endless list of mathematical commands


that I could show you.
However, the reality is that you will never need to use many of
them were not mathematicians after all!
So, in the next few slides, I will cover some of the ones that I
use the most frequently.
And remember, there are a ton of resources for this
information, so most people will never find the need to
memorize any except those they use with great regularity.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands A Note

For all the examples that follow, I will use the $. . . $


format (i.e. for including math within the body of a
paragraph). Remember that when using the equation,
equation*, or any other math environment, it is
unnecessary to include the $ symbols.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Greek Letters

Greek letters are commonly used and one of the simplest things to
remember.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Greek Letters

Greek letters are commonly used and one of the simplest things to
remember.

Lower case letters are simply their name in all lower case letter
preceded by a \
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Greek Letters

Greek letters are commonly used and one of the simplest things to
remember.

Lower case letters are simply their name in all lower case letter
preceded by a \

. . . for upper cases Greek letters you simply capitalize the first
letter of the name. For example:

$\alpha \beta \gamma \Pi \Sigma \Delta$


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Greek Letters

Greek letters are commonly used and one of the simplest things to
remember.

Lower case letters are simply their name in all lower case letter
preceded by a \

. . . for upper cases Greek letters you simply capitalize the first
letter of the name. For example:

$\alpha \beta \gamma \Pi \Sigma \Delta$

Gives you:

Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Fractions

There are a few ways to make fractions in LATEX.


For simple usually numeric fractions, we may want them
typeset as 1/2. We can do this by using:

$1/2$
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Fractions

There are a few ways to make fractions in LATEX.


For simple usually numeric fractions, we may want them
typeset as 1/2. We can do this by using:

$1/2$

Sometimes we want a more traditional appearance for our


a+b
fractions, especially when they are more complex like c+d .
For this we would use:

$\frac{a+b}{c+d}$
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Exponents and Subscripts

As we saw in the example equations earlier, to typeset exponents


we simply enter a ^ prior to the exponent. Thus, to get nk , we
simply need to enter:

$n^k$
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Exponents and Subscripts

As we saw in the example equations earlier, to typeset exponents


we simply enter a ^ prior to the exponent. Thus, to get nk , we
simply need to enter:

$n^k$

For subscripts, we simply insert the _ character before the


subscript. Thus, to get nk , we simply enter:

$n_k$
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Grouping Symbols

Often in typesetting mathematical expressions we need to use


grouping symbols such as parentheses (. . . ), brackets [. . . ], braces
{ . . . }, and absolute value symbols | . . . |.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Grouping Symbols

Often in typesetting mathematical expressions we need to use


grouping symbols such as parentheses (. . . ), brackets [. . . ], braces
{ . . . }, and absolute value symbols | . . . |.

Making each these symbols is quite simple:

( . . . ) for parentheses
[ . . . ] for brackets
\{ . . . \} for braces
$\vert$ for absolute values
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Grouping Symbols

Often in typesetting mathematical expressions we need to use


grouping symbols such as parentheses (. . . ), brackets [. . . ], braces
{ . . . }, and absolute value symbols | . . . |.

Making each these symbols is quite simple:

( . . . ) for parentheses
[ . . . ] for brackets
\{ . . . \} for braces
$\vert$ for absolute values

Note: Only the absolute value symbols require the $, when not in
math mode.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Grouping Symbols

There are commands that allow you to manually control the size of
your grouping symbols:

$\big($ $\Big($ $\bigg($ $\Bigg($


or
$\big\{$ $\Big\{$ $\bigg\{$ $\Bigg\{$
or
$\big\vert$ $\Big\vert$ $\bigg\vert$ $\Bigg\vert$
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Some Common Commands Grouping Symbols

There are commands that allow you to manually control the size of
your grouping symbols:

$\big($ $\Big($ $\bigg($ $\Bigg($


or
$\big\{$ $\Big\{$ $\bigg\{$ $\Bigg\{$
or
$\big\vert$ $\Big\vert$ $\bigg\vert$ $\Bigg\vert$

 (
n
. . . gives you

Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Typesetting Math Concluding Comments

I couldnt possibly go through everything you may ever need


to do with respect to typesetting mathematical symbols and
formulae.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Typesetting Math Concluding Comments

I couldnt possibly go through everything you may ever need


to do with respect to typesetting mathematical symbols and
formulae.
However, this introduction should provide you with all the
tools you need.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Typesetting Math Concluding Comments

I couldnt possibly go through everything you may ever need


to do with respect to typesetting mathematical symbols and
formulae.
However, this introduction should provide you with all the
tools you need.
Regardless of how simple your application:

y = X + 
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Typesetting Math Concluding Comments

I couldnt possibly go through everything you may ever need


to do with respect to typesetting mathematical symbols and
formulae.
However, this introduction should provide you with all the
tools you need.
Regardless of how simple your application:

y = X + 

. . . or how complex:
 

+ yi  2 1 
2 1
fnb (yi |, 2 ) =   2
yi ( 2 ) 2 1
yi ! 21
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX

Making tables in LATEX requires a relatively simple series of


commands, however it is important that you follow a few simple
rules.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX

Making tables in LATEX requires a relatively simple series of


commands, however it is important that you follow a few simple
rules.

Lets start with how to make a very simple 2 x 2 table like the one
below:

x1 x2
y1 .4 .6
y2 .6 .4
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX

The first thing that we need to keep in mind when making table is
that they are made inside the tabular environment.

\begin{tabular}{specifications}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX

The first thing that we need to keep in mind when making table is
that they are made inside the tabular environment.

\begin{tabular}{specifications}

Unlike many other environments, we must make an additional


declaration in in \begin{environment} command. Specifically,
we must define the specifications for our table.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

In defining the specifications for our table, we must define three


things:
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

In defining the specifications for our table, we must define three


things:
1 The number of columns.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

In defining the specifications for our table, we must define three


things:
1 The number of columns.
2 The alignment of each column.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

In defining the specifications for our table, we must define three


things:
1 The number of columns.
2 The alignment of each column.
3 Whether we want vertical lines on the left margin, right
margin, and/or between any of the columns.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

We use the following format to declare our table


specification:

\begin{tabular}{ l c c }
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

We use the following format to declare our table specification:

\begin{tabular}{ l c c }

Each entry represents a column. Thus the above example


would be for a table with three columns.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

We use the following format to declare our table specification:

\begin{tabular}{ l c c }

Each entry represents a column. Thus the above example would be


for a table with three columns.

The letters tell us how we want each column aligned, and we


use:
l left-aligned column
c centered column
r right-aligned column
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

We use the following format to declare our table specification:

\begin{tabular}{ l c c }

Each entry represents a column. Thus the above example would be


for a table with three columns.

The letters tell us how we want each column aligned, and we use:
l left-aligned column
c centered column
r right-aligned column

Thus in the example, the first column is left-aligned, the


second is centered, and the last is also centered.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

Finally, we must also declare any vertical lines we would like


to have appear in our table.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

Finally, we must also declare any vertical lines we would like to


have appear in our table.

To do this, we use the following symbols:


| vertical line
|| double vertical line
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Specifications

Finally, we must also declare any vertical lines we would like to


have appear in our table.

To do this, we use the following symbols:


| vertical line
|| double vertical line

Since our example has a line on each side for the edge of the
table and a line between the first and second column, we
must declare this in our specifications:

\begin{tabular}{ | l | c c |}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Additional Commands


Before we can fill in our table, we need to familiarize
ourselves with three more commands.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Additional Commands


Before we can fill in our table, we need to familiarize ourselves with
three more commands.

First, we need to know how to make the horizontal lines at


the top and bottom of our table and after the first row. To
do this we use:

\hline
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Additional Commands


Before we can fill in our table, we need to familiarize ourselves with
three more commands.

First, we need to know how to make the horizontal lines at the top
and bottom of our table and after the first row. To do this we use:

\hline

Second, we need a symbol to separate the data for each


column within a single row. For this we use:

&
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Additional Commands


Before we can fill in our table, we need to familiarize ourselves with
three more commands.

First, we need to know how to make the horizontal lines at the top
and bottom of our table and after the first row. To do this we use:

\hline

Second, we need a symbol to separate the data for each column


within a single row. For this we use:

&

Finally, we need a symbol to separate the rows of our table.


For this we use:

\\
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Putting It Together I

Now we know how to make a table in LATEX.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Putting It Together I

Now we know how to make a table in LATEX.

Lets look at the example again and then we will go through how
to put it all together.

x1 x2
y1 .4 .6
y2 .6 .4
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Putting It Together II

The first step is to enter the tabular environment and declare the
specifications:

\begin{tabular}{ | l | c c |}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Putting It Together III

Next, we declare that we want a horizontal line at the top of our


table:

\hline
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Putting It Together IV

Now we can enter our first line of information. Since the


first column is empty we simply leave a blank space, prior to
our first column separator ( &).
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Putting It Together IV

Now we can enter our first line of information. Since the first
column is empty we simply leave a blank space, prior to our first
column separator ( &).

Then, we enter the information for our second column,


another &, the information for the third column, and a row
separator (\\).

& $x_1$ & $x_2$ \\


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Putting It Together V

Now, since we want a horizontal line after this row, we can


enter another:

\hline
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Putting It Together V

Now, since we want a horizontal line after this row, we can enter
another:

\hline

Next we enter the information we want to appear in the final


two rows:

$y_1$ & .4 & .6 \\


$y_2$ & .6 & .4 \\
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Putting It Together VI

Since we want another horizontal line at the bottom of our


table we need one final:

\hline
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Putting It Together VI

Since we want another horizontal line at the bottom of our table


we need one final:

\hline

Finally, we need to exit the tabular environment:

\end{tabular}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Note on Spacing

While spacing makes little technical difference in the tabular


environment, you should carefully align your column separators
when making a table with many rows.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Note on Spacing

While spacing makes little technical difference in the tabular


environment, you should carefully align your column separators
when making a table with many rows.

Consider the following example. Each of the lines below will result
in the same output:

$y_1$ & .4 & .6 \\


$y_1$ & .4 & .6 \\
$y_1$ & .4 & .6 \\
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Note on Spacing

However, when you have multiple rows of unaligned data:

$x_1$ & .24 & .36 & .81 \\


$x_2$ & .44 & .63 & .32 \\
$x_3$ & .23 & .4 & .6 \\
$x_4$ &.64 & .32 & 12 \\
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Note on Spacing

However, when you have multiple rows of unaligned data:

$x_1$ & .24 & .36 & .81 \\


$x_2$ & .44 & .63 & .32 \\
$x_3$ & .23 & .4 & .6 \\
$x_4$ &.64 & .32 & 12 \\

It is incredibly difficult to find errors in your input file should one


occur, or should you need to go back later and edit your table.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX The table environment

You can place your table into the table environment. That will
allow you to assign each table a caption. Latex will also create a
running counter for your tables to generate a List of Tables
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX The table environment

You can place your table into the table environment. That will
allow you to assign each table a caption. Latex will also create a
running counter for your tables to generate a List of Tables

\begin{table}
\caption{Predicted Probabilities}
\begin{tabular}
. . .
\end{tabular}
\end{table}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Few Other Things

This should provide a good grasp on the basics of the tabular


environment. There are several resources out there that can
provide you with any details you may need.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Few Other Things

This should provide a good grasp on the basics of the tabular


environment. There are several resources out there that can
provide you with any details you may need.

. . . A good place to start is:


http://en.wikibooks.org/wiki/LaTeX/Tables.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Few Other Things

This should provide a good grasp on the basics of the tabular


environment. There are several resources out there that can
provide you with any details you may need.

. . . A good place to start is:


http://en.wikibooks.org/wiki/LaTeX/Tables.

Remember that you may have to load additional packages in the


front end of your document for some features.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Few Other Things

While it may seem a bit complicated to produce tables in LATEX,


they
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Few Other Things

While it may seem a bit complicated to produce tables in LATEX,


they
1 . . . look professional
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Few Other Things

While it may seem a bit complicated to produce tables in LATEX,


they
1 . . . look professional
2 . . . can save time in the long run
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Few Other Things

Both for STATA and R, commands for automated LATEX output


exist.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Few Other Things

Both for STATA and R, commands for automated LATEX output


exist.

In other words: You can . . .


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX A Few Other Things

Both for STATA and R, commands for automated LATEX output


exist.

In other words: You can . . .


Run your model(s)
Have the program generate the table for you
Copy/paste it into your file
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX STATA

Using the estout package in STATA:


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX STATA

Using the estout package in STATA:

run model1
estimates store model1
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX STATA

Using the estout package in STATA:

run model1
estimates store model1

run model2
estimates store model2
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX STATA

Using the estout package in STATA:

run model1
estimates store model1

run model2
estimates store model2

estout model1 model2, cells("b(star fmt(3))


se(fmt(3))") stats(N chi2, star(chi2)) style(tex)
label
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX STATA

. . . would produce the following output in STATA:

& model1 & & model2 &


& b & se& b &
Government Win & & & &
Afghanistan/Iraq War& 1.052* & 0.483& 0.940* &
Casualties & -35.934* & 15.574& -25.546* &
PM Approval & 0.001 & 0.012& 0.002 &
Rally & -1.571 & 0.874& &
Human Rights Act & -0.125 & 0.525& -0.439 &
Casualties*Approval & 0.989* & 0.472& 0.663* &
Ideology & -0.565 & 0.372& &
_cons & 0.598 & 0.704& 0.451 &
N & 299.000 & & 300.000 &
chi2 & 17.549* & & 11.458* &
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX STATA

. . . copy/pasting it into your LATEX file produces:

model1 model2
b se b se
Government Win
Afghanistan/Iraq War 1.052* 0.483 0.940* 0.475
Casualties -35.934* 15.574 -25.546* 11.526
PM Approval 0.001 0.012 0.002 0.012
Rally -1.571 0.874
Human Rights Act -0.125 0.525 -0.439 0.481
Casualties*Approval 0.989* 0.472 0.663* 0.335
Ideology -0.565 0.372
Constant 0.598 0.704 0.451 0.683
N 299 300
chi2 17.549* 11.458*
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Concluding Notes

The key is to be careful in declaring the specifications for your


table, and ensuring that all data gets entered properly and in
the correct location.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Making Tables in LATEX Concluding Notes

The key is to be careful in declaring the specifications for your


table, and ensuring that all data gets entered properly and in
the correct location.
You can automate much of the tedious process by letting your
statistical software do the work for you
Many pages on the web are dedicated to helping you draft
your table in LATEX if you ever get stuck
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Importing Figures

Importing figures into your LATEX is very simple.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Importing Figures

Importing figures into your LATEX is very simple.

Figures are made within the figure environment:

\begin{figure}[placement]
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Importing Figures

Importing figures into your LATEX is very simple.

Figures are made within the figure environment:

\begin{figure}[placement]

Where the placement option takes the following values:


h here (the exact location)
t at the top of the page
b at the bottom of the page
p on a special page for floating bodies
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Importing Figures

Importing figures into your LATEX is very simple.

Figures are made within the figure environment:

\begin{figure}[placement]

Where the placement option takes the following values:


h here (the exact location)
t at the top of the page
b at the bottom of the page
p on a special page for floating bodies

Note: the placement option is often left blank with the default
[tbp].
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Importing Figures

An example should clarify:


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Importing Figures

An example should clarify:

Say we to import a picture into our document. We could use the


following commands:

\begin{figure}
\centering
\includegraphics[scale=.5]{baby.jpg}
\caption{Cute Kid!}
\end{figure}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Importing Figures

. . . to get:

Figure: Cute Kid!


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Importing Figures

Remember to keep in mind that for this to work the file you want
to import must be located in the proper folder.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Importing Figures

Remember to keep in mind that for this to work the file you want
to import must be located in the proper folder.

This generally requires that it be stored in the same folder as the


.tex file
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

A Note on Importing Figures

Remember to keep in mind that for this to work the file you want
to import must be located in the proper folder.

This generally requires that it be stored in the same folder as the


.tex file Finally, note that his only works with certain file types.

While not an exhaustive list, some of the most common include


pdf, jpg, png, and eps.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Introduction to Bibliographies
Bibliographies are tedious work. LATEX will do much of the work for
you.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Introduction to Bibliographies
Bibliographies are tedious work. LATEX will do much of the work for
you.

For that you will need a BibTEXfile that contains the bibliographic
information on the works you may cite
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Introduction to Bibliographies
Bibliographies are tedious work. LATEX will do much of the work for
you.

For that you will need a BibTEXfile that contains the bibliographic
information on the works you may cite

The entries in the BibTEXfile will look something like this

@BOOK{Cox1993,
title = {Legislative Leviathan},
publisher = {University of California Press},
year = {1993},
author = {Cox, Gary W. and Matthew D. McCubbins},
address = {Berkeley}
}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Introduction to Bibliographies
Bibliographies are tedious work. LATEX will do much of the work for
you.

For that you will need a BibTEXfile that contains the bibliographic
information on the works you may cite

The entries in the BibTEXfile will look something like this

@BOOK{Cox1993,
title = {Legislative Leviathan},
publisher = {University of California Press},
year = {1993},
author = {Cox, Gary W. and Matthew D. McCubbins},
address = {Berkeley}
}

Where Cox1993 is what we call a Marker


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing with BibTEX

You will need to tell LATEX which citation style to use


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing with BibTEX

You will need to tell LATEX which citation style to use

Specifically, we recommend using the natbib package which


provides style files consistent with most of the major citation
formats (including APSA). To do this you need to add the
following lines to your preamble:

\usepackage{natbib}
\bibpunct{(}{)}{;}{a}{}{;}
\bibliographystyle{name of style file}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing with BibTEX

You will need to tell LATEX which citation style to use

Specifically, we recommend using the natbib package which


provides style files consistent with most of the major citation
formats (including APSA). To do this you need to add the
following lines to your preamble:

\usepackage{natbib}
\bibpunct{(}{)}{;}{a}{}{;}
\bibliographystyle{name of style file}

Note that the apsr style file included in the harvard and natbib
packages is NOT fully consistent with the APSA style manual.
Michael Fix and Susanne Schorpp provide a corrected version
available from the Society of Political Methodology.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing in LATEX

Back to our example


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing in LATEX

Back to our example

@BOOK{Cox1993,
title = {Legislative Leviathan},
publisher = {University of California Press},
year = {1993},
author = {Cox, Gary W. and Matthew D. McCubbins},
address = {Berkeley}
}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing in LATEX

Back to our example

@BOOK{Cox1993,
title = {Legislative Leviathan},
publisher = {University of California Press},
year = {1993},
author = {Cox, Gary W. and Matthew D. McCubbins},
address = {Berkeley}
}

Where Cox1993 is what we call a Marker


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing in LATEX

The marker can be used to cite the item within the document as
follows:
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing in LATEX

The marker can be used to cite the item within the document as
follows:

\cite{Cox1993}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing in LATEX

The marker can be used to cite the item within the document as
follows:

\cite{Cox1993}

. . . which will lead to the following output:


(Cox and McCubbins 1993)
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing in LATEX

Example: Typing this:

According to \citet{Cox1993}, as well as other work


on the subject \citep{Carmines1987,Kiewiet1988},
political science is a really important subject.

Will give you the following output:

According to Cox and McCubbins (1993), as well as other work on


the subject (Carmines, McIver, and Stimson 1987; Kiewiet and
McCubbins 1988), political science is a really important subject.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing in LATEX

When using BibTEX you generate a separate file with all your
references with the extension .bib
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Citing in LATEX

When using BibTEX you generate a separate file with all your
references with the extension .bib

Using a reference manager such as JabRef (or Zotero)


simplifies and automates this process
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Bibliographies with BibTEX

Finally, at the end of the document, where you would like


your reference pages to appear, you add the following line:

\newpage
\bibliography{filename.bib}
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Bibliographies with BibTEX

Finally, at the end of the document, where you would like your
reference pages to appear, you add the following line:

\newpage
\bibliography{filename.bib}

It is important to note that you will need to compile your


document again after running BibTEX, sometimes 2-3
additional times.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Bibliographies with BibTEX

Carmines, Edward G., John McIver, and James A. Stimson. 1987.


Unrealized Partisanship: A Theory of Dealignment. Journal of
Politics 49: 376400.
Cox, Gary W., and Matthew D. McCubbins. 1993. Legislative
Leviathan: Party Government in the House. Berkeley: University
of California Press.
Kiewiet, D. Roderick, and Mathew D. McCubbins. 1988.
Presidential Influence on Congressional Appropriations
Decisions. American Journal of Political Science 32: 713736.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Conclusions

We have covered a lot of material today.


Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Conclusions

We have covered a lot of material today.


We have walked through the basic structure of a proper input
file, the basic of typesetting text and math, and to make
tables and input graphics, and a bit on how to do
bibliographies.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Conclusions

We have covered a lot of material today.


We have walked through the basic structure of a proper input
file, the basic of typesetting text and math, and to make
tables and input graphics, and a bit on how to do
bibliographies.
Nearly everything you will ever need to do builds off of the
simply tools we have introduced.
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Conclusions

We have covered a lot of material today.


We have walked through the basic structure of a proper input
file, the basic of typesetting text and math, and to make
tables and input graphics, and a bit on how to do
bibliographies.
Nearly everything you will ever need to do builds off of the
simply tools we have introduced.
google is your friend. If you want to do something specific
with LATEX, chances are you can and someone has already
done so and posted the answer on the web (templates)
Outline Introduction The Basics Typesetting Text Typesetting Math Tables and Figures Bibliography References Closing Stat

Conclusions

We have covered a lot of material today.


We have walked through the basic structure of a proper input
file, the basic of typesetting text and math, and to make
tables and input graphics, and a bit on how to do
bibliographies.
Nearly everything you will ever need to do builds off of the
simply tools we have introduced.
google is your friend. If you want to do something specific
with LATEX, chances are you can and someone has already
done so and posted the answer on the web (templates)
Some initial costs, but high reward!

Potrebbero piacerti anche