我想用 排版矩阵matrix of math nodes
。但是,我在垂直居中方面遇到了麻烦。在下文中,我希望等号位于两个矩阵行的中间。
我怎样才能始终如一地实现这一目标?
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\tikzset{%
tikz matrix/.style={
matrix of math nodes,
minimum size=12pt,
row sep=1pt,
column sep=1pt,
left delimiter={\lbrack},
right delimiter={\rbrack},
inner xsep=0pt,
nodes in empty cells,
nodes={font=\footnotesize},
},
}
\begin{document}
\begin{equation*}
M =
\begin{tikzpicture}[baseline]
\matrix (m)[tikz matrix]{
1 & 2 & 9 & 3 \\
1 & -3 & -6 & 3 \\
};
\end{tikzpicture}
\end{equation*}
\end{document}
答案1
答案2
您无需设置baseline
,而是可以将tikzpicture
和 矩阵放在 内。为了进行比较,下面是您的矩阵和带有分隔符\vcenter{\hbox{...}}
的标准。matrix
Bigg
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\tikzset{%
tikz matrix/.style={
matrix of math nodes,
minimum size=12pt,
row sep=1pt,
column sep=1pt,
left delimiter={\lbrack},
right delimiter={\rbrack},
inner xsep=0pt,
nodes in empty cells,
nodes={font=\footnotesize},
},
}
\begin{document}
\begin{equation*}
M =\vcenter{\hbox{%
\begin{tikzpicture}
\matrix (m)[tikz matrix]{
1 & 2 & 9 & 3 \\
1 & -3 & -6 & 3 \\
};
\end{tikzpicture}}}\Biggl[\begin{matrix}1&2&9&3\\1&-3&-6&3\end{matrix}\Biggr]
\end{equation*}
\end{document}
答案3
您可以使用该calc
库来选择垂直对齐。
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{calc}
\tikzset{%
tikz matrix/.style={
matrix of math nodes,
minimum size=12pt,
row sep=1pt,
column sep=1pt,
left delimiter={\lbrack},
right delimiter={\rbrack},
inner xsep=0pt,
nodes in empty cells,
nodes={font=\footnotesize},
},
}
\begin{document}
\begin{equation*}
M =
\begin{tikzpicture}[baseline={($(m-1-1)!.5!(m-2-1)$)}]
\matrix (m)[tikz matrix]{
1 & 2 & 9 & 3 \\
1 & -3 & -6 & 3 \\
};
\end{tikzpicture}
\end{equation*}
\begin{equation*}
M =
\begin{tikzpicture}[baseline={([yshift=-.5ex]$(m-1-1)!.5!(m-2-1)$)}]
\matrix (m)[tikz matrix]{
1 & 2 & 9 & 3 \\
1 & -3 & -6 & 3 \\
};
\end{tikzpicture}
\end{equation*}
\end{document}
第一个例子是你的要求,第二个例子是我的建议。