Latex Tutorial For CME

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

CME 100/102/104 LATEX starter guide

Enze Chen
Date: September 19, 2018

Contents

1 Introduction 3
1.1 What is LaTeX? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Why should I care? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 How do I use LaTeX? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.1 Local machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.2 Online editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Basic structure: the .tex file 5

3 General typesetting 6
3.1 Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 Type and formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.3 Alignment and Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.4 Lists: itemize and enumerate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

4 Math commands/environments 9
4.1 The align environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2 Vectors and Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.3 Derivatives and Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.4 Note about {} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.5 Code: the lstlisting environment . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

5 Figures: the graphicx package 12

6 Tables: the array and booktabs packages 13

7 1-page cheat sheet 14

1
Why this document?

LaTeX is something that I’ve slowly picked up over the years here at Stanford, and now I absolutely
love using it. It started as a painstaking chore for CS assignments, but since then I’ve used it to
write research papers, all my problem sets, and even books.
I remember thinking early on, “Wow, LaTeX looks so cool, and so many classes advocate its use,
but no one seems to want to teach me it!” It’s always “Oh, go look online...” which can be helpful
once you have a solid foundation and know what to look for, but it’s pretty daunting for someone
just getting started. Therefore, I thought to prepare this as a quick guide to get someone who is
[more or less completely] new to LaTeX up and running; essentially, it’s everything I wish someone
had told me when I first started. Once the basics are there, questions regarding specific use cases
are best directed at Google and Stack Overflow, which I credit for much of my personal knowledge
of LaTeX and the content presented here.
The first three pages of this document are meant to be motivation (Section 1), an overview of the
software, and the basic structure of a .tex file (Section 2). If you want to skip to the meatier parts,
then Section 3 on typesetting and Section 4 on math commands will be more useful to you. Section 5
and 6 cover the specific syntax surrounding figures and tables respectively. Finally, Section 7 is a
concentrated cheat sheet of math commands/symbols that will hopefully serve as a handy reference
for CME related work. If you’re already familiar with LaTeX, you can jump straight to here.
If you have any questions or comments about this document and what can be added or clarified,
please don’t hesitate to reach out or post on Piazza. Enjoy.

∼ Enze

2
1 Introduction

1.1 What is LaTeX?

LaTeX, stylized as LATEX and pronounced either “Lay-tech” or “Lah-tech,” is a document preparation
system that uses the TeX typesetting program and various macros to stylize the text. Unlike What-
You-See-Is-What-You-Get (WYSIWYG) word processors (e.g. Microsoft Word), LaTeX relies on a
combination of powerful packages and markup conventions to format the plain text you input in a
highly structured and customizable way.

1.2 Why should I care?

As with everything else in life, before we jump into how to use LaTeX, we consider whether we
should be using LaTeX at all—I suppose it is here where I try to compel you into saying “yes.”
Pros

• Clean and controlled: LaTeX gives users a way to write very complex mathematical formulas
and organize content in a way that would be difficult for a normal word processor.

• Professional: LaTeX is used to typeset many scientific documents including journal articles,
reports, and books. It’ll likely come up in your future studies, so might as well get the growing
pains out now.

• Cross-referencing: LaTeX can automatically generate a title page, table of contents, bibliogra-
phy, and cross references (using \label{}) that auto-updates as your document changes.

• Portable: Ever received a word document format that you couldn’t open, or it opened with
weird symbols? LaTeX not only compiles into a PDF document that will look the same on
any platform/operating system, but the same LaTeX file you type now can be compiled on
any user’s TeX distribution at any time.

Cons

• Learning curve: Because LaTeX is not WYSIWYG, there is a bit of a learning curve to figure
out the right commands. Luckily there are many references online, and in this guide I will
touch upon the common commands that you’ll probably need. Like with everything else, the
more you use LaTeX commands the better you’ll remember them!

• Time investment: Relatedly, typing in LaTeX does take a non-trivial amount of time. I still
like to do scratch work and main calculations on paper before typing up my work in LaTeX.
Depending on the problem set and your familiarity with LaTeX, expect an additional 3-5
hours. Obviously the time spent on LaTeX will be worth it for larger projects, but for class
assignments this is one trade-off worth considering.

3
1.3 How do I use LaTeX?

