# smallmatrix between brackets [] instead of parentheses ()

I'm trying to write a math cheat sheet and have to write matrix in a compact way. I saw a very nice piece of answer there. What I want to do know is to set the matrix in brackets [] instead of parentheses (). Any idea?

\documentclass{article}
\usepackage{amsmath}

\newenvironment{psmallmatrix}
{\hbox\bgroup
\delimiterfactor=950
\delimitershortfall=2pt
$\left(\smallmatrix} {\endsmallmatrix\right)$\egroup}

\begin{document}
$$M = \begin{psmallmatrix} 1 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 1 & 1\\ 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 1\\ 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 1 & 0 & 0\\ 1 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 1 & 0 & 0 & 1 & 0\\ 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 1\\ 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 1 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 1 & 0\\ 0 & 0 & 1 & 0 & 1 & 0 & 1 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 1\\ 0 & 0 & 0 & 1 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0\\ 1 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0\\ 0 & 1 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0\\ 1 & 0 & 1 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 0\\ 1 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\ 1 & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0\\ 0 & 1 & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 \end{psmallmatrix}$$
\end{document}

• Define a bsmallmatrix analogously just with \left[ instead of \left( and \right] instead of \right)? Dec 24, 2018 at 14:48
• That was easy indeed. Didn't dig enough... Many thanks @moewe
– ecjb
Dec 24, 2018 at 14:53
• Mathtools already provides this. All variants Dec 24, 2018 at 15:14

The mathtools package extends amsmath for various features. In particular, it already defines the psmallmatrix, bsmallmatrix, Bsmallmatrix, vsmallmatrix , Vsmallmatrix and their star variants which accept the columns alignment as an optional argument (default: c).