Time Stalker: てきとーろぐ

メモを残したいものなどを雑に

TeX: マクロ

ようやく少し分かってきたのでメモ.

・通常は\def, \newcommandで定義.
 \newcommand{コマンド名}[引数の数][オプション]{定義}
・begin, endで記述する環境は\newenvironment.
 \newenvironment{環境名}[引数の数]{begin}{end}
・既存のものを書き換える場合には\renewcommand
・\newcounter{コマンド名}[カウントしたいもの]
オプションは引数#1の既定値になるので,本文中で#1を省略すると自動でコンパイル時に既定値が使われる.
e.g.) \newcommand{\test}[2][red]{\color{#1} \Large #2} と書いておくと,
  \test{text} → {\color{red} \Large text},
  \test[green]{text} → {\color{green} \Large text},
  になる.