mcpField
A
amsmath

amsmath

github.com/igbuendドキュメント938 回インストール33 週間前に更新
リポジトリ

amsmath について

amsmathは、LaTeXの数式組版を扱うスキルで、amsmath、amssymb、mathtools、amsthmの一般的な使い方をまとめています。数式、記号、行列、定理環境を扱う文書作成者向けです。

主な機能

  1. 01複数行の数式と整列環境
  2. 02場合分け関数と行列の組版
  3. 03数式テキスト・記号・演算子の参照
  4. 04定理環境とスタイルの設定
  5. 05よくある組版問題と修正方法

活用シーン

  1. 01複数行の導出や連立方程式を組版
  2. 02行列や場合分け関数を含む文書を作成
  3. 03定理・補題・証明の環境を設定

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/igbuend/grimbard --skill amsmath

インストール後、Claude Code で/amsmathを入力して読み込まれたか確認します。

詳細

amsmath + amssymb + mathtools — 数式の組版

CTAN: https://ctan.org/pkg/amsmath | https://ctan.org/pkg/mathtools
マニュアル: texdoc amsmath、texdoc mathtools

セットアップ

\usepackage{amsmath}    % core math environments
\usepackage{amssymb}    % extra symbols (loads amsfonts)
\usepackage{mathtools}  % fixes + extensions for amsmath (loads amsmath)
\usepackage{amsthm}     % theorem environments

% mathtools loads amsmath, so you can just use:
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsthm}

数式環境

単一の数式
% Numbered
\begin{equation}
  E = mc^2
  \label{eq:einstein}
\end{equation}

% Unnumbered
\begin{equation*}
  E = mc^2
\end{equation*}
% or: \[ E = mc^2 \]
align — 複数の数式を揃える
\begin{align}
  f(x) &= x^2 + 2x + 1 \label{eq:f} \\
       &= (x+1)^2       \label{eq:f2}
\end{align}

% Unnumbered: align*
% Suppress single number: \nonumber or \notag before \\
gather — 揃えずに中央揃え
\begin{gather}
  x + y = 1 \\
  x - y = 3
\end{gather}
multline — 長い単一の数式
\begin{multline}
  f(x) = a_0 + a_1 x + a_2 x^2 + a_3 x^3 \\
    + a_4 x^4 + a_5 x^5 + a_6 x^6
\end{multline}

最初の行は左揃え、最後の行は右揃え、中間の行は中央揃えになります。

split — equation 内での部分的な揃え
\begin{equation}
\begin{split}
  f(x) &= a + b + c \\
       &\quad + d + e
\end{split}
\end{equation}

グループ全体に対して数式番号が1つ付きます。

cases
\begin{equation}
  |x| = \begin{cases}
    x  & \text{if } x \geq 0 \\
    -x & \text{if } x < 0
  \end{cases}
\end{equation}

% mathtools: dcases (displaystyle), rcases (right brace)
\begin{dcases}
  \frac{x}{2} & x > 0 \\
  0            & x = 0
