2

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!

1 Answer 1

4

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}

\[
\left(
  \mbox{\large$
    \renewcommand{\arraystretch}{1.2}
    \begin{array}{c|c}
    0 & \mathrm{Id}_n \\
    \hline
    -\mathrm{Id}_n & 0 \\
    \end{array}
  $}% end of \mbox
\right)
\qquad
\left(
  \mbox{\large$
    \renewcommand{\arraystretch}{1.2}
    \begin{array}{c|c|c}  
    0 & 0 & 0 \\
    \hline
    0 & 0 & \mathrm{Id}_n \\
    \hline
    0 & -\mathrm{Id}_n & 0 \\
    \end{array}
  $}% end of \mbox
\right).
\]
\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.

enter image description here

1
  • 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, 2018 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .