[Tex/LaTex] Diagonal dots spanning multiple lines/columns of a matrix

amsmathformattingmath-modematrices

I'm filling in large sparse matrices, for example

\begin{bmatrix}
0  & -2     & 1      &        & -1     & 2  \\
2  & \ddots & \ddots & \ddots &        & -1 \\
-1 & \ddots & \ddots & \ddots & \ddots &    \\
   & \ddots & \ddots & \ddots & \ddots & 1  \\
1  &        & \ddots & \ddots & \ddots & -2 \\
-2 & 1      &        & -1     & 2      & 0
\end{bmatrix}

enter image description here

I do not like the way the dots are spaced. I would like them to be equally spaced across the diagonals. I guess this can be done using TikZ but is there an easier way?

Best Answer

It's not difficult with TikZ. I have just removed the ddots

\documentclass{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{matrix}
\begin{document}
Following quadratic form involves a skew symmetric matrix. 
\begin{equation}
\begin{pmatrix}
    a\\b\\\vdots\\z
\end{pmatrix}^T
\begin{tikzpicture}[baseline=(current bounding box.center)]
\matrix (m) [matrix of math nodes,nodes in empty cells,right delimiter={]},left delimiter={[} ]{
0  & -2 & 1  &  & -1 & 2  \\
2  & & & & & -1 \\
-1 & & & & &    \\
   & & & & & 1  \\
1  & & & & & -2 \\
-2 &1 & & -1 & 2 & 0\\
} ;
\draw[loosely dotted] (m-1-1)-- (m-6-6);
\draw[loosely dotted] (m-1-2)-- (m-5-6);
\draw[loosely dotted] (m-2-1)-- (m-6-5);
\end{tikzpicture}\begin{pmatrix}
    a\\b\\\vdots\\z
\end{pmatrix}=0
\label{eq:eqq1}
\end{equation}

\end{document}

enter image description here

It looks slightly faint in the picture but if you wish you can add the option thick to the draw commands.