Basic Latex Typesetting - Session 1
-
Upload
kiel-granada -
Category
Education
-
view
6.201 -
download
1
description
Transcript of Basic Latex Typesetting - Session 1
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Basic LATEXTypesetting
A Hands-On Seminar for Math Training Elective
Kiel F. Granada
Philippine Science High School – Main Campus
Session 1
July 17, 2010
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
What is LATEX?Software RequirementsTEXMAKER Basics
What is LATEX?
A document markup language and a document preparation systemfor the TEXTypesetting Program.
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
What is LATEX?Software RequirementsTEXMAKER Basics
How LATEX Works
file.tex
source file
file.dvi file.ps file.pdf
outputs
latex dvips ps2pdf
pdflatex
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
What is LATEX?Software RequirementsTEXMAKER Basics
What do we need to create LATEX documents?
A TEX distribution like TEX Live!
A LATEX editor like TEXMAKER
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
What is LATEX?Software RequirementsTEXMAKER Basics
TEXMAKER Basics
TEXMAKER is a free cross-platform LATEX editor.
TEXMAKER Command Shortcuts
latex – F2
dvips – F4
ps2pdf – F8
pdflatex – F6
View DVI – F3
View PS – F5
View PDF – F7
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
The TEX File: Document Structure
\ document c l a s s [ op t i on s ]{ a r t i c l e }
preamble%comments
\ beg i n {document }
body
\end{document }
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
General Syntax
command format
\command [ op t i on s ]{ argument}
environment markers
\ beg i n { env i ronment }
con t en t
\end{ env i ronment }
Achtung!
LATEX is case-sensitive.
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
Exercise 1
Create your first LATEX document.
1. Launch TEXMAKER.
2. Create a new file.
3. Type the following basic structure:
\ documen tc l a s s{ a r t i c l e }
\ beg i n {document}
\ end{document}
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
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 Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
Document Classes
article – for short papers
report
book
letter
slides
beamer – for slide presentations
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
Document Options
\documentclass[options]{article}Font Size – 10pt, 11pt, 12pt
Paper Size – a4paper, letterpaper
Orientation – landscape
Layout – twocolumn
Equation Display – fleqn, leqno
Example
\ documen tc l a s s [ 1 1 pt , twocolumn ]{ a r t i c l e }
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
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 Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
Exercise 2
Create a “titled” LATEX document.
1. Launch TEXMAKER and type the basic structure.
2. In the preamble, set your own document labels.
Example:
\ t i t l e {Bas i c \LaTeX \ , T yp e s e t t i n g }\ author { K i e l F . Granada}\ date { Ju l y 20 , 2010}
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
Exercise 2
3. In the document’s body, type:
\maketitle4. 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 Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
Commonly Used Packages
amsmath, amsfonts, amssymb
amsthm
fullpage
multicol
setspace
Simplest Declaration
\ usepackage{amsmath , amsfonts , amssymb , amsthm ,f u l l p a g e , mu l t i c o l , s e t s p a c e }
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
Page Numbers, Margins and Line SpacingHandy 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 Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
Other DeclarationsHandy Commands
\definecolor{darkblue}{rgb}{0,0.08,0.45}\color{darkblue}
\DeclareMathOperator{\cis}{cis}
\usepackage[none]{hyphenat}
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Document ClassesOptionsPreamble Declarations
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 Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
ParagraphsFont Sizes and StylesList Environments
White Spaces, Lines and IndentationIllustration: 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 Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
ParagraphsFont Sizes and StylesList Environments
White Spaces, Lines and IndentationIllustration: Output
It is a pleasure to thank those who read the first draft ofthis paper and particularly to N. Katz who patiently answered manyquestions 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 thispaper, especially Diamond, de Shalit, Ribet, Rubin and Taylor.
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
ParagraphsFont Sizes and StylesList Environments
White Spaces, Lines and IndentationHandy Commands
white spaces – \, \: \;spaces between paragraphs– \smallskip, \medskip, \bigskip, \vspace{1in}new line – \newline or \\new page – \newpageremove indentation – \noindent
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
ParagraphsFont Sizes and StylesList Environments
Paragraph Alignments
\ beg in { f l u s h l e f t }l e f t
\end{ f l u s h l e f t }
\ beg in { c en t e r }c en t e r
\ end{ c en t e r }
\ beg in { f l u s h r i g h t }r i g h t
\ end{ f l u s h r i g h t }
left
center
right
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
ParagraphsFont Sizes and StylesList Environments
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 Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
ParagraphsFont Sizes and StylesList Environments
Font Styles
\textbf{text} text
\underline{text} text\textit{text} text
\emph{text} text
\texttt{text} text
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
ParagraphsFont Sizes and StylesList Environments
List Environments
enumerate
1. Items2. are3. numbered.
itemize
Itemsarebulleted.
description
Labels areindented with
the items.
\ beg in { enumerate }\ i t em numbered
\ i t em i t ems
\ end{ enumerate }
\ beg in { i t em i z e }\ i t em b u l l e t e d
\ i t em l i s t
\ end{ i t em i z e }
\ beg in { d e s c r i p t i o n }\ i t em i n d en t ed
\ i t em l a b e l s
\ end{ d e s c r i p t i o n }
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
ParagraphsFont Sizes and StylesList Environments
Exercise 4 – “Decode Me”
Create a LATEX document with the given output Ex4.pdf.Font size is 12 pt and page has 1” margin in all sides.
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Math Modes
paragraph mode
$ math content $ \begin{math}math content
\end{math}
display mode
$$ math content $$ \begin{displaymath}math content
\end{displaymath}
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Math ModesExample: Source
S inc e $x = 1$ and $y = −2$ , we can now e a s i l y ge t thev a l u e o f $z$ u s i n g any o f the t h r e e e qua t i o n s .
From Eq . 1 , we have
$$ 2(1) − (−2) + z = 5$$$$2 + 2 + z = 5$$
There fo re , $z = 1$ .
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Math ModesExample: Output
Since x = 1 and y = −2, we can now easily get the value ofz using any of the three equations.
From Eq. 1, we have
2(1) − (−2) + z = 5
2 + 2 + z = 5
Therefore, z = 1.
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Exercise 5 – “Quick Decode”
Complex numbers are of the form a + bi , where a and b are realnumbers and i =
√−1.
Tip
You may use TEXMAKER’s Math dropdown menu.
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Basic Operations
+−\ t imes\ d i v\pm
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Relation Symbols
<
=>
\ l e q\geq\neq
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Subscripts and Superscripts
ˆ{ s u p e r s c r i p t }{ s u b s c r i p t }
ˆab
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Fractions and Radicals
\ f r a c { numerator }{ denominator}\ d f r a c { numerator }{ denominator}
\ s q r t { r a d i c a nd }\ s q r t [ i ndex ]{ r a d i c a nd }
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Exercise 6 - “Quick Encode”
Typeset the Quadratic Formula.
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Sets and Set Operations
\mathbb{N, W, Z , Q, R}\Re
\ f o r a l l x \ i n \mathbb{Z}\ e x i s t s y \not \ i n \mathbb{N}
A \cup BA \ cap B
N,W,Z,Q,R
ℜ∀x ∈ Z
∃y 6∈ N
A ∪ B
A ∩ B
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Equations
\ beg i n { equa t i on }nP r = \ d f r a c {n !}{ ( n−r ) ! }
\ end{ equa t i on }
\ beg i n { equa t i on }nC r = \ d f r a c {n !}{ ( n−r ) ! r !}
\ end{ equa t i on }
\ beg i n { equa t i on ∗}nC r = nC {n−r }
\ end{ equa t i on ∗}
nPr =n!
(n − r)!(1)
nCr =n!
(n − r)!r !(2)
nCr =n Cn−r
Note
The equation environment is not written inside $ $.
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Equation Arrays
\ beg i n { eqna r r a y ∗}x &=& 5 − (−1) + 3\\&=& 5 + 1 + 3\\x &=& 9\end{ eqna r r a y }
\ beg i n { eqna r r a y }equa t i on1 &a l i g n he r e&\\equa t i on2 &a l i g n he r e&\\equa t i on3 &a l i g n he r e&\end{ eqna r r a y }
x = 5− (−1) + 3
= 5 + 1 + 3
x = 9
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Theorems and ProofsExample: Source
\newtheorem{thm}{Theorem }
\ beg i n {thm } [ Fermat ’ s La s t Theorem ]The d i ophan t i n e equa t i on $xˆn + yˆn = zˆn$has 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}
\ beg i n { p r oo f }‘ ‘ I have d i s c o v e r e d a t r u l y r ema rkab l e p r oo fwhich t h i s margin i s too sma l l to con t a i n . ”\end{ p r oo f }
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
Theorems and Proofs
Theorem (Fermat’s Last Theorem)
The diophantine equation xn + yn = zn has no nontrivial solutions
for n ≥ 3.
Proof.
“I have discovered a truly remarkable proof which this margin istoo small to contain.”
KFGranada Basic LATEXTypesetting
IntroductionThe TEX Document Structure
General FormattingThe Math Environment
Math ModesSome Math Symbols and CommandsUseful Math Structures
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 [email protected] by Friday, July 23, 2010, 5pm.
KFGranada Basic LATEXTypesetting