Mathematics In LaTeX

Christina Lee

Skill Pill

January 21, 2016

The basis for MathJax

Markdown uses

  • Github readme
  • jupyter notebooks
  • Wikipedia
  • Quora

Packages for Today

  • amsmath
  • amssymb
  • amsfonts

 

  • graphicx
  • float
  • subcaption

Entering A Math Environment

$    $

\[   \]

\begin{equation}
\end{equation}

Good for inline

Beware!

You need to close the environment! Else LaTeX will be mad

Unnumbered equations

Numbered Equations

To remember

  • Spaces don't work
    • use \; or \ ,
  • All text italics
    • use \text{ }

 

Your First Equation

f(x) = a x + b
f(x)=ax+bf(x) = a x + b
\[ f(x) = a x + b \]

Elementary Additions

Subscripts and Superscripts

x_a

x^a

e^{ikx}

e^ikx
x^a
xax^a
x_a
xax_a
e^{ikx}
eikxe^{ikx}
e^ikx
eikxe^ikx

Beware!

You need brackets if the sub/super script contains more than one character

Elementary Additions

Greek Letters

\alpha

\pi

\Psi

\epsilon

\varepsilon
\pi
π\pi
\alpha
α\alpha
\Psi
Ψ\Psi
\varepsilon
ε\varepsilon
\epsilon
ϵ\epsilon

Elementary Additions

Simple Functions

\frac{a}{b}    
    
\sqrt{x+y}

\sqrt[n]{x+y}

2 \pm 1 \geq 0
\sqrt{x+y}
x+y\sqrt{x+y}
\frac{a}{b}
ab\frac{a}{b}
\sqrt[n]{x+y}
x+yn\sqrt[n]{x+y}
2 \pm 1 \geq 0
2±102 \pm 1 \geq 0

Elementary Additions

Simple Functions

\cos \theta

\sin \theta

\mathrm{e}^{-t/\tau}

\vec{x} \cdot \vec{y}

1 \neq 2

\sin \theta
sinθ\sin \theta
\cos \theta
cosθ\cos \theta
\mathrm{e}^{-t/\tau}
et/τ\mathrm{e}^{-t/\tau}
\vec{x} \cdot \vec{y}
xy\vec{x} \cdot \vec{y}
1 \neq 2
121 \neq 2

Elementary Additions

Simple Functions

\int\limits_0^{\infty} f(x) \mathrm{d} x
0f(x)dx\int\limits_0^{\infty} f(x) \mathrm{d} x

\int\limits_{0}^{\infty} f(x) \mathrm{d}x

Get the d to stand up

Get the limits above the integration sign

Infinity

Elementary Additions

Parentheses

\left( \frac{x+y}{2} +
\left( z \right) \right)

