# Typing an 11 x 11 (or larger) Matrix [duplicate]

I would like to explicitly write out a n x n matrices in my paper, but once n \geq 11, I get compiling errors and it refuses to print the matrix. Here is what I have:

\documentclass{standalone}
\usepackage{amsmath,mathtools,amsthm}
\usepackage{array}

\begin{document}

$$\begin{bmatrix*}[r] 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ -\fract{1}{2} & -\fract{1}{2} & \fract{1}{2}\sqrt{2} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & -\fract{1}{2}\sqrt{2} & \fract{1}{2}\sqrt{2} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & -\fract{1}{2}\sqrt{2} & \fract{1}{2}\sqrt{2} & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & -\fract{1}{2}\sqrt{2} & \fract{1}{2}\sqrt{2}& 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & -\fract{1}{2}\sqrt{2} & \fract{1}{2}\sqrt{2} & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & -\fract{1}{2}\sqrt{2} & \fract{1}{2}\sqrt{2} & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\fract{1}{2}\sqrt{2} & \fract{1}{2}\sqrt{2} & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\fract{1}{2}\sqrt{2} & \fract{1}{2} & \fract{-1}{2}\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix*}$$

\end{document}


I do not see any errors for this 11 x 11 matrix. However, when I type this in a blank standalone document, I get an error that says: "Missing $inserted. $$\begin{bmatrix*}[r]" Is there another way to write an 11 x 11 (or larger) matrix so that it compiles? Or is it impossible to type matrices this large into LaTeX? (If it helps, I am using writelatex.com to compile my thesis.) ## marked as duplicate by Werner, Svend Tveskæg, user13907, Guido, user31729 Nov 18 '14 at 20:52 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. • You need to reset the counter variable MaxMatrixCols. Its default value is 10. If you need, say, 15 cols, issue the instruction \setcounter{MaxMatrixCols}{15}. (See also footnote 2 on page 10 of the user guide of the amsmath package.) – Mico Nov 18 '14 at 19:08 • Some additional observations. There is no \fract command; I assume you meant to write \frac. Similarly, there's no bmatrix* environment; try bmatrix instead. The use of $$ to enter and exit displaymath mode in a LaTeX document is deprecated; see Why is $...$ preferable to $$...$$? for more information on this subject. Finally, you're getting the error message about the missing $ because you're trying to use the standalone document class without setting the option preview. – Mico Nov 18 '14 at 19:15
• Thank you!! I didn't know there's a max amount of columns allowed for matrices. This is incredibly helpful! Yes, I did mean \frac, and not \fract. I'm glad you pointed it out. bmatrix* allows me to align right [r] or left [l]. If I use bmatrix, then some how it does not understand that I want a specific alignment. It will think [r] is in the first row first column and it will do a default center alignment. – Student4Life Nov 18 '14 at 19:31
• As for the preview option you mentioned: for future reference, how might I add that? – Student4Life Nov 18 '14 at 19:32
• \documentclass[preview]{standalone}. About the bmatrix* environment: You're absulutely correct, it does exist (as it's defined in the the mathtools package). – Mico Nov 18 '14 at 19:35

Summarizing some of my earlier comments:

• Use the standalone package with the option preview in order to avoid getting an error message about a missing $ symbol. • Don't use $$ in a LaTeX document to start and end displaymath mode, as it's quite deprecated. See Why is $...$ preferable to $$ ...$\$? for more information on this subject.

• The matrix environments of the amsmath and mathtools environments work with the counter variable MaxMatrixCols. Its default value is 10; if you have a matrix with, say, 15 columns, issue the instruction \setcounter{MaxMatrixCols}{15}.

• There is no \fract command; use \frac instead.

For the matrix at hand, I actually wouldn't use any \frac instructions. Instead, I'd use inline-style math notation, i.e., I'd write \sqrt{2}/2, etc. That way, the fractional expressions won't become too tiny to read with ease.

\documentclass[preview]{standalone}
\usepackage{geometry,mathtools}
\setcounter{MaxMatrixCols}{11}
\begin{document}
$\begin{bmatrix*}[r] 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ -1/2 & -1/2 & \sqrt{2}/2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & -\sqrt{2}/2 & \sqrt{2}/2 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & -\sqrt{2}/2 & \sqrt{2}/2 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & -\sqrt{2}/2 & \sqrt{2}/2& 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & -\sqrt{2}/2 & \sqrt{2}/2 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & -\sqrt{2}/2 & \sqrt{2}/2 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\sqrt{2}/2 & \sqrt{2}/2 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\sqrt{2}/2 & 1/2 & -1/2\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix*}$
\end{document}

• maybe use sfrac{}{} of the xfrac package for the fractions ;) looks quite nice. – MaxNoe Nov 18 '14 at 20:19