\end{dcases}
aligned / gathered — インラインのサブ環境
% Use inside equation or \[ \] for sub-alignment
\begin{equation}
  \left\{
  \begin{aligned}
    2x + 3y &= 7 \\
    x - y   &= 1
  \end{aligned}
  \right.
\end{equation}
subequations
\begin{subequations} \label{eq:system}
\begin{align}
  x + y &= 1 \label{eq:system_a} \\
  x - y &= 3 \label{eq:system_b}
\end{align}
\end{subequations}
% Produces (1a), (1b)

環境の概要

環境揃え方番号付け用途
equation中央揃え1つの番号単一の数式
align& 列行ごと揃えた数式
gather中央揃え行ごと互いに関連しない数式
multline最初は左、最後は右1つの番号長い数式
split& 列1つの番号(親)equation 内で部分的に揃える
cases& 列なし(equation 内)区分的な関数
aligned& 列なし(equation 内)インラインで部分的に揃える
flalign& 列行ごと全幅で揃える

番号なしのバリエーションを使うには * を追加します(split、aligned、gathered を除く)。

数式内のテキスト

\text{if }           % normal text (respects surrounding font)
\mathrm{const}       % upright roman
\textit{word}        % italic text
\mathit{diff}        % math italic (different spacing than default)
\mathbf{v}           % bold (not for Greek — use \boldsymbol)
\boldsymbol{\alpha}  % bold Greek
\mathbb{R}           % blackboard bold: ℝ (amssymb)
\mathcal{L}          % calligraphic: ℒ
\mathfrak{g}         % Fraktur (amssymb)
\mathsf{X}           % sans-serif
\mathtt{code}        % monospace
\operatorname{span}  % upright operator (one-off)

数式内のスペース

コマンド幅例
\,3/18 em(細)\int f(x)\, dx
\: または \>4/18 em(中)
\;5/18 em(太)
\!−3/18 em(負の細スペース)詰めるには \!\!
\quad1 emx \quad y
\qquad2 em
\phantom{x}「x」の幅のスペース揃えに使う
\hphantom{x}水平方向のみ
\vphantom{x}垂直方向のみ

演算子

% Built-in: \sin, \cos, \tan, \log, \ln, \exp, \min, \max,
%   \sup, \inf, \lim, \det, \dim, \ker, \gcd, \Pr, \hom, ...

% Custom operator (preamble)
\DeclareMathOperator{\tr}{tr}       % like \sin
\DeclareMathOperator*{\argmax}{arg\,max}  % limits below in display

% Usage
\tr(A) = \sum_i a_{ii} \qquad x^* = \argmax_x f(x)

行列

\begin{pmatrix} a & b \\ c & d \end{pmatrix}   % ( )
\begin{bmatrix} a & b \\ c & d \end{bmatrix}   % [ ]
\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}   % { }
\begin{vmatrix} a & b \\ c & d \end{vmatrix}   % | |  (determinant)
\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}   % ‖ ‖
\begin{matrix}  a & b \\ c & d \end{matrix}    % no delimiters

% Small inline matrix
$\bigl(\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}\bigr)$

列の既定の最大数 = 10。 さらに増やすには、\setcounter{MaxMatrixCols}{20} を指定します。

区切り記号

% Auto-sizing (use sparingly — can oversize)
\left( \frac{a}{b} \right)
\left[ \sum_i x_i \right]
\left\{ x \in \mathbb{R} \mid x > 0 \right\}
\left. \frac{df}{dx} \right|_{x=0}   % \left. = invisible delimiter

% Manual sizing (preferred for control)
\bigl(  \bigr)    % slightly bigger
\Bigl(  \Bigr)    % bigger
\biggl( \biggr)   % even bigger
\Biggl( \Biggr)   % biggest

% mathtools paired delimiters (best approach)
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\DeclarePairedDelimiter\set{\{}{\}}

% Usage:
\abs{x}       % |x|  (no sizing)
\abs*{x}      % \left|x\right|  (auto-sizing)
\abs[\big]{x} % \bigl|x\bigr|  (manual)

mathtools の追加機能

% Colon equals
\coloneqq   % :=
\eqqcolon   % =:

% dcases (displaystyle fractions in cases)
\begin{dcases} ... \end{dcases}

% rcases (right brace)
\begin{rcases} ... \end{rcases}

% Short intertext (less vertical space than \intertext)
\begin{align}
  f(x) &= x^2 \\
  \shortintertext{where}
  x &> 0
\end{align}

% Prescript (left sub/superscript)
\prescript{14}{6}{\mathrm{C}}   % ¹⁴₆C

% Cramped styles
\cramped{x^{x^x}}  % reduces height

% Smashed operator limits
\smashoperator{\sum_{i=1}^{n}}

記号一覧

ギリシャ文字
小文字大文字小文字大文字
\alpha α—\nu ν—
\beta β—\xi ξ\Xi Ξ
\gamma γ\Gamma Γ\pi π\Pi Π
\delta δ\Delta Δ\rho ρ—
\epsilon ε—\sigma σ\Sigma Σ
\varepsilon ε—\tau τ—
\zeta ζ—\upsilon υ\Upsilon Υ
\eta η—\phi ϕ\Phi Φ
\theta θ\Theta Θ\varphi φ—
\iota ι—\chi χ—
\kappa κ—\psi ψ\Psi Ψ
\lambda λ\Lambda Λ\omega ω\Omega Ω
\mu μ—

異形: \varepsilon、\vartheta、\varphi、\varrho、\varsigma

