# LaTeX note
[Reference](https://hackmd.io/@RintarouTW/%E6%84%9A%E5%8D%83%E6%85%AE%E3%81%AE%E7%AD%86%E8%A8%98%E6%9C%AC/%2F%40RintarouTW%2FLaTeX_%25E8%25AA%259E%25E6%25B3%2595%25E7%25AD%2586%25E8%25A8%2598)
:::warning
In this note, the concept of each command will not be mentioned, but **the usages** instead.
:::
:::spoiler Resources
> - [LaTeX Website](https://www.latex-project.org/)
> - [LaTeX Wikibook](https://en.wikibooks.org/wiki/LaTeX)
> - [PDF file](https://upload.wikimedia.org/wikipedia/commons/2/2d/LaTeX.pdf)
> - Phoebe's [presentation note](https://hackmd.io/@Phoebe61G/B1ihdFCsY) in class.
:::
## I. Basic
### Class
- To set the overall format of your paper
```tex=
\documentclass[12pt]{article}
\documentclass[10pt,twocolumn,letterpaper]{article}
```
#### Table of Classes
<table>
<tr>
<td>Class</td>
<td>Description</td>
</tr>
<tr>
<td>article</td>
<td></td>
</tr>
<tr>
<td>books</td>
<td></td>
</tr>
<tr>
<td>book</td>
<td></td>
</tr>
</table>
### Package
```tex=
\usepackage[]{}
```
### Paper ID
```tex=
% Enter the paper ID here
\def\avssPaperID{****}
```
#### Table of Packages
### Preamble
- The part before body of document.
```tex=
\documentclass[]{}
\usepackage[]{}
\title{}
\author{}
\date{}
\begin{document}
\maketitle
<here is the body of document>
\end{document}
```
- Place `\maketitle`(line 8) in the body to show the info you define in the preamble.
### `\tableofcontents`
```tex=
\tableofcontents
```
- Place in the body.
### `\section`
```tex=
\section{Introduction}
\subsection{Phoebe you must work harder!!} \label{The_truth}
```
> `\label`: to refer to this section in the paragraph.
### Text space
### Line Break and Page Break
> [REF](http://www.personal.ceu.hu/tex/breaking.htm)
- `\\` start a new paragraph.
- `\\*` start a new line but not a new paragraph.
- `\-` OK to hyphenate a word here.
- `\cleardoublepage` flush all material and start a new page, start new odd numbered page.
- `\clearpage` plush all material and start a new page.
- `\hyphenation` enter a sequence pf exceptional hyphenations.
- `\linebreak` allow to break the line here.
- `\newline` request a new line.
- `\newpage` request a new page.
- `\nolinebreak` no line break should happen here.
- `\nopagebreak` no page break should happen here.
- `\pagebreak` encourage page break.
## II. Chinese Text
- Two ways --> **include class** or **include package**.
### Class `cjkart`
```tex=documentclass{ctexart}
```
```tex=
```
### Package `CJK`
```tex=
\usepackage{CJK}
```
- Then place following commands in the body.
```tex=
\begin{CJK}{UTF8}{bkai}
繁體中文
\end{CJK}
```
#### Table of font
<table>
<tr>
<td>Font Name</td>
<td>Code Usage</td>
</tr>
<tr>
<td>標楷體</td>
<td>bkai</td>
</tr>
<tr>
<td>新細明體</td>
<td>bsmi</td>
</tr>
</table>
## III. Formula
```tex=
$(x+y=z)$
${(2x+3y=5z)}$
$$A(X)=2x^2+3x+1$$
```
### Mathematical Symbols
> [Mathematical Symbols](https://oeis.org/wiki/List_of_LaTeX_mathematical_symbols)
- $${\Sigma}^{10}_{i=0}{i}^2$$
- $\frac{n}{n-1}$
### Equations
```tex=
\begin{equation}
\label{eqn:parked}
\begin{align*}
2x - 5y &= 8 \\
3x + 9y &= -12
\end{align*}
\end{equation}
```
$2x - 5y = 8\\3x + 9y = -12$
> Add `&` to denote which symbol you wanna align with
> [Align equations with amsmath](https://www.overleaf.com/learn/latex/Aligning_equations_with_amsmath)
## IV. Figure
- In the preamble, type
```tex=
\usepackage {graphicx}
\graphicspath { {./my_images/} }
```
- Then place following commands in the body.
```tex=
\includegraphics{file_name}
\includegraphics[width=\linewidth]{file_name}
```
## V. Table
### `{tabular}`
- Place following commands in the body.
```tex=
\begin{tabular} { |c|c|c| }
\hline
(0,0) & (0,1) & (0,1) \\
\hline
(1,0) & (1,0) & (1,2) \\
\hline
(2,0) & (2,1) & (2,2) \\
\hline
\end{tabular}
```

### `\multicolumn`
### `\centering` & `\raggedleft` & `\raggedright`
### `\multicolumn`
### `\rowcolors`
### `\setlength`
### `{table}`
### Package `array`
## VI. Citation
### `{thebibliography}` & `\bibitem`
- Place following commands in the body.
```tex=
\begin{thebibliography}
\bibitem{lamport94}
Leslie Lamport (1994) \emph{\LaTeX: a document preparation system}, Addison Wesley, Massachusetts, 2nd ed.
\end{thebibliography}
```
### `\cite`
```tex=
\cite{lamport94}
```
- Give the name of `\bibitem` in `{}`
### Symbol-table
[Symbol-table from offical website](https://v1.overleaf.com/latex/templates/symbol-table/fhqmttqvrnhk.pdf)
---
## VII. Define new command
- Tab
- `\newcommand\tab[1][1cm]{\hspace*{#1}}`