Skip to main content

LaTeX Cheat Sheet

Expressions

Expression Number

If you need an expression number:

\begin{eqnarray}
y=\alpha x + \beta
\end{eqnarray}
y=αx+β(1) y=\alpha x + \beta \tag{1}

If you do not need an expression number:

\[
y=\alpha x + \beta
\]
y=αx+β y=\alpha x + \beta

Align Equations

Use & to align multiple equations at equal positions.

\[
a&=b+c \\
d+e&=f
\]
a=b+c d+e=f\begin{aligned} a&=b+c \\\ d+e&=f \end{aligned}
\begin{eqnarray}
a&=b+c \\
d+e&=f
\end{eqnarray}
a=b+c d+e=f\begin{aligned} a&=b+c \\\ d+e&=f \end{aligned}

Simultaneous Equations

\begin{eqnarray}
\begin{cases}
(x - 2)^2 + y^2 + z^2 = 1\\
x + z = 3
\end{cases}
\end{eqnarray}
{(x2)2+y2+z2=1 x+z=3\begin{cases} \left(x - 2\right)^2 + y^2 + z^2 = 1\\\ x + z = 3 \end{cases}
\begin{numcases}
{}
(x - 2)^2 + y^2 + z^2 = 1\\
x + z = 3
\end{numcases}
{(x2)2+y2+z2=1 x+z=3\begin{cases} \left(x - 2\right)^2 + y^2 + z^2 = 1\\\ x + z = 3 \end{cases}

Matrix

\begin{eqnarray}
\left(
\begin{array}{cc}
a & b \\
c & d
\end{array}
\right)
\end{eqnarray}
(ab cd)\begin{pmatrix} a & b \\\ c & d \end{pmatrix}

Source Code

minted

To write code directly in a tex file, use minted.

\begin{minted}[linenos, breaklines, frame=lines]{c}
#include <stdio.h>
int main(){
printf("Hello, World!");
return 0;
}
\end{minted}

Use inputminted to specify a file and put the source code in it.

\inputminted[linenos, breaklines, frame=lines]{language}{src/hello.c}

Figure

This is an example of inserting a single image. In the example below, the package here is used to insert the image at the specified position. (\usepackage{here})

\begin{figure}[H]
\centering
\includegraphics[width=10cm]{path2image}
\caption{hoge}
\label{fig1}
\end{figure}

Table

The table can be written as follows, but it is easier to create it automatically using Table generator.

\begin{table}[H]
\centering
\caption{title}
\label{tbl:1}
\begin{tabular}{ccc}
\hline
e1 & e2 & e3 \\
\hline
11 & 12 & 13 \\
21 & 22 & 23 \\
31 & 32 & 33 \\
\hline
\end{tabular}
\end{table}

Footnote

\footnote[number]{text}

Special Characters and Operators

Σ

\sum_{\alpha=0}^{\beta}

α=0β\sum_{\alpha=0}^{\beta}

\int_{\alpha}^{\beta}
αβ\int_{\alpha}^{\beta}

lim

\lim_{n \to \infty}
limn\lim_{n \to \infty}

\neq
\neq

\approx
\approx

\fallingdotseq
\fallingdotseq

\equiv
\equiv

>

\gt
>\gt

<

\lt
<\lt

\geq
\geqq
\geq\\ \geqq

\leq
\leqq
\leq\\ \leqq

×

\times
×\times

÷

\div
÷\div

±

\pm
±\pm

\in
\in

\subset
\subset

\cap
\cap

\cup
\cup

Null Set ∅

\emptyset
\emptyset

\infty
\infty

Vector

\vec{a}
a\vec{a}
\bm{a}
a\bm{a}

Partial, Del, ∂

\partial
\partial