関係記号
記号コマンド記号コマンド
≤\leq≥\geq
≪\ll≫\gg
≠\neq≈\approx
∼\sim≃\simeq
≡\equiv≅\cong
∝\propto∈\in
∉\notin⊂\subset
⊆\subseteq⊃\supset
⊇\supseteq⊄\not\subset
≺\prec≻\succ
⊥\perp∥\parallel
⊢\vdash⊣\dashv
⊨\models
二項演算子
記号コマンド記号コマンド
±\pm∓\mp
×\times÷\div
·\cdot∗\ast
⊕\oplus⊗\otimes
∪\cup∩\cap
∨\vee∧\wedge
∘\circ•\bullet
†\dagger‡\ddagger
矢印
記号コマンド記号コマンド
→\to / \rightarrow←\leftarrow
⇒\Rightarrow⇐\Leftarrow
↔\leftrightarrow⇔\Leftrightarrow
↦\mapsto⟶\longrightarrow
↑\uparrow↓\downarrow
⇑\Uparrow⇓\Downarrow
↗\nearrow↘\searrow
⟹\implies⟸\impliedby
⟺\iff
↪\hookrightarrow↠\twoheadrightarrow
大型演算子
記号コマンド記号コマンド
∑\sum∏\prod
∫\int∮\oint
∬\iint∭\iiint
⋃\bigcup⋂\bigcap
⨁\bigoplus⨂\bigotimes
⋁\bigvee⋀\bigwedge
∐\coprod
点
コマンド出力用途
\cdots⋯演算子の間:$a + \cdots + z$
\ldots…リスト内:$a_1, \ldots, a_n$
\vdots⋮垂直方向
\ddots⋱対角方向(行列)
その他の記号(amssymb)
記号コマンド記号コマンド
ℝ\mathbb{R}ℂ\mathbb{C}
ℤ\mathbb{Z}ℕ\mathbb{N}
ℚ\mathbb{Q}∅\emptyset / \varnothing
∞\infty∂\partial
∇\nablaℓ\ell
ℏ\hbar∀\forall
∃\exists¬\neg
√\sqrt{x}ⁿ√\sqrt[n]{x}
∠\angle△\triangle
⊤\top⊥\bot
♠\spadesuit♣\clubsuit
アクセント
コマンド結果用途
\hat{a}â単位ベクトル
\bar{a}ā平均、共役
\vec{a}a⃗ベクトル
\dot{a}ȧ時間微分
\ddot{a}ä2階微分
\tilde{a}ã近似
\widehat{abc}幅広のハット範囲を覆う
\widetilde{abc}幅広のチルダ範囲を覆う
\overline{abc}上線集合、共役
\underline{abc}下線
\overbrace{a+b}^{n}上括弧グループ化
\underbrace{a+b}_{n}下括弧グループ化

定理環境(amsthm)

\usepackage{amsthm}

% Define theorem types (preamble)
\newtheorem{theorem}{Theorem}[section]     % numbered by section
\newtheorem{lemma}[theorem]{Lemma}         % shares theorem counter
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}[theorem]{Proposition}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}

% Usage
\begin{theorem}[Pythagoras]
  For a right triangle: $a^2 + b^2 = c^2$.
\end{theorem}

\begin{proof}
  Obvious. % ends with □ automatically
  % Use \qedhere to place □ at end of equation:
  % \[ a^2 + b^2 = c^2 \qedhere \]
\end{proof}
定理スタイル
スタイル本文のフォント見出し用途
plain(デフォルト)イタリック太字定理、補題
definition立体太字定義、例
remark立体イタリック備考、注記

よくある問題

問題原因対処法
$$...$$TeX プリミティブで、間隔が不適切\[...\] または equation* を使用する
eqnarray= の周囲の間隔が不適切代わりに align を使用する(常に)
数式番号が誤った行に表示される最終行の後に \\ がある末尾の \\ を削除する
複数行にまたがる \left...\right\\ をまたげない手動で \bigl...\bigr を使用する
ギリシャ文字を太字にできない\mathbf が機能しない\boldsymbol{\alpha} を使用する
\displaystyle がないインラインの分数が小さい\dfrac(または \displaystyle\frac)を使用する
:= の間隔が不適切コロンが関係演算子として扱われる\coloneqq(mathtools)を使用する
\mid と | と `` の違い間隔がそれぞれ異なる
数式で hbox がはみ出す数式の幅が広すぎるmultline、split、または手動の改行を使用する
証明ボックスが表示されない環境内で \qed を使用している末尾に \qedhere を使用する

コメント