Basic L TEX Typesetting: A Hands-On Seminar For Math Training Elective

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Introduction

The TEX Document Structure


General Formatting
The Math Environment

Basic LATEX Typesetting


A Hands-On Seminar for Math Training Elective

Kiel F. Granada

Philippine Science High School Main Campus

Session 1
July 17, 2010

KFGranada Basic LATEX Typesetting


Introduction
What is LATEX?
The TEX Document Structure
Software Requirements
General Formatting
TEXMAKER Basics
The Math Environment

What is LATEX?

A document markup language and a document preparation system


for the TEX Typesetting Program.

KFGranada Basic LATEX Typesetting


Introduction
What is LATEX?
The TEX Document Structure
Software Requirements
General Formatting
TEXMAKER Basics
The Math Environment

How LATEX Works

pdflatex

file.tex file.dvi file.ps file.pdf


latex dvips ps2pdf
source file outputs

KFGranada Basic LATEX Typesetting


Introduction
What is LATEX?
The TEX Document Structure
Software Requirements
General Formatting
TEXMAKER Basics
The Math Environment

What do we need to create LATEX documents?

A TEX distribution like TEX Live!


A LATEX editor like TEXMAKER

KFGranada Basic LATEX Typesetting


Introduction
What is LATEX?
The TEX Document Structure
Software Requirements
General Formatting
TEXMAKER Basics
The Math Environment

TEXMAKER Basics

TEXMAKER is a free cross-platform LATEX editor.

TEXMAKER Command Shortcuts


latex F2 View DVI F3
dvips F4 View PS F5
ps2pdf F8 View PDF F7
pdflatex F6

KFGranada Basic LATEX Typesetting


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 Basic LATEX Typesetting


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!
LATEX is case-sensitive.

KFGranada Basic LATEX Typesetting


Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment

Exercise 1

Create your first LATEX document.

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 Basic LATEX Typesetting


Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment

Exercise 1

4. In the documents 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 LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment

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 { 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 Basic LATEX Typesetting


Introduction
Document Classes
The TEX Document Structure
Options
General Formatting
Preamble Declarations
The Math Environment

Exercise 2

3. In the documents 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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting
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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


Introduction
Paragraphs
The TEX Document Structure
Font Sizes and Styles
General Formatting
List Environments
The Math Environment

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 LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 numbersare of the form a + bi , where a and b are real


numbers and i = 1.

Tip
You may use TEXMAKERs Math dropdown menu.

KFGranada Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


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
6 N
A \ cup B AB
A \ cap B AB

KFGranada Basic LATEX Typesetting


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 ! } { ( nr ) ! } 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 ! } { ( nr ) ! 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 {nr }
\ end { e q u a t i o n } n Cr =n Cnr

Note
The equation environment is not written inside $ $.
KFGranada Basic LATEX Typesetting
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 Basic LATEX Typesetting


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 Basic LATEX Typesetting


Introduction
Math Modes
The TEX Document Structure
Some Math Symbols and Commands
General Formatting
Useful Math Structures
The Math Environment

Theorems and Proofs

Theorem (Fermats 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 Basic LATEX Typesetting


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 Basic LATEX Typesetting

You might also like