. . . . . . 
LATEX Basics 
Kristen Sauby, Rosana Zenil-Lopez, Gabriela Blohm 
Department of Biology 
University of Florida 
April 1, 2011 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 1 / 29
. . . . . . 
What is LATEX? 
a programming language used to create attractive and 
consistently formatted documents 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 2 / 29
. . . . . . 
Why would you want to use LATEX? 
consistent formatting 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 3 / 29
. . . . . . 
Why would you want to use LATEX? 
consistent formatting 
fancy fonts 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 3 / 29
. . . . . . 
Why would you want to use LATEX? 
consistent formatting 
fancy fonts 
make posters, presentations, and other types of 
documents 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 3 / 29
. . . . . . 
Why would you want to use LATEX? 
consistent formatting 
fancy fonts 
make posters, presentations, and other types of 
documents 
automatic numbering of sections,
gures, tables, and 
formulas 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 3 / 29
. . . . . . 
Why would you want to use LATEX? 
consistent formatting 
fancy fonts 
make posters, presentations, and other types of 
documents 
automatic numbering of sections,
gures, tables, and 
formulas 
creation of a bibliography and index 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 3 / 29
. . . . . . 
Why would you want to use LATEX? 
!"##$ %"##& '"##( )"##g 
*"##+ ,"##- ."##g /"##g 
D. Taraborelli !2008", The Beauty of LATEX 
Some rights reserved. ##$%&$'( 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 4 / 29
. . . . . . 
Why would you want to use LATEX? 
include, align, and number attractive mathematical 
formulas 
n! 
k!(n  k)! 
= 
( 
n 
k 
) 
(1) 
lim 
x!1 
exp(x) = 0 (2) 
Am;n = 
 
 
a1;1 a1;2    a1;n 
a2;1 a2;2    a2;n 
... 
... 
. . . ... 
am;1 am;2    am;n 
 
 
(3) 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 5 / 29
. . . . . . 
Why would you want to use LATEX? 
Embed R code and objects 
 sample(100, 5) 
[1] 85 79 82 62 73 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 6 / 29
. . . . . . 
Why would you want to use LATEX? 
Embed R code and objects 
 library(xtable) 
 counts - c(18, 17, 15, 20, 10, 20, 25, 13, 12) 
 outcome - gl(3, 1, 9) 
 treatment - gl(3, 3) 
 print(xtable(data.frame(treatment, outcome, counts))) 
