I have written a fairly standard matrix as an array since I wanted to have a matrix within it. Typeset as follows:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{array}
\usepackage{multirow}
\def\block(#1,#2)#3{\multicolumn{#2}{c}{\multirow{#1}{*}{$ #3 $}}}
\begin{document}
\[A =
\left(
\begin{array}{cccccc|cc}
1 & 1 & & & & & & \\
1 & 0 & 1 & & & & & \\
& 1 & 0 & \ddots & & & & \\
& & \ddots & \ddots & 1 & & & \\
& & & 1 & 0 & 1 & & \\
& & & & 1 & 0 & 1 & \\
\hline
& & & & & 1 & \block(2,2){M} \\
& & & & & & \\
\end{array}
\right)
\]
\end{document}
Annoyingly, there's extra spacing between some of the columns and rows: in particular, the second & third column and second & third row. Also seems like there's some issues between the third-to-last & second-to-last column in the top left matrix, though I'm not sure if that's because of \ddots.
Any ideas why this is happening and how I could potentially fix it?