LaTeX is a markup language and compiler that typesets your document and generates a PDF.
Math
vs.
Support for automatic cross-references.
Support for automatic bibliography generation.
Plain Text can be edited with simple scripts.
Separate content from typesetting.
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.
pdflatex
compilerLet’s compile our latex without texstudio
.
LaTeX’s markup consists of commands and environments.
Commands:
\commandname[options]{argument1}{argument2}
\nabla
: insert the del operator \(\nabla\)\int
: insert an integral sign \(\int\)\begin{equation}
: open an equation
environment\end{equation}
: close an equation
environment\emph{some text}
: add emphasis (usually itallics) to
text\section{Section Name}
: create a section header\frac{x}{y}
: render a fraction \(\frac{x}{y}\)\documentclass[10pt,letterpage]{article}
: set the
document class to article
and use 10pt font on a letter
page.Environments:
\begin{environment_name}
and
\end{environment_name}
Lets:
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”
$y = mx + b$
$$y = mx + b$$
equation
environmentalign
environmentInline 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}
Let’s:
add Maxwell’s Equations \[ \nabla \cdot \vec{E} = \frac{\rho}{\epsilon_0} \\ \nabla \cdot \vec{B} = 0 \\ \nabla \times \vec{E} = - \frac{\partial \vec{B}}{\partial t} \\ \nabla \times \vec{B} = \mu_0\left( \vec{J} + \epsilon_0 \frac{\partial \vec{E}}{\partial t} \right) \]
align these equations
remove the numbers
remove just one of the numbers
We often need to reference a specific equation in our writing. We also need to reference sections or subsections, tables, figures, etc. These are cross-references.
To cross-reference something, we have to
\label{label_text}
\ref{label_text}
Lets:
\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:
\begin{figure}
\\includegraphics[]{image.png}
\caption{\label{fig:fig1} This is a figure.}
\end{figure}
Let’s
\usepackage{...}
command\documentclass{article}
\usepackage{amsmath}
...
amsmath
, fullpage
, and
geometry
amsmath
, it provides the
align
environmentfullpage
package makes the margins more
reasonable.geometry
package gives use full control over the
margins.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
\dv{f}{x}
=> \dv{x}
=> \dv{x} f(x)
=> \dv[2]{f}{x}
=> \dv[2]{x}
=> \dv[2]{x} f(x)
=> \pdv{f}{x}
=> \pdv{x}
=> \pdv{x} f(x)
=> \pdv[2]{f}{x}
=> \pdv[2]{x}
=> \pdv[2]{x} f(x)
=> df = \pdv{f}{x} df + \pdv{f}{y} dy
=> \dd f = \pdv{f}{x} \dd x + \pdv{f}{y} \dd y
=> \int f(x) \dd x
=> -\grad \phi = \vb{E}
=> \div{\vb{E}} = \rho/\epsilon_0
=> \curl{\vb{E}} = -\pdv{\vb{B}}{t}
=> \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.
\url{https://google.com}
will create a link using the
URL as its text.\href{https://google.com}{Google}
will create a link
using Google
for the text.