# I want to typeset following matrix in LaTeX

I have a problem with following matrix. Actually I can't put this matrix in LaTeX.

The boxes drawn with TikZ:

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}

\begin{document}
$\check B \equiv \left[ \begin{array}{cc} \begin{tikzpicture}[baseline=(tmp.base)] \node (tmp) {B^L}; \path (tmp.north) ++(0,.3em); \draw[overlay] (tmp.south east) ++(.75em, -.5em) rectangle (tmp.north west) ; \end{tikzpicture} & 0 \\[.4em] 0 & \begin{tikzpicture}[baseline=(tmp.base)] \node (tmp) {B^R}; \path (tmp.south) ++(0, -.3em); \draw[overlay] (tmp.north west) ++(-.75em, .5em) rectangle (tmp.south east) ; \end{tikzpicture} \end{array} \right]$
\end{document}


Or a little larger:

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}

\begin{document}
$\check B \equiv \left[ \begin{array}{cc} \begin{tikzpicture}[baseline=(tmp.base)] \node (tmp) {B^L}; \path (tmp.north) ++(0,.3em); \draw[overlay] (tmp.south east) ++(.75em, -.75em) rectangle (tmp.north west) ; \end{tikzpicture} & 0 \\[1em] 0 & \begin{tikzpicture}[baseline=(tmp.base)] \node (tmp) {B^R}; \path (tmp.south) ++(0, -.3em); \draw[overlay] (tmp.north west) ++(-.75em, .75em) rectangle (tmp.south east) ; \end{tikzpicture} \end{array} \right]$
\end{document}


Some improvements to @onewhaleid's tikz-free solution. I slighly modified some parameters and managed to get the brackets fully enclose the contents of the matrix:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\setlength{\fboxsep}{1.25em} \check B \equiv \begin{bmatrix}\noalign{\vskip0.5ex} \, \boxed{B^L} & \hspace{-2em} 0 \\[-0.8em] 0 & \hspace{-1.85em}\boxed{B^R} \,\rule[-3.5ex]{0pt}{0pt} \end{bmatrix}

\end{document}


• Very nice. I should have put my \setlength inside the align environment too. – onewhaleid Sep 6 '15 at 21:15
• For one row displays, use equation, not align. – egreg Sep 6 '15 at 21:38
• @egreg: Oh yes, I forgot that. I took@onewhaleid's code as a starting point, and focused on the problem of the brackets size. Thanks for pointing that. – Bernard Sep 6 '15 at 22:00

This is a non-tikz alternative, although I can't work out how to get the brackets the correct size.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\setlength{\fboxsep}{1em}

\begin{align}
\check B \equiv
\begin{bmatrix}
\, \boxed{B^L} & \hspace{-2em} 0 \\[-0.9em]
0 & \hspace{-2em} \boxed{B^R} \,
\end{bmatrix}
\end{align}

\end{document}


• For one row displays, use equation, not align. – egreg Sep 6 '15 at 21:39