# Doing block matrices with array environment

I am used to writing block matrices using the array environment, when these matrices are decomposed in four blocks, controlling vertical spacing and using \hfill, etc.. Now I wanted to draw a matrix decomposed in nine blocks, but the vertical lines made by the array environment broke up. How can I fix it without completely changing the approach? (say, I'm not interested in solutions using tikz, at least for now).

Here's a MWE (done in Overleaf):

\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage{amsmath}
\usepackage{graphicx}

\begin{document}

$\left( \begin{array}{c|c} \mbox{\large 0} & \mbox{\large {\rm Id}_n} \\[.7ex] \hline \\[-1.5ex] \mbox{\large -{\rm Id}_n} & \mbox{\large 0}\\ \end{array} \right) \qquad \left( \begin{array}{c|c|c} \mbox{\large 0} & \mbox{\large 0} & \mbox{\large 0} \\[.7ex] \hline \\[-1.5ex] \mbox{\large 0} & \mbox{\large 0} & \mbox{\large {\rm Id}_n} \\[.7ex] \hline \\[-1.5ex] \mbox{\large 0} & \mbox{\large -{\rm Id}_n} & \mbox{\large 0}\\ \end{array} \right).$
\end{document}


Thanks!

Instead of doing \large in every cell, do it globally for the array. Don't use \\ after \hline.

\documentclass[a4paper]{article}
\usepackage{amsmath}

\begin{document}

\end{document}


I removed all unnecessary packages. Don't use utf8x for it's been unmaintained for several years, but utf8. Note also that \rm has been deprecated for more than 20 years.

• This is exactly what I wanted, thanks a lot! The package utf8x came in the Overleaf template I used to write the MWE, and I'm too lazy to type \mathrm instead of \rm (at least in my own notes, when I don't have to share the .tex file with other people), but I'll try to get used to it. – Ivo Terek Mar 17 '18 at 21:42