( \big( \Big( \bigg( \Bigg(
( \big( \Big( \bigg( \Bigg(
(((((( \big( \Big( \bigg( \Bigg(

Danger!

\left( f(x) = a x +b

makes LaTeX very angry!

Intro Debugging Checklist

  • Ended the environment?
  • Closed each bracket { }?
  • Correct capitalization ?
  • Matched \left( and \right) ?
  • An empty line in the middle?
  • Break your equations into smaller lines so the compiler isolates where exactly the mistake is.

 

  • Compile smaller parts of the equation till you isolate what part of it is malfunctioning.
\]
x+

a
\]

makes LaTeX

mad

Finding out how to do something

  • Check your cheat sheet
  • Check Wikibooks- LaTeX- Mathematics
  • Search google
  • If you did it before, check in an old .tex file
  • Bother someone around you
  • Bother someone on the internet

LaTeXiT

On Mac

write snippits of LaTeX and drop them into presentations

First Problems Break!

Matrices

\begin{matrix}
1    &    0    \\
0    &    1   
\end{matrix}    

Next Column

Next Row

Matrices

\begin{matrix}
1    &    0    \\
0    &    1   
\end{matrix}    
\begin{matrix} 1 & 0 \\ 0 & 1 \end{matrix}
1001\begin{matrix} 1 & 0 \\ 0 & 1 \end{matrix}
\sigma^y =
\begin{pmatrix}
0    &    -i    \\
i    &    0  
\end{pmatrix}
\sigma^y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}
σy=(0ii0)\sigma^y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}
\begin{bmatrix}
a    &    b    \\
c    &    d    
\end{bmatrix}
\begin{bmatrix} a & b \\ c & d \end{bmatrix}
[abcd]\begin{bmatrix} a & b \\ c & d \end{bmatrix}

Math Fonts

\mathrm{ABC def}

\mathit{ABC def}

\mathbf{ABC def}    

\mathfrak{ABC def}

\mathcal{ABC def}

\mathbb{ABC def}

    
\mathrm{ABC def}
ABCdef\mathrm{ABC def}
\mathit{ABC def}
ABCdef\mathit{ABC def}
\mathbf{ABC def}
ABCdef\mathbf{ABC def}
\mathfrak{ABC def}
ABCdef\mathfrak{ABC def}
\mathbb{ABC def}
ABCdef\mathbb{ABC def}
\mathcal{ABC def}
ABCdef\mathcal{ABC def}

requires mathsymb or amsfonts

Multi-Line Environment

\begin{align}
f(x) =& 1+ x^2 + x^3 \\
  &+x^4 + x^5 
\end{align}

Multi-Line Environment

\begin{align}
f(x) =& 1+ x^2 + x^3 \nonumber \\
  &+x^4 + x^5 
\end{align}

Multi-Line Environment

\begin{subequations}
Maxwell's Equations
\begin{align}
B &= - \nabla \times E \\
E &= \nabla \times B - 4 \pi j
\end{align}
\end{subequations}

Multi-Line Environment

\Theta(x)=
\begin{cases}
0  &  \text{if } x<0 \\
1  &  \text{if } x\geq 0
\end{cases}

Boxed

\boxed{
\cal{H} = \frac{\hbar^2}{2m}\nabla^2 + V(x,y)
}

    

Second Problem Break

\{d_i, d_j^{\dagger} \} = (-1)^{i+j-2} \prod\limits_{n=1}^{i-1} \prod\limits_{m=1}^{j-1} \sigma_n^z S_i ^- \sigma_m^z S_j^+ + (-1)^{i+j-2} \prod\limits_{n=1}^{i-1} \prod\limits_{m=1}^{j-1} \sigma_m^z S_j^+ \sigma_n^z S_i^-
{di,dj}=(1)i+j2n=1i1m=1j1σnzSiσmzSj++(1)i+j2n=1i1m=1j1σmzSj+σnzSi\{d_i, d_j^{\dagger} \} = (-1)^{i+j-2} \prod\limits_{n=1}^{i-1} \prod\limits_{m=1}^{j-1} \sigma_n^z S_i ^- \sigma_m^z S_j^+ + (-1)^{i+j-2} \prod\limits_{n=1}^{i-1} \prod\limits_{m=1}^{j-1} \sigma_m^z S_j^+ \sigma_n^z S_i^-
= (-1)^{i+j-2} \left( \prod\limits_{k=i+1}^{j-1} \left( \prod\limits_{n=1}^{i-1} \prod\limits_{m=1}^{i-1} \sigma_n^z \sigma_m^z \right) S_i^- \sigma_i^z \sigma_k^z S_j^+ + \prod\limits_{k=i+1}^{j-1} \left( \prod\limits_{n=1}^{i-1} \prod\limits_{m=1}^{i-1} \sigma_m^z \sigma_n^z \right) S_j^+ \sigma_k^z \sigma_i^z S_i^- \right)
=(1)i+j2(k=i+1j1(n=1i1m=1i1σnzσmz)SiσizσkzSj++k=i+1j1(n=1i1m=1i1σmzσnz)Sj+σkzσizSi)= (-1)^{i+j-2} \left( \prod\limits_{k=i+1}^{j-1} \left( \prod\limits_{n=1}^{i-1} \prod\limits_{m=1}^{i-1} \sigma_n^z \sigma_m^z \right) S_i^- \sigma_i^z \sigma_k^z S_j^+ + \prod\limits_{k=i+1}^{j-1} \left( \prod\limits_{n=1}^{i-1} \prod\limits_{m=1}^{i-1} \sigma_m^z \sigma_n^z \right) S_j^+ \sigma_k^z \sigma_i^z S_i^- \right)
=(-1)^{i+j-2} \prod\limits_{k=i+1}^{j-1} \left( - S_i^- \sigma_k^z S_j^+ + S_j^+ \sigma_k^z S_i^- \right) =0
=(1)i+j2k=i+1j1(SiσkzSj++Sj+σkzSi)=0=(-1)^{i+j-2} \prod\limits_{k=i+1}^{j-1} \left( - S_i^- \sigma_k^z S_j^+ + S_j^+ \sigma_k^z S_i^- \right) =0

For A Cookie!

Yes ;) That's part of my research notes right now.

Figures in LaTeX

Graphics

Use the package graphicx

Available image types

  • EPS
  • JPG
  • PNG
  • PDF

Graphics

Our first image! 

\includegraphics{picture.jpg}

Graphics

Now a better version!

\includegraphics[width=\textwidth]{picture.jpg}

\includegraphics[scale=0.5]{picture.jpg}

Control how large you want the image.

I prefer width to scale.

Tables

\begin{tabular}{c c}
1    &    1    \\
2    &    2    
\end{tabular}

My First Table!

Tables

\begin{tabular}{c c}
1    &    1    \\
2    &    2    
\end{tabular}

Align to the center

Other options r or l

New Line. 

Don't have one on the last line

New column

Tables

\begin{tabular}{|| c | c | c ||}
\hline
1    &    1   &  1 \\ 
2    &    2   &  2\\
\hline    
\end{tabular}

Adds a horizontal line

Location of vertical lines

Tables

\begin{tabular}{| c | c |}
\multicolumn{2}{|c|}{Columns}\\
\hline
1    &  1  \\
2    &  2  \\
\end{tabular}

Span multiple columns

\multicolumn{number of columns}

{style}{text}

Yeah, Yeah, Yeah... But I don't want to write it out...

TexMaker

Internet

Matlab

Excel to LaTeX addon

Figures

A Basic Figure

\begin{figure}

\includegraphics
[width=\textwidth]
{picture.jpg}

\end{figure}

Figures

Now a better version!

\begin{figure}

\includegraphics
[width=\textwidth]
{picture.jpg}

\caption{An Image}
\label{FIRE}

\end{figure}

Adding a Caption

Figures

On To Two Images!

\begin{figure}
\begin{subfigure}{.5\textwidth}
	\includegraphics[width=\textwidth]{bg4.jpg}
	\caption{fire}
	\label{FIRE}
\end{subfigure}
\begin{subfigure}{.5\textwidth}
	\includegraphics[width=\textwidth]{dragon.jpg}
	\caption{dragon}
	\label{dragon}
\end{subfigure}
\caption{Two Images4}
\label{ims}
\end{figure}

Set the width of each figure block

Can label and caption individually

Requires package subcaption

Figures

Positioning on the page

\begin{figure}[!b]
	\includegraphics[width=\textwidth]{pic.jpg}
	\caption{A fantasy picture forced to the bottom}
	\label{fig:picb}
\end{figure}

Location

on the page. 

h here
H HERE!!!!
b bottom
t top
p float page
! I MEAN IT!

Requires Float Package

Figures

Figure Wrapping

  \begin{wrapfigure}{r}{.5\textwidth}
		\includegraphics[width=.49\textwidth]{bg4.jpg} 
  		\caption{A wrapped image}
  		\label{fig:wrap}
  \end{wrapfigure}

Set the width of each figure block

Where on page

Can be r,l

i,o for twoside doc

Requires package wrapfig

Figures

Figure Listing

\listoffigures

Referencing

\begin{equation}
\label{eq:myequation}
f(x) = a x+b
\end{equation}
Lets Reference Equation~\ref{eq:myequation}
Made with Slides.com