LaTeX is freely distributed, and the two ways people create documents with LaTeX is either on
their local machine or using an online editor. For the purposes of this class, I will suggest you use
an online editor simply to avoid any compatibility issues and/or hassle of set-up, but the choice is
yours.

1.3.1 Local machine

You’ll need two things to start using LaTeX on your local machine, a TeX distribution and any
editor. Some common ones include:
Windows Mac Linux
TeX MikTex or TeX Live MacTeX TeX Live or with Linux source
Editor TeXStudio or TeXMaker TeXStudio or TeXShop TeXMaker or Vim/Emacs/Atom

The TeX distribution is in charge of storing all the libraries and packages you need to compile
your LaTeX code. Some distributions come with all packages pre-installed while others install
packages on-the-fly when you call them for the first time.
The choice of editor is largely user preference. Editors that are specifically made for LaTeX
might have nice user interfaces, keyboard shortcuts, auto-complete features, and PDF viewing within
the software. I recommend any of the above to start, but you should use what is most comfortable
for you.

1.3.2 Online editor

Two popular online editors used nowadays include Overleaf and ShareLaTeX. There are many
reasons to prefer using online editors over local distributions because they will store your files, have
most packages available, compile your document as you type, and allow real-time collaboration
between you and your peers. For this class, if you upload the template for each problem set into
your project directory on either of these sites, then everything should compile smoothly to get you
started.

4
2 Basic structure: the .tex file

To help you learn the basics of structuring a LaTeX document, I’ve purposely kept formatting to a
minimum on these templates. Every LaTeX document will have a preamble and body, with each
part consisting of the following.
Preamble

• \documentclass[options]{doctype}: This is required so LaTeX knows what format your


document takes. doctype examples include article, report, or book, and we’ve chosen
article, which is a standard class used for most documents. options will differ depending on
the document class, and we’ve kept it simple here with just the font size (11pt).

• \usepackage[options]{packagename}: You have to specify which packages you wish to use


before you’re allowed to call its commands. All packages are on CTAN, and below are some
brief descriptions of what I chose to include in the basic template:

– amsmath, amssymb, amsfonts: Basic packages for math typesetting.


– array, booktabs: Basic packages that help with creating tables (see Tables below)
– enumerate: Basic package that makes ordered lists (e.g. 1, 2, 3; see Lists below).
– geometry: Basic package that resizes margins [to 1in].
– microtype: Basic package that hyper-optimizes kerning. Subtle but good.
– graphicx: Basic package that helps with creating figures (see Figures below)
– xcolor: Extended package for colors. See documentation for details.
– mathtools: Extended package for more math symbols. See documentation for details.
– physics: Extended package that provides shortcut macros for differential equations and
various physics operators. See documentation for details.
– siunitx: Extended package for including units. See documentation for more details.
– listings: Extended package that provides a syntax-highlighted, language-dependent
environment for writing code. See documentation for details.

• Macros: In general, macros are shortcuts that will find and replace every instance of a shortcut
command with the user-defined code that follows it. I also like to put other styling commands
here. Here are some brief descriptions of what I chose to include in the template:

– \setlength: This is to help with variable paragraph spacing.


– \newcommand{\numberthis}: This is useful for the align* environment (see Section 4.1)
and will automatically insert the correct line number when \numberthis is typed.
– \lstset: This has parameters for the \lstlisting environment. More options here.

Body
The body of your LaTeX document (i.e. what actually appears to your readers) is everything
that is inside the \begin{document} and \end{document} environment. Here you can type text as
normal, and I will go over specific math and text formatting below.

5
3 General typesetting

3.1 Workflow

A typical workflow might look something like the following:

1) Create a .tex file in a directory with the figures you want to use (more on figures later).

2) Define \documentclass and list all \usepackage and macros.

3) Start the document body and begin typing, adding extra packages / macros as needed.

4) Recompile every couple of lines or when a large formula is typed to catch any errors early on.
With this step in particular, editors are handy because they can display the PDF and source
code side-by-side.

3.2 Type and formatting

As previously mentioned, if you just want normal text and paragraphs, you can type as you would
in any word processor. Note, however, that you must have an extra blank line in order to start a
new paragraph, and any extra spaces (1 vs 10) will render the same in LaTeX (1 space). This might
be something new to get used to, although you can use it advantageously by making the .tex file
easier to read. For example, typing

