![使用 tikzpicture 的小矩阵](https://linux22.com/image/389908/%E4%BD%BF%E7%94%A8%20tikzpicture%20%E7%9A%84%E5%B0%8F%E7%9F%A9%E9%98%B5.png)
我希望使用tikzpicture
而不是smallmatrix
,因为前者通过这个帖子.然而,代码
$\Z^4\!\xleftarrow{
\begin{tikzpicture}[baseline=(current bounding box.center)]
\matrix (m) [matrix of math nodes,nodes in empty cells,right delimiter={]},left delimiter={[} ]{
& & & & & \\ 1& & -1& & 1& \\ 1& & -1& & 1& \\ & 1& & -1& & 1\\};
\end{tikzpicture} }\!\Z^6$
返回错误(除非tikzpicture
超出\xleftarrow
)。如何获取
$\Z^4\!\xleftarrow{ \left[\!\begin{smallmatrix}&&&&&\vspace{6pt}\\ 1&&-\!1&&1&\\1&&-\!1&&1&\\ &1&&-\!1&&1\\\end{smallmatrix}\!\right]}\!\Z^6$
(一切紧密而小巧)使用tikzpicture
?
答案1
您需要ampersand replacement
保持&
不变。
\documentclass[border=7pt]{standalone}
\usepackage{mathtools,amssymb,tikz}
\usetikzlibrary{matrix}
\newcommand*{\Z}{\mathbb{Z}}
\begin{document}
$\Z^4\!\xleftarrow{%
\begin{tikzpicture}[baseline=(current bounding box.center)]
\matrix (m) [
matrix of math nodes,
nodes in empty cells,
right delimiter={]},
left delimiter={[},
ampersand replacement=\&, % <-- this is what you need
nodes={scale=.5}]
{
\& \& \& \& \& \\
1 \& \& -1 \& \& 1 \& \\
1 \& \& -1 \& \& 1 \& \\
\& 1 \& \& -1 \& \& 1 \\
};
\end{tikzpicture}%
}\!\Z^6$
\end{document}
答案2
这真是让人哭笑不得ampersand replacement
。
\documentclass{article}
\usepackage{mathtools}
\usepackage{bbm}
\newcommand{\Z}{\mathbbm{Z}}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
$\Z^4\!\xleftarrow{\vcenter{\hbox{
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,nodes in empty cells,right delimiter={]},
left delimiter={[},ampersand replacement=\&]{
\& \& \& \& \& \\ 1\& \& -1\& \& 1\& \\ 1\& \& -1\& \& 1\& \\ \& 1\& \& -1\& \& 1\\};
\end{tikzpicture} }}}\!\Z^6$
\end{document}