1

I'm trying to make a 6x6 matrix with the following text:

\begin{gather}
\dfrac{d}{dt}
\begin{bmatrix}
    y \\ \dot{y} \\ a_{M} \\ \lambda_{T} \\ \lambda_{D} \\ a_{T}
\end{bmatrix}
=
\begin{bmatrix}
    0 && 1 && 0 && 0 && 0 && 0 \\
    0 && 1 && 0 && 0 && 0 && 0 \\
    0 && 1 && 0 && 0 && 0 && 0 \\
    0 && 1 && 0 && 0 && 0 && 0 \\
    0 && 1 && 0 && 0 && 0 && 0 \\
    0 && 1 && 0 && 0 && 0 && 0 \\
\end{bmatrix}
\end{gather}

And I get the following error:

Extra alignment tab has been changed to \cr. \endtemplace \end{gather}.

Whats weird is when i check the same code for 5x5 it worked.

Thank you.

  • 5
    You are not making a 6x6 matrix, but rather a 11x11 matrix because of the && either use & instead of && or set the MaxMatrixCols counter to something higher (default i 10). – daleif Jul 7 '17 at 8:13
  • changed && to & and it worked, thank you. still cant understand why for 10x10 then it worked. – Ben Jul 7 '17 at 8:14
  • 1
    Because it was within the bound of 10 columns. You simply had 5 empty columns alternating with columns with a digit. – Bernard Jul 7 '17 at 8:23
  • 4
    you can increase the limit from 10 if you need it but you do not need it here. Also, use equation not gather for a one-line equation – David Carlisle Jul 7 '17 at 8:34
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – user36296 Jun 30 '18 at 14:04
8

The problem is that only up to ten columns are supported by default in matrix-like constructions, but the number can be increased with

\setcounter{MaxMatrixCols}{20}

(twenty columns should be sufficient).

However, if you want to have wider separation between columns, set it properly, not by adding dummy columns.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\frac{d}{dt}
\begin{bmatrix}
    y \\ \dot{y} \\ a_{M} \\ \lambda_{T} \\ \lambda_{D} \\ a_{T}
\end{bmatrix}
=
\setlength{\arraycolsep}{2\arraycolsep}% this change is local
\begin{bmatrix}
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
\end{bmatrix}
\end{equation}

\begin{equation}
\frac{d}{dt}
\begin{bmatrix}
    y \\ \dot{y} \\ a_{M} \\ \lambda_{T} \\ \lambda_{D} \\ a_{T}
\end{bmatrix}
=
\begin{bmatrix}
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
\end{bmatrix}
\end{equation}

\end{document}

I'd much prefer the latter.

enter image description here

5

The input here is actually not a 6x6 matrix, but rather a 6x11 matrix (number og & +1. Basically you have a lot of blank columns because of the &&.

By default bmatrix and similar envs has a max of 10 columns (controlled by the counter MaxMatrixCols). So you get the error as there are more columns than the matrix env is defined with.

Easy solution replace && by &.

5x5 matrix in the manner you wrote here, is the same as a 10x5 so that is within the 10 col limit.

As David mentions in a comment, use equation(*) for one liners, it has a build in space saving feature that the other envs does not have.

  • 1
    Just to be nit-picky ;-): the OP is making a 6x11 matrix, not 11x11. – campa Jul 7 '17 at 10:28

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.