[Tex/LaTex] Seemingly simple block matrix

blockmatrices

I have a seemingly simple block matrix that I want to set with as few dependencies as possible. I already have amsmath and friends loaded. The only thing I'm intent on avoiding is blkarray.

Here is what I want to make:

What I want to make

Here is a failed attempt of mine, which produces the most heinous spacing imaginable with lines that don't meet to make corners.

\begin{equation}
    \begin{pmatrix}[ccc]
        J_1 & \begin{array}{|cc}0 & 0\\ 0 & 0\end{array} & \begin{array}{cc}0 & 0\\ 0 & 0\end{array}\\ \cline{1-2}
        \begin{array}{cc|}0&0\\0&0\end{array} & J_2 & \begin{array}{|cc}0&0\\0&0\end{array}\\ \cline{2-3}
        \begin{array}{cc}0 & 0\\ 0 & 0\end{array} & \begin{array}{cc|}0 & 0\\ 0 & 0\end{array} & J_3
    \end{pmatrix}
\end{equation}

Which is ugly as all get-out:

My nasty failed attempt at it

NB: I have modified pmatrix so it takes column specs as an optional argument. Just pretend it is an array.

My difficulty seems to stem from the fact that I want 2×2 blocks, while most others I've seen seem to skate by using either multirow or multicolumn, but not both.

Edit:
This isn't nearly as ugly, but the vertical lines only cover half the distance of the multirow:

\begin{equation}
    \begin{array}{cccccc}
        \multicolumn{2}{c|}{\multirow{2}{*}{$J_1$}} & 0 & 0 & 0 & 0\\
                                                   & & 0 & 0 & 0 & 0\\ \cline{1-4}
        0 & 0 & \multicolumn{2}{|c|}{\multirow{2}{*}{$J_1$}} & 0 & 0\\
        0 & 0 &                                           & & 0 & 0\\ \cline{3-6}
        0 & 0 & 0 & 0 & \multicolumn{2}{|c}{\multirow{2}{*}{$J_1$}} \\
        0 & 0 & 0 & 0 & & \\
    \end{array}
\end{equation}

Better, but still not there.

Best Answer

The fundamental part of the matrix construction looks like this:

enter image description here

\documentclass{article}
\newcommand{\mc}{\multicolumn{1}{c}}
\begin{document}

\[
  \renewcommand{\arraystretch}{1.2}
  \left(
  \begin{array}{ c c | c c | c c }
    \multicolumn{1}{|c}{} & & 0 & \mc{0} & 0 & 0 \\
    \multicolumn{2}{|c|}{\raisebox{.6\normalbaselineskip}[0pt][0pt]{$J_1$}} & 0 & \mc{0} & 0 & 0 \\
    \cline{1-4}
    0 & 0 & & & 0 & 0 \\
    0 & 0 & \multicolumn{2}{c|}{\raisebox{.6\normalbaselineskip}[0pt][0pt]{$J_2$}} & 0 & 0 \\
    \cline{3-6}
    0 & \mc{0} & 0 & 0 & & \multicolumn{1}{c|}{} \\
    0 & \mc{0} & 0 & 0 & \multicolumn{2}{c|}{\raisebox{.6\normalbaselineskip}[0pt][0pt]{$J_3$}}
  \end{array}
  \right)
\]

\end{document}

Perhaps it would be best to assign variables to the other components (like A and B) in order to maintain the matrix spacing.

Related Question