我用 tikz 画了这个矩阵,但你可以看到,这些框不是正方形。我该如何解决这个问题?我定义了
\usepackage{tikz}
\usetikzlibrary{arrows,matrix,positioning}
\newcommand\bigzero{\makebox(0,0){\text{\huge0}}}
接下来是我的矩阵
\begin{equation}\label{eqn:mat}
\begin{tikzpicture}[baseline=(current bounding box.center)]
\matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)
{
0&1\\
-1&0&&&&\bigzero\\
&&0&1\\
&&-1&0\\
&&&&\ddots\\
&\bigzero&&&&0&1\\
&&&&&-1&0\\
};
\draw (m-1-1.north west) -- (m-1-2.north east) -- (m-2-2.south east) -- (m-2-1.south west) -- (m-1-1.north west);
\draw (m-3-3.north west) -- (m-3-4.north east) -- (m-4-4.south east) -- (m-4-3.south west) -- (m-3-3.north west);
\draw (m-6-6.north west) -- (m-6-7.north east) -- (m-7-7.south east) -- (m-7-6.south west) -- (m-6-6.north west);
\end{tikzpicture}
\end{equation}
答案1
\documentclass{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{matrix,positioning,fit}
\newcommand\bigzero{\makebox(0,0){\text{\huge0}}}
\begin{document}
\begin{equation}\label{eqn:mat}
\begin{tikzpicture}[baseline=(current bounding box.center)]
\matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)
{
0&1\\
-1&0&&&&\bigzero\\
&&0&1\\
&&-1&0\\
&&&&\ddots\\
&\bigzero&&&&0&1\\
&&&&&-1&0\\
};
\node[draw,fit=(m-1-1) (m-2-2),inner sep=0pt]{};
\node[draw,fit=(m-3-3) (m-4-4),inner sep=0pt]{};
\node[draw,fit=(m-6-6) (m-7-7),inner sep=0pt]{};
\end{tikzpicture}
\end{equation}
\end{document}