
\newcommand
コマンドへの引数が環境で囲まれるようにコマンド マクロを定義するにはどうすればよいですか?
答え1
または 、あるいは既知の接頭辞のいずれか(例: 、 、 )のいずれかb
であるオプションの引数を使用して、それが可能であることの証明。p
v
B
V
それに加えて、私の見解では、コードの可読性は向上しません。
\documentclass{article}
\usepackage{amsmath}
\newcommand{\mat}[2][b]{%
\begin{#1matrix}
#2
\end{#1matrix}
}
\begin{document}
$\mat{ 1 & 2 \\ 3 & 4 \\}$ and $ \mat[p]{ 1 & 2 \\ 3 & 4 \\}$ and $\mat[B]{ 1 & 2 \\ 3 & 4 \\}$ and $\mat[v]{ 1 & 2 \\ 3 & 4 \\}$ and $ \mat[V]{ 1 & 2 \\ 3 & 4 \\}$
\end{document}