$1234 + 56 = 1290 \\ 1 + 3 = 4$

and

$1234 + 56 = 1290 \\
1 + 3 = 4$

will both appear as


1234 + 56 = 1290
1+3=4
but the second option offers better readability for the writer. In the next section we’ll learn how
to make the above equations more readable for the reader.
Environments allow for customization of a section of text. They start with \begin{env-name}
and must be closed with a corresponding \end{env-name}. Pretty much all commands in LaTeX
start with a backslash (\), followed by a keyword, and then curly braces {} enclosing an argument
(if one is required). For example, some special fonts and commands that you might find useful are:

• Bold, italics, and underline can be achieved with \textbf{word-to-be-bolded}, \textit{},


and \underline{}.

• Monospaced computer type can be achieved with the \texttt{} command.

• Small caps (of two different sizes) can be achieved with the \textsc{} command.

6
• Backslash: Backslash by itself will create a space, and typing double backslash will create a
new line. If you want to actually type the backslash character so it appears to the reader, \,
use \textbackslash in plain text mode or \backslash in math mode.

• Curly braces: Similarly, because curly braces enclose arguments (and otherwise won’t show),
if you want curly braces to actually appear, you can force them by preceding each part with a
backslash, i.e. typing “\{\}” creates {}.

• Quotes: Open/left quotation marks in LaTeX, “, use two backticks (next to the ‘1’ on a
keyboard) and close/right quotation marks use the apostrophe, ”. You don’t want to be
caught using apostrophes for both; ”ugly!”

• Spacing and breaks. The command \quad inserts whitespace approximately the width of
the letter ‘M,’ and \qquad inserts double that width. Use the \newpage command to insert a
page break.

Sections: If you want to split your document into numbered sections, use the \section{Header
name} command. Subsections are specified with \subsection{} and \subsubsection{}, and are
automatically numbered in order. If at any point you want a section header without a number, include
an asterisk like \section*{Header name} (many numbered options in LaTeX can be removed with
the addition of an asterisk).
Cross-referencing: LaTeX also supports internal references to different parts of a document.
Anything that is numbered (e.g. sections, equations, figures, tables) can have a \label{labelname}
placed by it, and this can be referenced elsewhere in the text using \ref{labelname}. When you
do this, I would advise informative names that differ by object, for example, \label{fig:wave} or
\label{sec:LU} for figures and sections respectively.
Comments: The percent sign % will comment out the rest of the line.

3.3 Alignment and Fonts

You will notice that the homework templates begin with the \begin{center} environment to center
the title and names. Everything typed inside this environment will be centered and everything outside
returns to the default. If you would like to right-align text, you can use the \begin{flushright}
environment.
Sometimes, you might want text to be aligned left and right in the same line, like when
constructing headers [for a resume]. You can accomplish this using the \hfill command, which
pushes everything after it to the right.
Absolute font size is controlled in the documentclass declaration, but you can also specify
relative font size by enclosing sections of text in curly braces, as shown in the template. Choices
include \tiny, \footnotesize, \small, \large, \Large, \LARGE, \huge, and \HUGE.
You probably will only need font color for specific words and phrases here or there, and for that
there is the \textcolor{color}{text} command such as \textcolor{red}{this} → this.

7
3.4 Lists: itemize and enumerate

If you would like to create lists of items, the two ways are using the itemize and enumerate
environments. Both use \item to start a new entry, and while the former creates bullet points, the
second one creates ordered lists that allow you to specify the style. If you type:

\begin{itemize}
\item One fish
\item Two fish
\end{itemize}
\begin{enumerate}[a)]
\item Red fish
\item Blue fish
\end{enumerate}

what you will get is:

• One fish
• Two fish

a) Red fish
b) Blue fish

where in the enumerate environment the [a)] option creates the list bullet style. Other style
options for lists include [1.], [(i)], [a.], etc.
Now, of course, I herd you like lists, so I put a list in your list so you can list while you list1 :

1. Ordered list item 1 contains


• Unordered list item 1
• Unordered list item 2 contains
i. Inner ordered list item
2. Ordered list item 2

\begin{enumerate}[1.]
\item Ordered list item 1 contains
\begin{itemize}
\item Unordered list item 1
\item Unordered list item 2 contains
\begin{enumerate}[i.]
\item Inner ordered list item
\end{enumerate}
\end{itemize}
\item Ordered list item 2
\end{enumerate}

