LaTeX

First

$ sudo apt install texstudio

Terminology

What is LaTeX?

LaTeX is a markup language and compiler that typesets your document and generates a PDF.

Motivation

De-Motivation

_

Our first document

Let’s fire up texstudio

Note: You can create and compile your document without texstudio (I use vi and Makefiles)

But, texstudio has some useful features.

The pdflatex compiler

Let’s compile our latex without texstudio.

LaTeX commands

LaTeX’s markup consists of commands and environments.

Commands:

Environments:

LaTeX commands

Lets:

Equations: Math Mode

LaTeX has a “text mode” and a “math mode”.

In “math mode”, text is rendered as math…correctly

\[ y = mx + b \]

vs.

\[ \text{y = mx + b} \]

Some commands are only available in “math mode.”

There are multiple ways to activate “math mode”

Equations

Inline math with single dollar signs, $y = mx + b$. The dollar signs open up "math mode"

Double dollar signs
$$y = mx + b$$
put the equation on its own line.

The equation environment will put an equation on its own line and give it a number

\begin{equation}
    y = mx + b
\end{equation}

The align environment (in the amsmath package) will align multiple equations,
and add numbers.

\begin{align}
    y & = mx + b \\
    mx + b & = y
\end{align}

The starred equation and align environments wont add equation numbers
\begin{equation*}

\end{equation*}

\begin{align*}
    y & = mx + b \\
    mx + b & = y
\end{align*}

We can also choose specific equations that we dont want to number
\begin{align}
    y & = mx + b \\
    mx + b & = y \nonumber \\
    y & = mx + b
\end{align}

Equations

Let’s:

Cross-references

Lets:

Tables

\begin{table}
\begin{tabular}{ccc}
year &  make & model \\
\hline
1978 & Chevrolet & Suburban \\
1973 & Chevrolet & Monte-Carlo \\
1977 & Chevrolet & Silverado \\
1992 & Chevrolet & Camaro \\
\end{tabular}
\caption{\label{tab:cars} List of cars driven by Clark in high school.}
\end{table}

Let’s:

Figures

\begin{figure}
\\includegraphics[]{image.png}
\caption{\label{fig:fig1} This is a figure.}
\end{figure}

Let’s

_

LaTeX Libraires: Packages

\documentclass{article}

\usepackage{amsmath}
...

Useful Packages

amsmath, fullpage, and geometry

siunitx

siunitx is a packages for formatting units.

It solves the problem of formatting units inside of math mode correctly.

If your travel 60 m in 2 s, then your velocity velocity is $30 \frac{m}{s}$
($3000 \frac{ \text{cm} }{ \text{s} }$).
In 1 hour, you will have travelled

\begin{equation}
x = v t = 30 \frac{\text{m}}{\text{s}} \text{hr}
\end{equation}
If your travel \SI{60}{\minute} in \SI{2}{\second}, then your velocity velocity is \SI{30}{\meter\per\second}
(\SI{3000}{\centi\meter\per\second}).
In 1 hour, you will have travelled

\begin{equation}
x = v t = \SI{30}{\meter\per\second\hour}
\end{equation}

siunitx Examples

\SI{9.8}{\meter\per\second\squared}

\SI{100}{\degree C}

\SI{2.3e7}{\gram\per\meter\cubed}

siunitx Options

\usepackage[per-mode=fraction]{siunitx} will format units in fractions (instead of negative exponents).

physics

The physics package provides some useful commands for writing physcis papers

Derivatives:

Differentials

Vector Calculus

Matrices

\begin{matrix}
a & b \\
c & d \\
\end{matrix}

\mathbb{A} =
\left(
\begin{matrix}
a & b \\
c & d \\
\end{matrix}
\right)

\vec{u} = \mathbb{A}\vec{v} =
\left(
\begin{matrix}
a & b \\
c & d \\
\end{matrix}
\right)
\left(
\begin{matrix}
e \\
f \\
\end{matrix}
\right)

hyperref

The hyperref package allows you to insert links to web pages in your document.