treatment outcome counts 
1 1 1 18.00 
2 1 2 17.00 
3 1 3 15.00 
4 2 1 20.00 
5 2 2 10.00 
6 2 3 20.00 
7 3 1 25.00 
8 3 2 13.00 
9 3 3 12.00 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 7 / 29
We'll Work Through an Example Together 
Go to latexlab.org or open the example .tex
le on your 
computer. 
. . . . . . 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 8 / 29
We'll Work Through an Example Together 
Go to latexlab.org or open the example .tex
le on your 
computer. 
We'll use this example document to understand better the 
structure of LATEX documents. 
. . . . . . 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 8 / 29
We'll Work Through an Example Together 
Go to latexlab.org or open the example .tex
le on your 
computer. 
We'll use this example document to understand better the 
structure of LATEX documents. 
In LATEX lab, select split (near the bottom left of the 
page) 
this lets us see the .tex document and the ouput 
document (the compiled document) in the same 
window. 
. . . . . . 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 8 / 29
What types of documents can you make in LATEX? 
. . . . . . 
Classes of LATEX documents include: 
article 
book 
beamer (for presentations) 
and more 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 9 / 29
. . . . . . 
LATEX Document Structure 
preamble (commands that aect the entire document) 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
. . . . . . 
LATEX Document Structure 
preamble (commands that aect the entire document) 
top matter (title, date, authors, etc.) 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
. . . . . . 
LATEX Document Structure 
preamble (commands that aect the entire document) 
top matter (title, date, authors, etc.) 
the written document (abstract, sections, etc.) 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
. . . . . . 
LATEX Document Structure 
preamble (commands that aect the entire document) 
top matter (title, date, authors, etc.) 
the written document (abstract, sections, etc.) 
appendices 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
. . . . . . 
LATEX Document Structure 
preamble (commands that aect the entire document) 
top matter (title, date, authors, etc.) 
the written document (abstract, sections, etc.) 
appendices 
table of contents 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
. . . . . . 
LATEX Document Structure 
preamble (commands that aect the entire document) 
top matter (title, date, authors, etc.) 
the written document (abstract, sections, etc.) 
appendices 
table of contents 
bibliography 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
. . . . . . 
LATEX Document Structure 
preamble (commands that aect the entire document) 
top matter (title, date, authors, etc.) 
the written document (abstract, sections, etc.) 
appendices 
table of contents 
bibliography 
comments (i.e., text that does not show up in the
nal document) 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
. . . . . . 
LATEX Document Structure 
Begin your document using the following command: 
ndocumentstyle[options]fclassg 
where options include such speci
cations as 
font size 
number of columns 
paper size 
and the class is the type of document that you want to 
make 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 11 / 29
. . . . . . 
LATEX Document Structure 
Next list the packages to be used: 
nusepackage[options]fpackageg 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 12 / 29
. . . . . . 
LATEX Document Structure 
The preamble can also include: 
title and author information 
date 
font speci
cation 
and more 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 13 / 29
. . . . . . 
LATEX Document Structure 
After completing the preamble begin the document: 
nbeginfdocumentg 
At the end of the document you must include the 
command: 
nendfdocumentg 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 14 / 29
. . . . . . 
Compiling Your LATEX 
Once you have the document set up, you can then add 
text,
gures, formulas, tables, etc. to the document. 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 15 / 29
. . . . . . 
Types of Functions in LATEX 
Ways to organize or include data: 
verbatim 
itemize 
enumerate
gure 
table 
tabular 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 16 / 29
. . . . . . 
Types of Functions in LATEX 
Ways to organize or include data: 
verbatim 
itemize 
enumerate
gure 
table 
tabular 
Try adding a bulleted list to the example .tex
le. 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 16 / 29
. . . . . . 
Types of Functions 
You can also include comments (that don't appear in the
nal, compiled document) by using the % symbol. 
Anything after the % symbol will not be evaluated by 
LATEX when compiling the document. 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 17 / 29
. . . . . . 
Including Math in LATEX 
Note that our example .tex
le includes 
nusepackagefamsmathg in the preamble. 
This package lets us include mathematical formulas in our 
LATEX document. 
Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 18 / 29
. . . . . . 
Including Math in LATEX 
The example .tex
le includes this formula: 
nbeginfaligng 
E = mc^2 nn 
m = nfracfm 0gfnsqrtf1-nfracfv^2gfc^2ggg 
nendfaligng 
The aligncommand is speci