1
Xzibit Yo Dawg meme. Footnotes can be made with the \footnote{} command. Good for citations.

8
4 Math commands/environments

Time for the fun part! Math environments in LaTeX can be created in a variety of ways, the most
typical one being the dollar sign $. For example, if you type

$3 \times 2 - 1 = 5$

you will get 3 × 2 − 1 = 5 inline with the text. Anything enclosed with dollar signs will render
in math mode, including text, whichwillunf ortunatelylooklikethis, so if you need text within
dollar signs, use the \text{} command. Just as with curly braces, if you ever need to type the
actual dollar sign (such as with monetary figures), add a backslash before it, ‘\$.’ Please consult
the 1-page cheat sheet or online references for common math symbols (e.g. how to type fractions,
integrals, etc.).
Another way to trigger the math environment is to use ‘\[’ and ‘\].’ Anything within these
special brackets will not only render in math mode, but it will do so centered on a new line, such as
2
3×2− = 5.
2
With the exception of individual values, I much prefer to use this second math environment because
of the clarity and emphasis. Also, tall expressions likePfractions and summations will get compressed
to “fit” inline when using dollar signs, e.g. 12 and 51 , but they will fully expand in the bracket
environment.

4.1 The align environment

Yet another popular and useful way to trigger the math environment is using the \begin{align}
environment, which allows you to type multiple lines of math, each separated with two backslashes,
\\, and aligned using the ampersand character &. For example, to get
 
2 ab
c =4 + (b − a)2 (1)
2
= 2ab + b2 − 2ab + a2 (2)
2 2
=a +b (3)

one can type

\begin{align}
c^2 &= 4 \left( \frac{ab}{2} \right) + (b - a)^2 \\
&= 2ab + b^2 - 2ab + a^2 \\
&= a^2 + b^2
\end{align}

Note how in each line the ampersand lines up the equal signs, and how each line ends with two
backslashes so LaTeX knows to begin the next line. Each line must have the same number of &
characters. align will auto-center the expressions as well. Again, we don’t actually have to create
a new line for LaTeX to render (all of that could be typed onto a single line), but we do so for
readability. If we want an aligned environment without numbering each equation, we can use the
asterisk as before, \begin{align*} and corresponding \end{align*}.

9
4.2 Vectors and Matrices

We will be handling vectors and matrices a lot in this class. Vectors are most clearly specified with
an arrow above a lowercase letter using the \vec{u} command in math mode, e.g. ~u. Certain texts
may also use a bolded letter, u, \textbf{u}. Unit vectors are sometime denoted with a hat as well,
such as î, \hat{i}. Matrices are represented with a capital letter which can be directly typed in
math mode or bolded, i.e. A with “$A$” or A with “\textbf{A}” will work, but not plain-text A.
Explicitly writing the entries of a matrix can be done with either the \begin{matrix} (no side
bars), \begin{bmatrix} (square brackets), \begin{pmatrix} (parentheses), or \begin{vmatrix}
(vertical bars) environments. Following the previous convention, use ampersands “&” to separate
elements in each row and double backslash “\\” to separate different rows. Each matrix environment
can be sized without explicit pre-specification, but once the first row is specified, all subsequent
rows must have the same number of elements or it will throw an error. Examples include
   
1 2 3 1 0
A= , I=
4 5 6 0 1

\[ A = \begin{pmatrix}
1 & 2 & 3 \\
4 & 5 & 6
\end{pmatrix}, \qquad
I = \begin{bmatrix}
1 & 0 \\
0 & 1
\end{bmatrix} \]
 
  1
Vectors are just 1-dimensional matrices and constructed as such, namely p~ = 1 2 or ~u = .
2
To save space and for presentation purposes, you might see a column vector represented as ~u =
 T
1 2 , written as the transpose of a row vector. Do remember, however, that if not explicitly
written as a row vector, then by convention vectors are assumed to be column vectors.

4.3 Derivatives and Integrals

There are many packages out there that simplify the work of typesetting derivatives, but I have
found physics to be nice, and so I’ve included it in the template. To obtain an ordinary derivative,
simply use the macro \dv[order; default = 1]{optional top argument}{required bottom
argument}. Concrete examples include

d d2 T d4
, ,
dt dx2 dx4

