1. Introduction
The TEX Document Structure
General Formatting
The Math Environment
A
Basic LTEX Typesetting
A Hands-On Seminar for Math Training Elective
Kiel F. Granada
Philippine Science High School – Main Campus
Session 1
July 17, 2010
KFGranada A
Basic L TEX Typesetting
2. Introduction A
What is L TEX?
The TEX Document Structure
Software Requirements
General Formatting
TEXMAKER Basics
The Math Environment
A
What is LTEX?
A document markup language and a document preparation system
for the TEX Typesetting Program.
KFGranada A
Basic L TEX Typesetting
3. Introduction A
What is L TEX?
The TEX Document Structure
Software Requirements
General Formatting
TEXMAKER Basics
The Math Environment
A
How LTEX Works
pdflatex
file.tex file.dvi file.ps file.pdf
latex dvips ps2pdf
source file outputs
KFGranada A
Basic L TEX Typesetting
4. Introduction A
What is L TEX?
The TEX Document Structure
Software Requirements
General Formatting
TEXMAKER Basics
The Math Environment
A
What do we need to create LTEX documents?
A TEX distribution like TEX Live!
A LTEX editor like TEXMAKER
A
KFGranada A
Basic L TEX Typesetting
5. Introduction A
What is L TEX?
The TEX Document Structure
Software Requirements
General Formatting
TEXMAKER Basics
The Math Environment
TEXMAKER Basics
TEXMAKER is a free cross-platform LTEX editor.
A
TEXMAKER Command Shortcuts
latex – F2 View DVI – F3
dvips – F4 View PS – F5
ps2pdf – F8 View PDF – F7
pdflatex – F6
KFGranada A
Basic L TEX Typesetting
6. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
The TEX File: Document Structure
documentclass [ options ]{ a r t i c l e }
preamble
%comments
b e g i n { document }
body
end { document }
KFGranada A
Basic L TEX Typesetting
7. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
General Syntax
command format
command [ o p t i o n s ] { a rgument }
environment markers
begin { environment }
content
end { e n v i r o n m e n t }
Achtung!
LTEX is case-sensitive.
A
KFGranada A
Basic L TEX Typesetting
8. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Exercise 1
Create your first LTEX document.
A
1. Launch TEXMAKER.
2. Create a new file.
3. Type the following basic structure:
documentclass{ a r t i c l e }
b e g i n { document}
end { document}
KFGranada A
Basic L TEX Typesetting
9. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Exercise 1
4. In the document’s body, list the first 10 prime numbers.
5. Save as Ex1.tex.
6. Compile to PDF by pressing F6 .
7. View PDF by pressing F7 .
KFGranada A
Basic L TEX Typesetting
10. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Document Classes
article – for short papers
report
book
letter
slides
beamer – for slide presentations
KFGranada A
Basic L TEX Typesetting
11. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Document Options
documentclass[options]{article}
Font Size – 10pt, 11pt, 12pt
Paper Size – a4paper, letterpaper
Orientation – landscape
Layout – twocolumn
Equation Display – fleqn, leqno
Example
d o c u m e n t c l a s s [ 1 1 pt , twocolumn ] { a r t i c l e }
KFGranada A
Basic L TEX Typesetting
12. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Preamble Contents
Document Labels
(title, subtitle, author, institute, date)
Package Declarations
Syntax: usepackage{package1, package2, · · · }
General Formatting and Declarations
(page margins, line spacing, etc.)
KFGranada A
Basic L TEX Typesetting
13. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Exercise 2
Create a “titled” LTEX document.
A
1. Launch TEXMAKER and type the basic structure.
2. In the preamble, set your own document labels.
Example:
t i t l e { B a s i c LaTeX , T y p e s e t t i n g }
a u t h o r { K i e l F . Granada }
d a t e { J u l y 20 , 2010}
KFGranada A
Basic L TEX Typesetting
14. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Exercise 2
3. In the document’s body, type:
maketitle
4. Save as Ex2.tex.
5. Compile and view.
Note
Close PDF reader before running pdflatex.
Follow-up Exercise
Try out the options: 11pt, 12pt, twocolumn
KFGranada A
Basic L TEX Typesetting
15. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Commonly Used Packages
amsmath, amsfonts, amssymb
amsthm
fullpage
multicol
setspace
Simplest Declaration
u s e p a c k a g e { amsmath , a m s f o n t s , amssymb , amsthm ,
fullpage , multicol , setspace }
KFGranada A
Basic L TEX Typesetting
16. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Page Numbers, Margins and Line Spacing
Handy Commands
pagestyle{empty}
setlength{topmargin}{-0.5in}
setlength{oddsidemargin}{-0.5in}
setlength{evensidemargin}{-0.5in}
setlength{textwidth}{7.27in}
setlength{textheight}{10.69in}
doublespacing
singlespacing
onehalfspacing
KFGranada A
Basic L TEX Typesetting
17. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Other Declarations
Handy Commands
definecolor{darkblue}{rgb}{0,0.08,0.45}
color{darkblue}
DeclareMathOperator{cis}{cis}
usepackage[none]{hyphenat}
KFGranada A
Basic L TEX Typesetting
18. Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment
Exercise 3
Modify Ex2.tex for its output to meet the following specifications:
Font size: 12 pt
Orientation: portrait
Layout: two-column
Margins: 1.5” left, 1” right, 1.25” top and bottom
Spacing: double-spaced
Hyphenation: on
KFGranada A
Basic L TEX Typesetting
19. Introduction
Paragraphs
The TEX Document Structure
Font Sizes and Styles
General Formatting
List Environments
The Math Environment
White Spaces, Lines and Indentation
Illustration: Source
It is a pleasure to thank those who read the first
draft of this paper and particularly to N. Katz who
patiently answered many questions in the course of
this project, listened to many false trails, and
together with Illusie read the original draft of
Chapter 3.
Several others made valuable suggestions and
criticisms of this paper,
especially Diamond,
de Shalit,
Ribet, Rubin and Taylor.
KFGranada A
Basic L TEX Typesetting
20. Introduction
Paragraphs
The TEX Document Structure
Font Sizes and Styles
General Formatting
List Environments
The Math Environment
White Spaces, Lines and Indentation
Illustration: Output
It is a pleasure to thank those who read the first draft of
this paper and particularly to N. Katz who patiently answered many
questions in the course of this project, listened to many false trails,
and together with Illusie read the original draft of Chapter 3.
Several others made valuable suggestions and criticisms of this
paper, especially Diamond, de Shalit, Ribet, Rubin and Taylor.
KFGranada A
Basic L TEX Typesetting
21. Introduction
Paragraphs
The TEX Document Structure
Font Sizes and Styles
General Formatting
List Environments
The Math Environment
White Spaces, Lines and Indentation
Handy Commands
white spaces – , : ;
spaces between paragraphs
– smallskip, medskip, bigskip, vspace{1in}
new line – newline or
new page – newpage
remove indentation – noindent
KFGranada A
Basic L TEX Typesetting
22. Introduction
Paragraphs
The TEX Document Structure
Font Sizes and Styles
General Formatting
List Environments
The Math Environment
Paragraph Alignments
begin { f l u s h l e f t } begin { center } begin { f l u s h r i g h t }
left center right
end { f l u s h l e f t } end { c e n t e r } end { f l u s h r i g h t }
left
center
right
KFGranada A
Basic L TEX Typesetting
23. Introduction
Paragraphs
The TEX Document Structure
Font Sizes and Styles
General Formatting
List Environments
The Math Environment
Font Sizes
{tiny text} text
{scriptsize text} text
{footnotesize text} text
{small text} text
{normalsize text} text
{large text} text
{Large text} text
{LARGE text} text
{huge text} text
{Huge text} text
KFGranada A
Basic L TEX Typesetting
24. Introduction
Paragraphs
The TEX Document Structure
Font Sizes and Styles
General Formatting
List Environments
The Math Environment
Font Styles
textbf{text} text
underline{text} text
textit{text} text
emph{text} text
texttt{text} text
KFGranada A
Basic L TEX Typesetting
25. Introduction
Paragraphs
The TEX Document Structure
Font Sizes and Styles
General Formatting
List Environments
The Math Environment
List Environments
enumerate b egin { enumerate }
1. Items i t e m numbered
2. are item items
end { e n u m e r a t e }
3. numbered.
itemize begin { itemize }
Items item b u l l e t e d
are item l i s t
bulleted. end { i t e m i z e }
description
begin { d e s c r i p t i o n }
Labels are item in d en ted
indented with item l a b e l s
the items. end { d e s c r i p t i o n }
KFGranada A
Basic L TEX Typesetting
26. Introduction
Paragraphs
The TEX Document Structure
Font Sizes and Styles
General Formatting
List Environments
The Math Environment
Exercise 4 – “Decode Me”
Create a LTEX document with the given output Ex4.pdf.
A
Font size is 12 pt and page has 1” margin in all sides.
KFGranada A
Basic L TEX Typesetting
27. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Math Modes
paragraph mode
$ math content $ begin{math}
math content
end{math}
display mode
$$ math content $$ begin{displaymath}
math content
end{displaymath}
KFGranada A
Basic L TEX Typesetting
28. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Math Modes
Example: Source
S i n c e $x = 1 $ and $y = −2$ , we can now e a s i l y g e t t h e
v a l u e o f $ z$ u s i n g any o f t h e t h r e e e q u a t i o n s .
From Eq . 1 , we have
$$ 2 ( 1 ) − ( −2) + z = 5 $$
$$2 + 2 + z = 5 $$
T h e r e f o r e , $z = 1 $ .
KFGranada A
Basic L TEX Typesetting
29. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Math Modes
Example: Output
Since x = 1 and y = −2, we can now easily get the value of
z using any of the three equations.
From Eq. 1, we have
2(1) − (−2) + z = 5
2+2+z =5
Therefore, z = 1.
KFGranada A
Basic L TEX Typesetting
30. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Exercise 5 – “Quick Decode”
Complex numbers√ of the form a + bi , where a and b are real
are
numbers and i = −1.
Tip
You may use TEXMAKER’s Math dropdown menu.
KFGranada A
Basic L TEX Typesetting
31. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Basic Operations
+
−
times
div
pm
KFGranada A
Basic L TEX Typesetting
32. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Relation Symbols
<
=
>
leq
geq
neq
KFGranada A
Basic L TEX Typesetting
33. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Subscripts and Superscripts
ˆ{ s u p e r s c r i p t }
{ subscript }
ˆa
b
KFGranada A
Basic L TEX Typesetting
34. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Fractions and Radicals
f r a c { n u m e r a t o r }{ d e n o m i n a t o r }
d f r a c { n u m e r a t o r }{ d e n o m i n a t o r }
sqrt { radicand}
sqrt [ index ]{ radicand}
KFGranada A
Basic L TEX Typesetting
35. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Exercise 6 - “Quick Encode”
Typeset the Quadratic Formula.
KFGranada A
Basic L TEX Typesetting
36. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Sets and Set Operations
mathbb{N, W, Z , Q, R} N, W, Z, Q, R
Re
f o r a l l x i n mathbb{Z} ∀x ∈ Z
e x i s t s y n o t i n mathbb {N} ∃y ∈ N
A cup B A∪B
A cap B A∩B
KFGranada A
Basic L TEX Typesetting
37. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Equations
begin{ equation }
n P r = d f r a c {n ! } { ( n−r ) ! } n!
end { e q u a t i o n } n Pr = (1)
(n − r )!
begin{ equation }
n C r = d f r a c {n ! } { ( n−r ) ! r ! }
n!
end { e q u a t i o n } n Cr = (2)
(n − r )!r !
b e g i n { e q u a t i o n ∗}
n C r = n C {n−r }
end { e q u a t i o n ∗} n Cr =n Cn−r
Note
The equation environment is not written inside $ $.
KFGranada A
Basic L TEX Typesetting
38. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Equation Arrays
b e g i n { e q n a r r a y ∗}
x &=& 5 − ( −1) + 3
&=& 5 + 1 + 3 x = 5 − (−1) + 3
x &=& 9 = 5+1+3
end { e q n a r r a y } x = 9
begin { eqnarray }
e q u a t i o n 1 & a l i g n h e r e &
e q u a t i o n 2 & a l i g n h e r e &
e q u a t i o n 3 & a l i g n h e r e&
end { e q n a r r a y }
KFGranada A
Basic L TEX Typesetting
39. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Theorems and Proofs
Example: Source
newtheorem {thm}{ Theorem }
b e g i n {thm } [ Fermat ’ s L a s t Theorem ]
The d i o p h a n t i n e e q u a t i o n $x ˆn + y ˆn = z ˆ n$
h a s no n o n t r i v i a l s o l u t i o n s f o r $n geq 3 $ .
end {thm}
begin { proof }
‘ ‘ I ha ve d i s c o v e r e d a t r u l y r e m a r k a b l e p r o o f
whi ch t h i s ma rgi n i s t o o s m a l l t o c o n t a i n . ”
end { p r o o f }
KFGranada A
Basic L TEX Typesetting
40. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Theorems and Proofs
Theorem (Fermat’s Last Theorem)
The diophantine equation x n + y n = z n has no nontrivial solutions
for n ≥ 3.
Proof.
“I have discovered a truly remarkable proof which this margin is
too small to contain.”
KFGranada A
Basic L TEX Typesetting
41. Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment
Assignment
Part 1
√
Encode the proof that 2 is irrational.
Part 2
Encode the derivation of the quadratic formula.
Send yourlastname1.tex and yourlastname2.tex to
kielgranada@yahoo.com by Friday, July 23, 2010, 5pm.
KFGranada A
Basic L TEX Typesetting