Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typesetting a large matrix in LaTeX

I have a 3x12 matrix I'd like to input into my LaTeX (with amsmath) document but LaTeX seems to choke when the matrix gets larger than 3x10:

\begin{equation}
\textbf{e} = 
\begin{bmatrix} 
1&1&1&1&0&0&0&0&-1&-1&-1&-1\\
1&-1&0&0&1&1&-1&-1&0&0&1&-1\\
0&0&1&-1&1&-1&1&-1&1&-1&0&0
\end{bmatrix}
\end{equation}

The error: Extra alignment tab has been changed to \cr. tells me that I have more & than the bmatrix environment can handle. Is there a proper way to handle this? It also seems that the alignment for 1's and the -1's are different, is that also expected of the bmatrix?

like image 853
Hooked Avatar asked May 07 '10 14:05

Hooked


People also ask

How do you change the size of a matrix in LaTeX?

To e.g. change the size of your array you would switch the size by adding the command inside your align environment. Valid commands are \tiny , \scriptsize , \footnotesize , \small , \normalsize , \large , \Large , \huge , and \Huge (there could be more).

How do I increase the space between rows in matrix LaTeX?

One option is to use the commands \setlength and \arraystretch to change the horizontal spacing (column separation) and the vertical spacing (row separation) respectively.

How do you fill a page in LaTeX?

you could insert \vspace*{\fill} to fill the remaining space on the page.


2 Answers

From the amsmath documentation (texdoc amsmath):

The amsmath package provides some environments for matrices beyond the basic array environment of LATEX. The pmatrix, bmatrix, Bmatrix, vmatrix and Vmatrix have (respectively) ( ), [ ], { }, | |, and ∥ ∥ delimiters built in. For naming consistency there is a matrix environment sans delimiters. This is not entirely redundant with the array environment; the matrix environments all use more economical horizontal spacing than the rather prodigal spacing of the array environment. Also, unlike the array environment, you don’t have to give column specifications for any of the matrix environments; by default you can have up to 10 centered columns. (If you need left or right alignment in a column or other special formats you must resort to array.)

i.e. bmatrix defaults to a 10 column maximum.

A footnote adds

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

like image 54
Scott Wales Avatar answered Sep 21 '22 20:09

Scott Wales


If you came to this page looking for the exact command (thanks to Scott Wales for the answer), you want this in your preamble:

\setcounter{MaxMatrixCols}{20}

Where you can replace 20 with the maximum number of columns you want.

like image 44
James Weigle Avatar answered Sep 22 '22 20:09

James Weigle