# LaTeX 빠른 참조

*문서 구조, 수식, 표, 그림 등*

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

## 문서 구조

### 최소 문서

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

### 문서 클래스

| Command | Description |
|---------|-------------|
| `article` | 짧은 문서, 논문, 보고서 |
| `report` | 챕터가 있는 긴 문서 |
| `book` | 부, 챕터가 있는 전체 책 |
| `beamer` | 슬라이드 프레젠테이션 |
| `letter` | 공식 편지 |

### 프리앰블

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

### 섹션 나누기

| Command | Description |
|---------|-------------|
| `\part{}` | 최상위 구분 (book/report) |
| `\chapter{}` | 챕터 (report/book만 해당) |
| `\section{}` | 섹션 |
| `\subsection{}` | 서브섹션 |
| `\subsubsection{}` | 서브서브섹션 |
| `\paragraph{}` | 이름 있는 단락 |

## 텍스트 서식

### 폰트 스타일

| Command | Description |
|---------|-------------|
| `\textbf{bold}` | **굵은** 텍스트 |
| `\textit{italic}` | *기울임* 텍스트 |
| `\underline{text}` | 밑줄 텍스트 |
| `\texttt{code}` | 고정폭 / 타이프라이터 |
| `\textsc{Small Caps}` | 소형 대문자 |
| `\emph{emphasis}` | 강조 (컨텍스트 인식 기울임) |

### 폰트 크기

| Command | Description |
|---------|-------------|
| `\tiny` | 가장 작음 |
| `\small` | 기본보다 작음 |
| `\normalsize` | 기본 크기 |
| `\large / \Large` | 크게 / 더 크게 |
| `\huge / \Huge` | 매우 크게 / 가장 크게 |

### 간격 및 줄바꿈

| Command | Description |
|---------|-------------|
| `\\` | 줄바꿈 |
| `\newpage` | 페이지 나누기 |
| `\vspace{1cm}` | 수직 간격 |
| `\hspace{1cm}` | 수평 간격 |
| `\noindent` | 단락 들여쓰기 억제 |
| `~` | 줄바꿈 없는 공백 |

## 수식 모드

### 인라인 및 디스플레이 수식

```
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}
```

### 주요 기호

| Command | Description |
|---------|-------------|
| `^ and _` | 위첨자 / 아래첨자: `x^2`, `a_i` |
| `\frac{a}{b}` | 분수: a/b |
| `\sqrt{x} / \sqrt[3]{x}` | 제곱근 / 세제곱근 |
| `\sum_{i=1}^{n}` | 합산 |
| `\int_a^b` | 적분 |
| `\lim_{x \to 0}` | 극한 |
| `\infty` | 무한대 기호 |

### 그리스 문자

| Command | Description |
|---------|-------------|
| `\alpha \beta \gamma \delta` | 소문자 그리스 |
| `\Gamma \Delta \Theta \Lambda` | 대문자 그리스 |
| `\epsilon \sigma \omega \pi` | 추가 소문자 그리스 |
| `\mu \nu \rho \tau \phi` | 통계/물리학에서 자주 쓰이는 문자 |

### 행렬

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

## 환경

### 주요 환경

| Command | Description |
|---------|-------------|
| `document` | 본문 영역 |
| `equation` | 번호 있는 수식 |
| `align` | 정렬된 여러 줄 수식 |
| `figure` | 플로팅 그림 |
| `table` | 플로팅 표 |
| `verbatim` | 리터럴 텍스트 (서식 없음) |
| `abstract` | 초록 블록 (article) |

### 정렬된 수식

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

## 목록 및 표

### 목록

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

### 표

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

### 컬럼 지정자

| Command | Description |
|---------|-------------|
| `l / c / r` | 왼쪽 / 가운데 / 오른쪽 정렬 |
| `\|` | 컬럼 사이 수직선 |
| `p{3cm}` | 단락 컬럼 (고정 너비) |
| `\hline` | 수평선 |
| `\cline{2-3}` | 부분 수평선 (2-3열) |

## 그림

### 이미지 포함

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

### 배치 지정자

| Command | Description |
|---------|-------------|
| `h` | 현재 위치 (대략적) |
| `t` | 페이지 상단 |
| `b` | 페이지 하단 |
| `p` | 특별 플로트 페이지 |
| `!` | 내부 제약 무시 |
| `H` | 정확히 현재 위치 (`float` 패키지 필요) |

### 상호 참조

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

## 참고문헌

### BibTeX 워크플로우

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

### 문서 내 인용

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

### 참고문헌 스타일

| Command | Description |
|---------|-------------|
| `plain` | 번호 지정, 알파벳순 정렬 |
| `unsrt` | 번호 지정, 인용 순서 |
| `abbrv` | plain과 유사, 이름 축약 |
| `apalike` | 저자-연도 형식 (APA 유사) |

## 패키지

### 필수 패키지

| Command | Description |
|---------|-------------|
| `amsmath` | 고급 수식 환경 |
| `graphicx` | 이미지 포함 |
| `hyperref` | 클릭 가능한 링크 및 참조 |
| `geometry` | 페이지 여백: `\usepackage[margin=1in]{geometry}` |
| `booktabs` | 전문적인 표 (`\toprule`, `\midrule`) |
| `xcolor` | 텍스트 및 배경 색상 |
| `listings` | 소스 코드 목록 |
| `tikz` | 프로그래밍 방식의 그래픽 및 다이어그램 |
| `babel` | 다국어 지원 |
| `natbib` | 유연한 인용 (저자-연도, 숫자) |

## 커스텀 명령어

### 새 명령어

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

### 명령어 갱신 및 환경

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

### 유용한 단축어

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

## 주요 패턴

### 제목 페이지

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

### 컴파일

| Command | Description |
|---------|-------------|
| `pdflatex doc.tex` | PDF로 컴파일 |
| `bibtex doc` | 참고문헌 처리 |
| `latexmk -pdf doc.tex` | 자동 컴파일 (재실행 처리) |
| `xelatex doc.tex` | 유니코드/커스텀 폰트 지원 |

### 특수 문자

| Command | Description |
|---------|-------------|
| `\% \$ \& \# \_` | 예약 문자 이스케이프 |
| `\textbackslash` | 텍스트 내 백슬래시 |
| `\{ \}` | 리터럴 중괄호 |
| ```text''` | 스마트 큰따옴표 |
| `---` | 긴 대시 (em dash) |
| `--` | 중간 대시 (en dash) |

### 유용한 팁

| Command | Description |
|---------|-------------|
| `\label{} + \ref{}` | 어디에나 상호 참조 |
| `\input{file}` | 다른 .tex 파일 포함 |
| `% comment` | 한 줄 주석 |
| `\usepackage{lipsum}` | 더미 텍스트: `\lipsum[1-3]` |
