# Referensi Cepat LaTeX

*Struktur dokumen, matematika, tabel, gambar, dan lainnya*

> Source: LaTeX Project (latex-project.org) · MIT

## Struktur Dokumen

### Dokumen Minimal

```
\documentclass{article}
\begin{document}
Hello, LaTeX!
\end{document}
```

### Kelas Dokumen

| Command | Description |
|---------|-------------|
| `article` | Dokumen pendek, makalah, laporan |
| `report` | Dokumen panjang dengan chapter |
| `book` | Buku lengkap dengan bagian, chapter |
| `beamer` | Presentasi slide |
| `letter` | Surat resmi |

### Preamble

```
\documentclass[12pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, graphicx}
\title{My Document}
\author{Alice}
\date{\today}
```

### Pembagian Section

| Command | Description |
|---------|-------------|
| `\part{}` | Divisi tingkat atas (book/report) |
| `\chapter{}` | Chapter (hanya report/book) |
| `\section{}` | Section |
| `\subsection{}` | Subsection |
| `\subsubsection{}` | Sub-subsection |
| `\paragraph{}` | Paragraf bernama |

## Pemformatan Teks

### Gaya Font

| Command | Description |
|---------|-------------|
| `\textbf{bold}` | Teks **tebal** |
| `\textit{italic}` | Teks *miring* |
| `\underline{text}` | Teks bergaris bawah |
| `\texttt{code}` | Monospace / mesin ketik |
| `\textsc{Small Caps}` | Kapital kecil |
| `\emph{emphasis}` | Penekanan (miring peka konteks) |

### Ukuran Font

| Command | Description |
|---------|-------------|
| `\tiny` | Terkecil |
| `\small` | Lebih kecil dari normal |
| `\normalsize` | Ukuran default |
| `\large / \Large` | Lebih besar / lebih besar lagi |
| `\huge / \Huge` | Sangat besar / terbesar |

### Spasi & Pemisah

| Command | Description |
|---------|-------------|
| `\\` | Pemisah baris |
| `\newpage` | Pemisah halaman |
| `\vspace{1cm}` | Spasi vertikal |
| `\hspace{1cm}` | Spasi horizontal |
| `\noindent` | Hilangkan indentasi paragraf |
| `~` | Spasi tak dapat dipisah |

## Mode Matematika

### Math Inline & Display

```
Inline: $E = mc^2$ or \( a^2 + b^2 = c^2 \)
Display: \[ \int_0^\infty e^{-x} dx = 1 \]
Numbered: \begin{equation}
  F = ma \label{eq:newton}
\end{equation}
```

### Simbol Umum

| Command | Description |
|---------|-------------|
| `^ and _` | Superscript / subscript: `x^2`, `a_i` |
| `\frac{a}{b}` | Pecahan: a/b |
| `\sqrt{x} / \sqrt[3]{x}` | Akar kuadrat / kubik |
| `\sum_{i=1}^{n}` | Penjumlahan |
| `\int_a^b` | Integral |
| `\lim_{x \to 0}` | Limit |
| `\infty` | Simbol tak hingga |

### Huruf Yunani

| Command | Description |
|---------|-------------|
| `\alpha \beta \gamma \delta` | Huruf Yunani kecil |
| `\Gamma \Delta \Theta \Lambda` | Huruf Yunani kapital |
| `\epsilon \sigma \omega \pi` | Huruf Yunani kecil lainnya |
| `\mu \nu \rho \tau \phi` | Umum statistik / fisika |

### Matriks

```
\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}
% pmatrix = (), vmatrix = ||, Bmatrix = {}
```

## Environment

### Environment Umum

| Command | Description |
|---------|-------------|
| `document` | Area konten utama |
| `equation` | Persamaan matematika bernomor |
| `align` | Persamaan multi-baris yang disejajarkan |
| `figure` | Gambar mengambang |
| `table` | Tabel mengambang |
| `verbatim` | Teks literal (tanpa pemformatan) |
| `abstract` | Blok abstrak (article) |

### Persamaan Disejajarkan

```
\begin{align}
  x &= a + b \\
  y &= c + d
\end{align}
% & marks alignment point, \\ breaks lines
```

## Daftar & Tabel

### Daftar

```
\begin{itemize}
  \item Bullet point
  \item Another item
\end{itemize}
\begin{enumerate}
  \item First  \item Second
\end{enumerate}
```

### Tabel

```
\begin{tabular}{|l|c|r|}
  \hline
  Name & Age & Score \\ \hline
  Alice & 25 & 88 \\
  Bob & 30 & 92 \\ \hline
\end{tabular}
```

### Penentu Kolom

| Command | Description |
|---------|-------------|
| `l / c / r` | Rata kiri / tengah / kanan |
| `\|` | Garis vertikal antar kolom |
| `p{3cm}` | Kolom paragraf (lebar tetap) |
| `\hline` | Garis horizontal |
| `\cline{2-3}` | Garis horizontal parsial (kol 2-3) |

## Gambar

### Menyisipkan Gambar

```
\usepackage{graphicx}  % in preamble
\begin{figure}[htbp]
  \centering
  \includegraphics[width=0.8\textwidth]{img.png}
  \caption{A figure caption}
  \label{fig:example}
\end{figure}
```

### Penentu Penempatan

| Command | Description |
|---------|-------------|
| `h` | Di sini (kira-kira) |
| `t` | Bagian atas halaman |
| `b` | Bagian bawah halaman |
| `p` | Halaman float khusus |
| `!` | Abaikan pembatasan internal |
| `H` | Tepat di sini (membutuhkan `float`) |

### Referensi Silang

```
See Figure~\ref{fig:example} on
page~\pageref{fig:example}.
% Requires two compilations to resolve
```

## Daftar Pustaka

### Alur Kerja BibTeX

```
% In .bib file:
@article{smith2025,
  author = {Smith, John},
  title = {A Great Paper},
  journal = {Nature}, year = {2025}
}
```

### Mengutip dalam Dokumen

```
According to~\cite{smith2025} ...
\bibliographystyle{plain}
\bibliography{refs}  % refs.bib
```

### Gaya Daftar Pustaka

| Command | Description |
|---------|-------------|
| `plain` | Bernomor, diurutkan alfabetis |
| `unsrt` | Bernomor, sesuai urutan kutipan |
| `abbrv` | Seperti plain, nama disingkat |
| `apalike` | Penulis-tahun (mirip APA) |

## Package

### Package Penting

| Command | Description |
|---------|-------------|
| `amsmath` | Environment matematika lanjutan |
| `graphicx` | Penyisipan gambar |
| `hyperref` | Tautan dan referensi yang dapat diklik |
| `geometry` | Margin halaman: `\usepackage[margin=1in]{geometry}` |
| `booktabs` | Tabel profesional (`\toprule`, `\midrule`) |
| `xcolor` | Warna teks dan latar belakang |
| `listings` | Daftar kode sumber |
| `tikz` | Grafik dan diagram terprogram |
| `babel` | Dukungan multibahasa |
| `natbib` | Kutipan fleksibel (penulis-tahun, numerik) |

## Perintah Custom

### Perintah Baru

```
\newcommand{\R}{\mathbb{R}}    % shortcut
\newcommand{\norm}[1]{\|#1\|}  % 1 argument
Now use: $x \in \R$, $\norm{v}$
```

### Memperbarui & Environment

```
\renewcommand{\abstractname}{Summary}
\newenvironment{boxed}
  {\begin{center}\begin{tabular}{|p{0.9\textwidth}|}\hline}
  {\hline\end{tabular}\end{center}}
```

### Pintasan Berguna

```
\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\dd}[2]{\frac{d #1}{d #2}}
% Usage: $\pd{f}{x}$, $\dd{y}{t}$
```

## Pola Umum

### Halaman Judul

```
\begin{document}
\maketitle
\tableofcontents
\newpage
```

### Kompilasi

| Command | Description |
|---------|-------------|
| `pdflatex doc.tex` | Compile ke PDF |
| `bibtex doc` | Proses daftar pustaka |
| `latexmk -pdf doc.tex` | Auto-compile (menangani pengulangan) |
| `xelatex doc.tex` | Dukungan Unicode/font custom |

### Karakter Khusus

| Command | Description |
|---------|-------------|
| `\% \$ \& \# \_` | Karakter khusus yang di-escape |
| `\textbackslash` | Backslash dalam teks |
| `\{ \}` | Kurung kurawal literal |
| ```text''` | Tanda kutip ganda cerdas |
| `---` | Em dash |
| `--` | En dash |

### Tips Berguna

| Command | Description |
|---------|-------------|
| `\label{} + \ref{}` | Referensi silang apa pun |
| `\input{file}` | Sertakan file .tex lain |
| `% comment` | Komentar satu baris |
| `\usepackage{lipsum}` | Teks dummy: `\lipsum[1-3]` |
