我想创建一个新的环境来绘制以下矩阵:
\begin{tikzpicture}[baseline,every right delimiter/.style={xshift=-8pt},every left delimiter/.style={xshift=8pt}]
\matrix [matrix of math nodes,left delimiter=(,right delimiter=)](m)
{
a \\
b \\
};
\end{tikzpicture}
因此我希望的环境是:
\begin{mymatrix}
a \\
b \\
\end{mymatrix}
然而,我没能成功。你知道该怎么做吗?
问候
答案1
您需要将环境主体作为宏参数来获取,因此:
\documentclass[a4paper,10pt]{report}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{environ}
\NewEnviron{mymatrix}{%
\begin{tikzpicture}[baseline,every right delimiter/.style={xshift=-8pt},every left delimiter/.style={xshift=8pt}]
\matrix [matrix of math nodes,left delimiter=(,right delimiter=),
ampersand replacement=\&](m)
{\BODY};\end{tikzpicture}}
\begin{document}
\begin{mymatrix}
a \\
b \\
\end{mymatrix}
\end{document}