63

The code below works, but when I add 10 more columns, it does not. So, how can I add ten more columns to the matrix below?

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
\begin{bmatrix}
 1 & 0 & 0 & 0  & 0 & 1 & 0 & 0 & 1 & 0 
\end{bmatrix}
\end{equation}

\end{document}

2 Answers 2

72

One simple way is to use the array environment together the expansible brackets \left[ and \right] (note the use of {*{20}c} as suggested by @cmhughes):

\left[
\begin{array}{*{20}c}
 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 
\end{array}
\right]

The problem is the difference on the spacing for the brackets.


From the texdoc amsmath documentation:

The maximum number of columns in a matrix is determined by the counter MaxMatrixCols (normal value = 10), which you can change if necessary using \setcounter or \addtocounter commands.

So, you can just use

\setcounter{MaxMatrixCols}{20}
\begin{equation}
\begin{bmatrix}
 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 
\end{bmatrix}
\end{equation}
3
  • @Günal, there is a global solution. Before to replace all your matrices, consider reading the updated answer.
    – Sigur
    Commented Jan 24, 2013 at 11:29
  • 4
    +1 you shouldn't need to write {ccccccccccccc} and can use {*{20}c}
    – cmhughes
    Commented Jan 24, 2013 at 16:43
  • 3
    “The problem is the difference on the spacing for the brackets.” → Use \begin{array}{@{}<columns>@{}} instead, i.e. \begin{array}{@{}*{20}c@{}}. Commented Jan 28, 2013 at 2:14
1

Instead of a bmatrix, you could use a +bmatrix from the tabularray package:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularray}
\UseTblrLibrary{amsmath}
\begin{document}

\begin{equation}
\begin{+bmatrix}
 1 & 0 & 0 & 0  & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0  & 0 & 1 & 0 & 0 & 1 & 0 
\end{+bmatrix}
\end{equation}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .