14

I wish to write the following block matrix in LaTex.

enter image description here

I have been trying a bunch of stuff, but none of it seems to work. In particular, I tried the following:

\begin{bmatrix}
0 & -1&        &         &          &        & 0    &         &       &         &\\
1 & 0 &        &         &          &        &      &         &       &         &\\
  &   & \cdot  &         &          &        &      &         &       &         &\\
  &   &        & \cdot   &          &        &      &         &       &         &\\
  &   &        &         & \cdot    &        &      &         &       &         &\\
  &   &        &         &          & 0      & 1    &         &       &         &\\
  &   &        &         &          &-1      & 0    &         &       &         &\\
  &   &        &         &          &        &      & \cdot  &        &        &\\
  &   &        &         &          &        &      &         & \cdot &        &  \\ 
  &   &        &         &          &        &      &         &        &  \cdot & \\
0 &   &        &         &          &        &      &         &        &         &  0\\ 
\end{bmatrix}

But this is pretty ugly and so any suggestions will be much appreciated.

Student
  • 567

5 Answers5

13

Perhaps

$\left(\begin{array}{cccccc}
\left[\begin{array}{cc}
0 & 1\\
-1 & 0
\end{array}\right] &  &  &  &  & 0\\
 & \ddots\\
 &  & \left[\begin{array}{cc}
0 & 1\\
-1 & 0
\end{array}\right]\\
 &  &  & 0\\
 &  &  &  & \ddots\\
0 &  &  &  &  & 0
\end{array}\right)$  

enter image description here

riccs_0x
  • 1,087
9

Just for the fun of it! :-)

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

\begin{document}

\[
\begin{pmatrix}
\newcommand{\lr}[1]{\multicolumn{1}{|c}{#1}}
\newcommand{\rr}[1]{\multicolumn{1}{c|}{#1}}
\;
\begin{array}{@{}*{10}{c}@{}}
\cline{1-2}
\lr{0} & \rr{1} &&&&&&&& \raisebox{-1em}[0pt][0pt]{$0$}\\
\lr{-1} & \rr{0} \\
\cline{1-2}
&& \ddots \\
\cline{4-5}
&&& \lr{0} & \rr{1} \\
&&& \lr{-1} & \rr{0} \\
\cline{4-5}
&&&&& 0 \\[-1ex]
&&&&&& \ddots \\
&&&&&&& 0 \\[-1ex]
&&&&&&&& \ddots \\
\multicolumn{2}{c}{0} &&&&&&&& 0
\end{array}
\;\;
\end{pmatrix}
\]

\end{document}

enter image description here

egreg
  • 1,121,712
8

Here there is my proposal as the original picture using \bmatx command that replace a boxed matrix.

enter image description here

\documentclass{article}
\usepackage{mathtools}
\newcommand{\bmatx}{\boxed{\begin{matrix} 0&  1  \\ -1&  0\end{matrix}}}

\begin{document}
\[
\begin{pmatrix}
\, \bmatx&  &  &  &  & & & 0 \\ 
 &  \ddots&  &  &  & \\ 
 &  &  \bmatx &  &  & & \\ 
 &  &  &  \ddots&  & &\\ 
 &  &  &  & 0 & &\\ 
 &  &  &  &  &  & \ddots\\ 
0 &  &  &  &  &  & & 0 
\end{pmatrix}
\]

\end{document}

The best code is provided thanks to the precious comment of @Bernard.

Sebastiano
  • 54,118
7

Here's another solution. It uses a pmatrix environment for the overall matrix and a custom macro called \blockmat for the 2x2 inner matrices.

enter image description here

\documentclass{article}
\usepackage{array,amsmath}
\newcommand\blockmat{%
   \begin{array}{|@{\,}rr@{\,}|}
     \hline 0 & 1^{\mathstrut} \\ -1 & 0 \\ \hline
   \end{array}}
\begin{document}
\[
\begin{pmatrix}
\blockmat &        &           &   &        & 0 \\
          & \ddots &           &   &        &   \\
          &        & \blockmat &   &        &   \\
          &        &           & 0 &        &   \\
          &        &           &   & \ddots &   \\
0         &        &           &   &        & 0 \\  
\end{pmatrix}
\]
\end{document}
Mico
  • 506,678
3

Here's a solution using TikZ that will work in all kinds of context, not just matrices, to draw boxes. You just need to put \tl in the point where the top-right corner is supposed to be and \br where the bottom-right will be. You can also use any TikZ feature to modify your box. Obviously this needs to be fine tuned depending on what exactly you're using it for (spacing etc.).

\newcounter{textbox}
\def\tl{\stepcounter{textbox}\tikzmarknode{a\thetextbox}{\strut}}
\def\br{\tikzmarknode{b\thetextbox}{\strut}\begin{tikzpicture}[overlay, remember picture]\draw (a\thetextbox.north west) rectangle (b\thetextbox.south east);\end{tikzpicture}}

The spacing in this version is not optimized for matrices, but you can use

\tikzmarknode{b\thetextbox}{\strut}\begin{tikzpicture}[overlay, remember picture]\draw ($(a\thetextbox.north west)+(-0.4\arraycolsep,0ex)$) rectangle ($(b\thetextbox.south east)+(0.4\arraycolsep,0ex)$);\end{tikzpicture}

to add extra space.

enter image description here

Full code:

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath} 
\usetikzlibrary{tikzmark,calc}
\newcounter{textbox}
\def\tl{\stepcounter{textbox}\tikzmarknode{a\thetextbox}{\strut}}
\def\br{\tikzmarknode{b\thetextbox}{\strut}\begin{tikzpicture}[overlay, remember picture]\draw (a\thetextbox.north west) rectangle (b\thetextbox.south east);\end{tikzpicture}}
\begin{document}
\[
\begin{bmatrix}
\tl0    &-1     &        &         &          &        &      &         &       &    0    \\
1       & 0\br  &        &         &          &        &      &         &       &         \\
        &       & \cdot  &         &          &        &      &         &       &         \\
        &       &        & \cdot   &          &        &      &         &       &         \\
        &       &        &         & \cdot    &        &      &         &       &         \\
        &       &        &         &          &\tl0    & 1    &         &       &         \\
        &       &        &         &          &-1      & 0\br &         &       &         \\
        &       &        &         &          &        &      & \cdot   &       &         \\
        &       &        &         &          &        &      &         & \cdot &         \\ 
0       &       &        &         &          &        &      &         &       &  \cdot  \\
\end{bmatrix}
\]
\end{document}
sheß
  • 3,622