LaTeX Basics

  • 1.
    . . .. . . LATEX Basics Kristen Sauby, Rosana Zenil-Lopez, Gabriela Blohm Department of Biology University of Florida April 1, 2011 Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 1 / 29
  • 2.
    . . .. . . What is LATEX? a programming language used to create attractive and consistently formatted documents Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 2 / 29
  • 3.
    . . .. . . Why would you want to use LATEX? consistent formatting Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 3 / 29
  • 4.
    . . .. . . Why would you want to use LATEX? consistent formatting fancy fonts Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 3 / 29
  • 5.
    . . .. . . Why would you want to use LATEX? consistent formatting fancy fonts make posters, presentations, and other types of documents Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 3 / 29
  • 6.
    . . .. . . Why would you want to use LATEX? consistent formatting fancy fonts make posters, presentations, and other types of documents automatic numbering of sections,
  • 7.
    gures, tables, and formulas Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 3 / 29
  • 8.
    . . .. . . Why would you want to use LATEX? consistent formatting fancy fonts make posters, presentations, and other types of documents automatic numbering of sections,
  • 9.
    gures, tables, and formulas creation of a bibliography and index Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 3 / 29
  • 10.
    . . .. . . Why would you want to use LATEX? !"##$ %"##& '"##( )"##g *"##+ ,"##- ."##g /"##g D. Taraborelli !2008", The Beauty of LATEX Some rights reserved. ##$%&$'( Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 4 / 29
  • 11.
    . . .. . . Why would you want to use LATEX? include, align, and number attractive mathematical formulas n! k!(n k)! = ( n k ) (1) lim x!1 exp(x) = 0 (2) Am;n =   a1;1 a1;2 a1;n a2;1 a2;2 a2;n ... ... . . . ... am;1 am;2 am;n   (3) Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 5 / 29
  • 12.
    . . .. . . Why would you want to use LATEX? Embed R code and objects sample(100, 5) [1] 85 79 82 62 73 Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 6 / 29
  • 13.
    . . .. . . Why would you want to use LATEX? Embed R code and objects library(xtable) counts - c(18, 17, 15, 20, 10, 20, 25, 13, 12) outcome - gl(3, 1, 9) treatment - gl(3, 3) print(xtable(data.frame(treatment, outcome, counts))) treatment outcome counts 1 1 1 18.00 2 1 2 17.00 3 1 3 15.00 4 2 1 20.00 5 2 2 10.00 6 2 3 20.00 7 3 1 25.00 8 3 2 13.00 9 3 3 12.00 Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 7 / 29
  • 14.
    We'll Work Throughan Example Together Go to latexlab.org or open the example .tex
  • 15.
    le on your computer. . . . . . . Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 8 / 29
  • 16.
    We'll Work Throughan Example Together Go to latexlab.org or open the example .tex
  • 17.
    le on your computer. We'll use this example document to understand better the structure of LATEX documents. . . . . . . Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 8 / 29
  • 18.
    We'll Work Throughan Example Together Go to latexlab.org or open the example .tex
  • 19.
    le on your computer. We'll use this example document to understand better the structure of LATEX documents. In LATEX lab, select split (near the bottom left of the page) this lets us see the .tex document and the ouput document (the compiled document) in the same window. . . . . . . Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 8 / 29
  • 20.
    What types ofdocuments can you make in LATEX? . . . . . . Classes of LATEX documents include: article book beamer (for presentations) and more Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 9 / 29
  • 21.
    . . .. . . LATEX Document Structure preamble (commands that aect the entire document) Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
  • 22.
    . . .. . . LATEX Document Structure preamble (commands that aect the entire document) top matter (title, date, authors, etc.) Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
  • 23.
    . . .. . . LATEX Document Structure preamble (commands that aect the entire document) top matter (title, date, authors, etc.) the written document (abstract, sections, etc.) Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
  • 24.
    . . .. . . LATEX Document Structure preamble (commands that aect the entire document) top matter (title, date, authors, etc.) the written document (abstract, sections, etc.) appendices Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
  • 25.
    . . .. . . LATEX Document Structure preamble (commands that aect the entire document) top matter (title, date, authors, etc.) the written document (abstract, sections, etc.) appendices table of contents Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
  • 26.
    . . .. . . LATEX Document Structure preamble (commands that aect the entire document) top matter (title, date, authors, etc.) the written document (abstract, sections, etc.) appendices table of contents bibliography Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
  • 27.
    . . .. . . LATEX Document Structure preamble (commands that aect the entire document) top matter (title, date, authors, etc.) the written document (abstract, sections, etc.) appendices table of contents bibliography comments (i.e., text that does not show up in the
  • 28.
    nal document) Sauby,Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 10 / 29
  • 29.
    . . .. . . LATEX Document Structure Begin your document using the following command: ndocumentstyle[options]fclassg where options include such speci
  • 30.
    cations as fontsize number of columns paper size and the class is the type of document that you want to make Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 11 / 29
  • 31.
    . . .. . . LATEX Document Structure Next list the packages to be used: nusepackage[options]fpackageg Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 12 / 29
  • 32.
    . . .. . . LATEX Document Structure The preamble can also include: title and author information date font speci
  • 33.
    cation and more Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 13 / 29
  • 34.
    . . .. . . LATEX Document Structure After completing the preamble begin the document: nbeginfdocumentg At the end of the document you must include the command: nendfdocumentg Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 14 / 29
  • 35.
    . . .. . . Compiling Your LATEX Once you have the document set up, you can then add text,
  • 36.
    gures, formulas, tables,etc. to the document. Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 15 / 29
  • 37.
    . . .. . . Types of Functions in LATEX Ways to organize or include data: verbatim itemize enumerate
  • 38.
    gure table tabular Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 16 / 29
  • 39.
    . . .. . . Types of Functions in LATEX Ways to organize or include data: verbatim itemize enumerate
  • 40.
    gure table tabular Try adding a bulleted list to the example .tex
  • 41.
    le. Sauby, Zenil,Blohm (U of Fl) LATEXBasics April 1, 2011 16 / 29
  • 42.
    . . .. . . Types of Functions You can also include comments (that don't appear in the
  • 43.
    nal, compiled document)by using the % symbol. Anything after the % symbol will not be evaluated by LATEX when compiling the document. Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 17 / 29
  • 44.
    . . .. . . Including Math in LATEX Note that our example .tex
  • 45.
    le includes nusepackagefamsmathgin the preamble. This package lets us include mathematical formulas in our LATEX document. Sauby, Zenil, Blohm (U of Fl) LATEXBasics April 1, 2011 18 / 29
  • 46.
    . . .. . . Including Math in LATEX The example .tex
  • 47.
    le includes thisformula: nbeginfaligng E = mc^2 nn m = nfracfm 0gfnsqrtf1-nfracfv^2gfc^2ggg nendfaligng The aligncommand is speci