3

How can one construct the following matrix, where each block is a $3\times 3$ matrix by itself?

Enter image description here

3 Answers 3

8

Nest array in array:

\documentclass{article}
\usepackage{amsmath,array}

\begin{document}

\[
\setlength{\arraycolsep}{0pt}
\left(\begin{array}{c|c|c}
  \begin{array}{*{3}{w{c}{1em}}}
  1 & \cdot & \cdot \\
  \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot
  \end{array}
  &
  \begin{array}{*{3}{w{c}{1em}}}
  \cdot & \cdot & \cdot \\
  \cdot & 1 & \cdot \\
  \cdot & \cdot & \cdot
  \end{array}
  &
  \begin{array}{*{3}{w{c}{1em}}}
  \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot \\
  \cdot & \cdot & 1
  \end{array}
\\ \hline
  \begin{array}{*{3}{w{c}{1em}}}
  \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot \\
  \cdot & 1 & \cdot
  \end{array}
  &
  \begin{array}{*{3}{w{c}{1em}}}
  \cdot & \cdot & 1 \\
  \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot
  \end{array}
  &
  \begin{array}{*{3}{w{c}{1em}}}
  \cdot & \cdot & \cdot \\
  1 & \cdot & \cdot \\
  \cdot & \cdot & \cdot
  \end{array}
\\ \hline
  \begin{array}{*{3}{w{c}{1em}}}
  \cdot & \cdot & \cdot \\
  \cdot & \cdot & 1 \\
  \cdot & \cdot & \cdot
  \end{array}
  &
  \begin{array}{*{3}{w{c}{1em}}}
  \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot \\
  1 & \cdot & \cdot
  \end{array}
  &
  \begin{array}{*{3}{w{c}{1em}}}
  \cdot & 1 & \cdot \\
  \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot
  \end{array}
\end{array}\right)
\]

\end{document}

The main trick is to use zero space between columns and fixed width cells.

enter image description here

Just for fun, a better way to specify those blocks with a single 1.

\documentclass{article}
\usepackage{amsmath,array}

\ExplSyntaxOn

\NewDocumentCommand{\dotblock}{mmm}
 {% #1 is the size, #2 the row for the 1, #3 the column for the 1
  \userci_dotblock:nnn { #1 } { #2 } { #3 }
 }

\tl_new:N \l_userci_dotblock_body_tl

\cs_new_protected:Nn \userci_dotblock:nnn
 {
  \tl_clear:N \l_userci_dotblock_body_tl
  \int_step_inline:nn { #1 }
   {%
    \int_step_inline:nn { #1 }
     {% ##1 = row index, ####1 = column index
      \tl_put_right:Nx \l_userci_dotblock_body_tl
       {
        \bool_lazy_and:nnTF
         { \int_compare_p:n { ##1=#2 } }
         { \int_compare_p:n { ####1=#3 } }
         { 1 }
         { \cdot }
        \int_compare:nF { ####1 = #1 } { & } 
       }
     }
    \tl_put_right:Nn \l_userci_dotblock_body_tl { \\ }
   }
  \begin{array}{*{#1}{w{c}{1em}}}
  \tl_use:N \l_userci_dotblock_body_tl
  \end{array}
 }

\ExplSyntaxOff
\begin{document}

\[
\setlength{\arraycolsep}{0pt}
\left(\begin{array}{c|c|c}
  \dotblock{3}{1}{1}
  &
  \dotblock{3}{2}{2}
  &
  \dotblock{3}{3}{3}
\\ \hline
  \dotblock{3}{3}{2}
  &
  \dotblock{3}{1}{3}
  &
  \dotblock{3}{2}{1}
\\ \hline
  \dotblock{3}{2}{3}
  &
  \dotblock{3}{3}{1}
  &
  \dotblock{3}{1}{2}
\end{array}\right)
\]

\end{document}
7

You can nest an array within a pmatrix:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\begin{document}

    \[ \begin{pmatrix}
      \begin{array}{ccc|ccc|ccc}
        1 & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
        \cdot & \cdot & \cdot & \cdot & 1 & \cdot & \cdot & \cdot & \cdot \\
        \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & 1 \\
        \hline
       \cdot & \cdot & \cdot & \cdot & \cdot & 1 & \cdot & \cdot & \cdot \\
        \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & 1 & \cdot & \cdot \\
        \cdot & 1 & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
        \hline
       \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & 1 & \cdot \\
        \cdot & \cdot & 1 & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
        \cdot & \cdot & \cdot & 1 & \cdot & \cdot & \cdot& \cdot & \cdot
      \end{array}
    \end{pmatrix} \]%

\end{document} 

enter image description here

4

You can use a {array} and add parenthesis with \left-\right.

\documentclass{article}

\begin{document}

$\left(
\begin{array}{@{}ccc|ccc|ccc@{}}
1     & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
\cdot & \cdot & \cdot & \cdot & 1     & \cdot & \cdot & \cdot & \cdot \\
\cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & 1     \\ 
\hline
\cdot & \cdot & \cdot & \cdot & \cdot & 1     & \cdot & \cdot & \cdot \\
\cdot & \cdot & \cdot & \cdot & \cdot & \cdot & 1     & \cdot & \cdot \\
\cdot & 1     & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
\hline
\cdot & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot & 1     & \cdot \\
\cdot & \cdot & 1     & \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
\cdot & \cdot & \cdot & 1     & \cdot & \cdot & \cdot & \cdot & \cdot \\
\end{array}
\right)$

\end{document}

Output of the above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.