# 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` | Unicode / カスタムフォントのサポート |

### 特殊文字

| Command | Description |
|---------|-------------|
| `\% \$ \& \# \_` | エスケープされた予約文字 |
| `\textbackslash` | テキスト内のバックスラッシュ |
| `\{ \}` | リテラルの波括弧 |
| ```text''` | スマートダブルクォート |
| `---` | em ダッシュ |
| `--` | en ダッシュ |

### 便利なヒント

| Command | Description |
|---------|-------------|
| `\label{} + \ref{}` | 任意のものへの相互参照 |
| `\input{file}` | 別の .tex ファイルをインクルード |
| `% comment` | 単一行コメント |
| `\usepackage{lipsum}` | ダミーテキスト：`\lipsum[1-3]` |