\[ \dv{t}, \qquad
\dv[2]{T}{x}, \qquad
\dv[4]{x} \]

Partial derivatives follow the same syntax but use the \pdv macro. It’s pretty nifty!

10
The symbol for gradients is the nabla symbol, which is written using \nabla in math mode,
∇. Divergence is nabla followed by a centered dot, ∇· (\nabla \cdot), and this dot is also the
preferred symbol for multiplication (opposed to asterisk; 3 · 2 vs. 3 ∗ 2). Laplacians are commonly
written as ∇2 , \nabla^2, or 4, which is \triangle.
Integrals take the macro \int_{lower limit}^{upper limit} and end with \dd{var}, also
thanks to the physics package. An example would be
Z ∞
sin(x)
dx
0 x

\[ \int_{0}^{\infty} \frac{\sin(x)}{x} \dd{x} \]

Summations and products work in a similar fashion with the \sum and \prod commands
respectively.
∞ n
X 1 Y
i
i
i=1 i=1

\[ \sum_{i = 1}^{\infty} \frac{1}{i} \qquad \prod_{i = 1}^{n} i \]

4.4 Note about {}

You may have noticed that in the code above (and other places), we used curly braces to enclose
large quantities that we want to put into a subscript, exponent, fraction, etc. It’s important to
recognize that LaTeX will not capture more than one character for an operator, i.e. typing A^-23
results in A− 23 (only the minus sign is in the exponent) whereas typing A^{-23} is probably what
you want, A−23 . You will need braces whenever you want an operation or command to be applied
to a long expression.

4.5 Code: the lstlisting environment

Now, there are many times where we actually want the reader to see the raw source code without
it compiling, such as the many places above, and more generally when you want to include code
(like MATLAB!). This is accomplished with the \begin{lstlisting} environment. You should
use this environment if you’re attaching the MATLAB code into your LaTeX writeup, and for
readability, please make sure you’re consistent about tabs or spaces for indentation. If you want
more formatting options, they’re described in detail here.

11
5 Figures: the graphicx package

LaTeX is great for making its own vectorized graphics (see TikZ documentation), but sometimes we
want to attach a figure created by another program. The graphicx package is extremely useful for
this task, as it allows us to type the following:

\begin{figure}[!h]
\centering
\includegraphics[width=0.2\linewidth]{stanford.png}
\caption{Stanford emblem.}
\label{fig:stan}
\end{figure}

to produce:

Figure 1: Stanford emblem.

Let’s dissect each piece. The \begin{figure} environment is what we call for figures. The [!h]
option is a handy flag that optimizes placing of the figure near where we specify, or else figures will
float to the top of every page they appear on.
\centering centers the figure on the page, and \includegraphics grabs the actual figure from
its source file. The width option is handy for controlling figure size, and most of my MATLAB plots
I usually give between 0.4 − 0.5 of the total \linewidth. Inside the braces we write the name of
the figure file (with explicit extension to be safe). PNG, JPG, and PDF are all supported file types.
\caption{} is quite useful as you can explain a little bit about the figure, and \label{} allows
cross-referencing of Figure 1 within the text (I typed “Figure \ref{fig:stan}”).
Note on file path: The place LaTeX looks by default is the current folder that the .tex file is
in. If you have your figures organized elsewhere, say in a subdirectory called fig in the current
directory (often a good idea for larger projects!), you can add a line \graphicspath{{./fig/}} in
the preamble to tell LaTeX where to look. In general, “./fig/” can be replaced by any relative or
absolute path.

12
6 Tables: the array and booktabs packages

LaTeX offers a great deal of flexibility in creating and customizing tables, thanks to the array and
booktabs packages. We already saw an example of a table up above, and here I’ll give another
minimum working example.

\begin{table}[!h]
\centering
\begin{tabular}{l|cc}
\ & A & B \\ \toprule
1 & Yes & No \\
2 & $\frac{2}{3}$ & $-0.4$
\end{tabular}
\caption{My table.}
\label{tab:example}
\end{table}

A B
1 Yes No
2
2 3 −0.4

Table 1: My table.

