3

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}
\begin{equation}
    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{equation}
\end{document}
3
  • 1
    Define a bsmallmatrix analogously just with \left[ instead of \left( and \right] instead of \right)? – moewe Dec 24 '18 at 14:48
  • That was easy indeed. Didn't dig enough... Many thanks @moewe – ecjb Dec 24 '18 at 14:53
  • 2
    Mathtools already provides this. All variants – daleif Dec 24 '18 at 15:14
8

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).

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.