Basics of Latex

Basic Latex Skeleton

\documentclass[11pt]{article}
\usepackage[margin=2cm]{geometry}
\geometry{letterpaper}
\usepackage{graphicx, amssymb, latexsym, amsmath}
\usepackage{epstopdf}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}
\title{My Article}
\author{Aditya Bhargava}
\begin{document}
\maketitle
\section{My Section}
\subsection{My Subsection}
% Your text here
\end{document}

Create a PDF Out Of a Latex Source File

If you don't have latex and you're on a mac, get gwTeX:
http://ii2.sourceforge.net/tex-index.html

latex [source file]

Comments

Start with a %.

Italics

\emph{ this is italicized }

Bold

\textbf{ this is in bold }

Today's Date

\today

En Dash and Em Dash

Double Hyphens -- en dash
Triple Hyphens --- em dash

Force a Line Break

Two backslashes:
\\

Or specify the amount of vertical space (line height):
\\[24pt]

Force a New Page / Page Break

\newpage

Inline Math

Is placed between two $. For example:

$a$
$\infty$
$(u,v)$
$\lim_{x \to \infty} f(x)$

Displayed Math

Math that's on it's own line is placed between \[ and \]. Example:

\[
\frac{f(x) - 1}{4}
\]

Infinity Symbol

Must go in either inline math or displayed math.

\infty

Fractions

Must go in either inline math or displayed math.

\frac{numerator}{denominator}

Square Root

Used in either inline or displayed math.

\sqrt{5}

Multiplication

If you want an explicit dot or 'x' between two numbers to show that they're being multiplied use '\cdot' or '\times', respectively:

$a \times b$

Superscripts and Subscripts

Use
^{...} for superscripts.
_{...} for subscripts.

Examples:

$a^{2}$ % prints a squared (a ^ 2).
$a_{10}$ % prints a10, with 10 as a subscript

Binomial Coefficients

Use '\choose' or '\binom'. For example, here's n choose 2:

$n \choose {2}$
$\binom{n}{2}$

Congruences (The ≡ Character)

Aka the symbol with three lines in the equals sign.

\equiv

Theta

Print out a lowercase theta with:
\theta


Print out an uppercase theta with:
\Theta

Products and Summations

Use '\sum' and '\prod'. Example:
\sum_{i=1}^{n} x_{i}^{2}


Remember that _{...} is for subscripts and ^{...} is for superscripts. So this is a summation of xi^2 for all i from 1 to n.

Use Text Inside a Formula

Use the \mbox command:

\[
a = b, \mbox{ by assumption }
\]

Insert Curly Braces

You have to escape them:

\{ ... \}

Binary Relations

Less than / Greater than / Equals
< / > / =

Less Than or Equal To / Greater Than or Equal To
\le
\ge

In (∈)
\in

Approximately (≈)
\approx

Similar (∼)
\sim

Congruent (≅)
\cong

Subset (⊂)
\subset

Subset Of or Equal To (⊆)
\subseteq

Therefore
\therefore

Most of the above commands can be negated by putting an 'n' in front. For example, not equal to is:
\neq

Plus or Minus
\pm

Arrows

Right arrow
\rightarrow or \to

Path, or Leads To
\leadsto

Empty Set

\emptyset

Negates or Not

\neg

For All (Universal Quantifier)

\forall

Exists (Universal Quantifier)

\exists

Backslash

\backslash

Floor

\lfloor --stuff to floor-- \rfloor

Ceiling

\lceil --stuff to ceil-- \rceil

Union

\cup

Intersection

\cap

Typewriter Font (for code)

\texttt{ some text }

Small Caps

\textsc{ some text }

Bullet Point

\textbullet

Double Quotes Left

Put two single left quotes (aka backticks...they share a key with the ~):

``

Double Right Quotes

Put two single right quotes (normal single quotes):

''

Change Font Size

Small Type:
\scriptsize

Normal Type:
\normalsize

Large Font:
\Large

Huge Font:
\huge

Biggest Possible:
\Huge

You can also use these inside another command, like so:

\title{\Large Algorithms -- HW 8}

Text Alignment

You can choose between flushright, flushleft, and center:

\begin{flushright}
some text
\end{flushright}

Horizontal Space

Use '\hspace'. This is equal to about one letter:

\hspace{2pt}

Tabbing

To use tabs, you have to use the tabbing environment:
\begin{tabbing}

\end{tabbing}


Tab stops are set with the \= command, and \> moves to the next tab stop. Example:

\begin{tabbing}
If \= it's raining \\
\> then \= put on boots,\\
\> \> take hat;\\
\> or \> smile. \\
Leave house.
\end{tabbing}


This produces:
If it's raining
    then put on boots
      take hat;
    or  smile.
Leave house.

Tilde

\sim

Matrices

\[ \left( \begin{array}{ccc}
a & b & c \\
d & e & f \\
g & h & i \end{array} \right)\]

Matrices

In this code the 'ccc' represents the number of columns of the matrix:

\[
M =
\left[ {\begin{array}{cc}
x & y \\
z & w \\
\end{array} } \right]
\]

Summations

\sum\limits_{i=0}^n something

Integrals

\int_0^{2 \pi} \! [something] \,

Set of Real Numbers (R)

\usepackage{amssymb}
\mathbb{R}

Including Image (eps) Files In Your Document

\usepackage{epsfig}
\epsfig{file=figs/fig01.eps,width=0.9\linewidth,clip=}

Plus or Minus

\pm

Perpendicular

\perp

Two Matrices On The Same Line

\begin{equation}
\begin{bmatrix} 1 & 2 \\ 3 & 4\end{bmatrix}
\begin{bmatrix} 1 & 2 \\ 3 & 4\end{bmatrix}
\end{equation}

Determinants

\begin{equation}
\begin{vmatrix} ta & tb \\ c & d\end{vmatrix} =
t * egin{vmatrix} a & b \\ c & d\end{vmatrix}
\end{equation}

Small inline matrices

$M = \left[ \begin{smallmatrix} a&b\\ c&d \end{smallmatrix} \right]$

Limits

\lim_{x \to +\infty}