As you can see, tables and figures share a lot of similarities. We use the \begin{table}
environment with the appropriate alignment options. Inside, we call another \begin{tabular}
environment, which takes as options an explicit, pre-specified number of columns with explicit
alignment, either left (l), center (c), or right (r), that can differ for each column. Vertical lines,
made using the key above the Enter key on the keyboard, determine whether or not there is a line
separating the two columns.
The body of a table is very similar to that of a matrix. Again, ampersands separate the columns
and double backslashes separate the rows. The number of columns in each row must match what is
specified above, and while empty elements can be left blank (i.e. we could have started row one
with just an ampersand), I like to include a backslash to explicitly signal that the cell is empty.
booktabs comes with the \toprule, \midrule, and \bottomrule commands that draw horizontal
lines separating the rows of the table. Note that toprule and bottomrule are slightly thicker than
midrule. By default, tables are not in math mode, so any cells with math content need dollar
signs for each cell. Captions and labels work similar to that of figures.

13
7 1-page cheat sheet

• Bold: \textbf{A}, e.g. A. • Limits: \lim, lim. \max, max. \min, min.
• Italics: \textit{A}, A. • Gradient: \nabla, ∇. \triangle, 4.
• Underline: \underline{A}, A.
k
• Monospace: \texttt{A}, A.
X
• Summation: \sum_{lower}^{upper}, .
• Small caps: \textsc{a}, a. i=0

• Normal (in math mode (mm)): \text{}. Z L

• Emphasis: \emph{A}, A. • Integral: \int_{l}^{u} \dd{}, dx.


0
• Color: \textcolor{color}{text}, B. n
Y
• Blackboard (mm): \mathbb{Z}, Z. • Product: \prod_{lower}^{upper}, .
• Caligraphy (mm): \mathcal{T}, T . i=1

• Fraktur (mm): \mathfrak{R}, R. d2 F


• ODE: \dv[order]{top}{bottom}, .
• Greek (mm): \alpha, α. \beta, β. \pi, π. dx2
\psi, ψ. \Theta, Θ. And many more!
∂G
• Infinity (mm): \infty, ∞. • PDE: \pdv[order]{top}{bottom}, .
∂y

• Math mode: ${math}$ or \[{math}\]. • Comparison: \le, ≤. \ge, ≥. \neq, 6=.


• Align: \begin{align} or \begin{align*}. • Similarity: \sim, ∼. \approx, ≈. \cong, ∼
=.
• Force tall expression: \displaystyle\{com}. \equiv, ≡. \perp, ⊥. \parallel, k.
• Sets: \{ \mid, \in \}, {x | x ∈ N}. \subseteq,
◦ ⊆.
• Degree: 35^{\circ}, 35 .
• Empty set: \emptyset, ∅. \varnothing, ∅.
• Multiplication: \cdot, · \times, ×.
• Membership: \forall, ∀. \exists, ∃.
a • Logic: \vee, ∨. \wedge, ∧. \neg, ¬.
• Fraction: \frac{a}{b}, .
b
√ • Square: \square, . \blacksquare, .
• Square root: \sqrt{x}, x. • Signs: \pm, ±. \mp, ∓.

• nth root: \sqrt[n]{y}, n y. .
• Dots: \cdots, · · · \dots, . . . \vdots, ..
 
n • Parentheses: \left(, \right); (, ).
• Combination: \binom{n}{r}, .
r • Brackets: \left[, \right]; [, ].
• Vector: \vec{p}, p~. • Arrows: \rightarrow, →. \Leftarrow, ⇐.
\longleftrightarrow, ←→.
• Norm: \norm{p} {2}, k~
pk2 . \abs{a}, |a|.
\begin{figure}[!h]
• Matrix: \begin{bmatrix} 1 & 0 \centering
\end{bmatrix}, [1 0]. \includegraphics[width=0.4\linewidth]{myfig.png}
\caption{My figure.}
• Markings: \hat{p}, p̂. \tilde{O}, Õ. \label{fig:myfig}
\bar{x}, x̄. \dot{u}, u̇. \end{figure}
text
z}|{ \begin{table}[!h]
• Braces: \overbrace{text}^{p}, p . \centering
\underbrace{p} {text}, p . \begin{tabular}{l|c}
|{z}
text \ & A \\ \toprule
foo & bar
• Trigonometry: \sin, sin. \cos, cos. \arctan, \end{tabular}
arctan. \sinh, sinh. etc. \caption{My table.}
\label{tab:mytab}
• Functions: \exp, exp. \log, log. \ln, ln. \end{table}

14

You might also like