Math & Science! Extra alignment tab has been changed to \cr.

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
mlodyotak
Posts: 4
Joined: Mon Dec 23, 2013 10:19 pm

! Extra alignment tab has been changed to \cr.

Post by mlodyotak »

what is problem with that

Code: Select all

$$ D=(\left[ \begin{array} {ccc |ccc}
a_1,_1 & \ldots & a_1,_n & & & \\
\vdots & \ddots & \vdots & & \Theta &\\
a_n,_1 & \ldots & a_n,_n & & & \\
\hline
& & & & b_1,_1 & \ldots & b_1,_n \\
& &\Theta & & \vdots & \ddots & \vdots \\
& & & & b_n,_1 & \ldots & b_n,_n & & &
\right
\end{array}
$$
Last edited by Stefan Kottwitz on Tue Dec 24, 2013 2:04 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

! Extra alignment tab has been changed to \cr.

Post by Stefan Kottwitz »

Hi mlodyotak,

welcome to the forum!

You defined 6 columns by \begin{array} {ccc |ccc}, but you used more. Just count the column separator symbols (ampersand &), there are more than 6 in the last array line. Reduce those unneeded symbols. Btw. don't use $$...$$, this is TeX syntax and not recommendable for LaTeX documents, resulting in wrong vertical spacing. Use \[ ... \] instead. Here's a compilable version of it, also the \right corrected:

Code: Select all

\documentclass{article}
\begin{document}
\[
 D=\left[ \begin{array} {ccc |cccc}
a_1,_1 & \ldots & a_1,_n & & & \\
\vdots & \ddots & \vdots & & \Theta &\\
a_n,_1 & \ldots & a_n,_n & & & \\
\hline
& & & & b_1,_1 & \ldots & b_1,_n \\
& &\Theta & & \vdots & \ddots & \vdots \\
& & & & b_n,_1 & \ldots & b_n,_n
\end{array}\right]
\]
\end{document}
matrix.png
matrix.png (2.83 KiB) Viewed 26908 times
Stefan
LaTeX.org admin
mlodyotak
Posts: 4
Joined: Mon Dec 23, 2013 10:19 pm

! Extra alignment tab has been changed to \cr.

Post by mlodyotak »

I'm very thankfull for that but i have another question how to get Theata on middle of this table maybe u have any idea?? Ok nevermind i solve the problem but i need to do something like that:
output.jpg
output.jpg (21.54 KiB) Viewed 26872 times
Last edited by Stefan Kottwitz on Tue Dec 24, 2013 3:04 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

! Extra alignment tab has been changed to \cr.

Post by Stefan Kottwitz »

So I guess it's solved? I would move the Theta to the column with the \ddot.

Stefan
LaTeX.org admin
mlodyotak
Posts: 4
Joined: Mon Dec 23, 2013 10:19 pm

! Extra alignment tab has been changed to \cr.

Post by mlodyotak »

i need to do this ex and i have no idea how to posit this two big matrix's how can i sole it this is my latex code. Sorry of my bbcode but i'm rly bad in such a thinks, and my english is not very good as you can see.

Code: Select all

$$ f(x) =
\left \{
\begin{array} {rl}
sin (\frac {1}{x}) & \mbox  {dla} \ x \neq 0\\
0 & \mbox{dla } \ x \in \mathbb{R} \backslash \{0\}.
\end{array}
\right. $$
\\


$$det\begin{pmatrix}
a_1,_1 & 0 & 0 & \ldots & 0 \\
a_2,_1 & a_2,_2 & 0 & \ldots & 0\\
a_3._1 & a_3,_2 & a_3,_3 & \ldots & 0\\
\vdots & \vdots & \vdots & \ddots & \vdots & \\
a_n-_1,_1 & \ldots & a_n-_1,_n-_1 & \ldots & a_n,_m
\end{pmatrix}= \prod _{i=1}^n a_{i,i} $$\  
    \[
     D=\left[ \begin{array} {ccc |cccc}
    a_1,_1 & \ldots & a_1,_n & & & \\
    \vdots & \ddots & \vdots &  &  & \Theta\\
    a_n,_1 & \ldots & a_n,_n & & & \\
    \hline
    & & & & b_1,_1 & \ldots & b_1,_n \\
    & \Theta & & \vdots & \ddots & \vdots \\
    & & & & b_n,_1 & \ldots & b_n,_n
    \end{array}\right]
    \]
Last edited by cgnieder on Thu Dec 26, 2013 3:03 pm, edited 1 time in total.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

! Extra alignment tab has been changed to \cr.

Post by Johannes_B »

I am not quite sure what you want to know, maybe have a look at the following. There are some improvements (cases, commands defined by amsmath for operators ,e.g. \sin,\det).

Code: Select all

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}

\[ f(x) =
\left \{
\begin{array} {rl}
\sin (\frac {1}{x}) & \mbox {dla} \ x \neq 0\\
0 & \mbox{dla } \ x \in \mathbb{R} \backslash \{0\}.
\end{array}
\right. \]

\[ f(x) = \begin{cases}
\sin (\frac {1}{x}) & \text {dla} \ x \neq 0\\
0 & \text{dla } \ x \in \mathbb{R} \backslash \{0\}.
\end{cases}
\]


\begin{align*}
 \prod _{i=1}^n a_{i,i}&=
 \det \begin{pmatrix}
a_1,_1 & 0 & 0 & \ldots & 0 \\
a_2,_1 & a_2,_2 & 0 & \ldots & 0\\
a_3._1 & a_3,_2 & a_3,_3 & \ldots & 0\\
\vdots & \vdots & \vdots & \ddots & \vdots & \\
a_n-_1,_1 & \ldots & a_n-_1,_n-_1 & \ldots & a_n,_m
\end{pmatrix}  \\
D &=\hphantom{\det}\left[ \begin{array} {ccc |cccc}
a_1,_1 & \ldots & a_1,_n & & & \\
\vdots & \ddots & \vdots & & & \Theta\\
a_n,_1 & \ldots & a_n,_n & & & \\
\hline
& & & & b_1,_1 & \ldots & b_1,_n \\
& \Theta & & \vdots & \ddots & \vdots \\
& & & & b_n,_1 & \ldots & b_n,_n
\end{array}\right]
\end{align*}

\end{document}
Maybe you can find some help at GUST or CSTUG. TeX user groups around the world.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
mlodyotak
Posts: 4
Joined: Mon Dec 23, 2013 10:19 pm

Re: ! Extra alignment tab has been changed to \cr.

Post by mlodyotak »

it's a ex. what i need to do exactly how this is written in pdf and i don't know how to do in this same lane this two big matrixes
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

! Extra alignment tab has been changed to \cr.

Post by Johannes_B »

Those matrices, as you say yourself, are very big and simply too big for one line. You could change the font size in the math environment, but this would be an inconsistency.

Another possibility would be to change the printable area (this is shown by showframe) using geometry. Click on »Open in Writelatex« just above the following code and uncomment the \geometry line.

Code: Select all

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{showframe}
\usepackage{geometry}
%\geometry{margin=1cm}%Just for showing, these are bad margins!
\begin{document}

\[ f(x) =
\left \{
\begin{array} {rl}
\sin (\frac {1}{x}) & \mbox {dla} \ x \neq 0\\
0 & \mbox{dla } \ x \in \mathbb{R} \backslash \{0\}.
\end{array}
\right. \]

\[ f(x) = \begin{cases}
\sin (\frac {1}{x}) & \text {dla} \ x \neq 0\\
0 & \text{dla } \ x \in \mathbb{R} \backslash \{0\}.
\end{cases}
\]


\[ 
%\small
\footnotesize
  \det \begin{pmatrix}
a_1,_1 & 0 & 0 & \ldots & 0 \\
a_2,_1 & a_2,_2 & 0 & \ldots & 0\\
a_3._1 & a_3,_2 & a_3,_3 & \ldots & 0\\
\vdots & \vdots & \vdots & \ddots & \vdots & \\
a_n-_1,_1 & \ldots & a_n-_1,_n-_1 & \ldots & a_n,_m
\end{pmatrix} = \prod _{i=1}^n a_{i,i}
\quad 
D =\left[ \begin{array} {ccc |cccc}
a_1,_1 & \ldots & a_1,_n & & & \\
\vdots & \ddots & \vdots & & & \Theta\\
a_n,_1 & \ldots & a_n,_n & & & \\
\hline
& & & & b_1,_1 & \ldots & b_1,_n \\
& \Theta & & \vdots & \ddots & \vdots \\
& & & & b_n,_1 & \ldots & b_n,_n
\end{array}\right]
\]

\[ 
  \det \begin{pmatrix}
a_1,_1 & 0 & 0 & \ldots & 0 \\
a_2,_1 & a_2,_2 & 0 & \ldots & 0\\
a_3._1 & a_3,_2 & a_3,_3 & \ldots & 0\\
\vdots & \vdots & \vdots & \ddots & \vdots & \\
a_n-_1,_1 & \ldots & a_n-_1,_n-_1 & \ldots & a_n,_m
\end{pmatrix} = \prod _{i=1}^n a_{i,i}
\quad 
D =\left[ \begin{array} {ccc |cccc}
a_1,_1 & \ldots & a_1,_n & & & \\
\vdots & \ddots & \vdots & & & \Theta\\
a_n,_1 & \ldots & a_n,_n & & & \\
\hline
& & & & b_1,_1 & \ldots & b_1,_n \\
& \Theta & & \vdots & \ddots & \vdots \\
& & & & b_n,_1 & \ldots & b_n,_n
\end{array}\right]
\]

\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
symolon
Posts: 2
Joined: Wed Oct 18, 2017 9:15 pm

! Extra alignment tab has been changed to \cr.

Post by symolon »

Hey all, I'm getting a similar error while trying to split an equation between 2 lines. I know the error usually means there's an extra column somewhere but I'm not creating a table and I can't see the problem. I've tried two versions of the code below, the first gives me an error that there's an extra } or missing \right. The second version gives the extra alignment tab changed to \cr. It may have to do with the semicolon, but I'm not sure. I'd appreciate any help you can provide.

Code: Select all

\documentclass{article}

\usepackage{graphicx}
\usepackage[intlimits]{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{epsfig}
\usepackage{array}
\usepackage{subfigure}
\usepackage{multirow}
\usepackage{subfigure}
\usepackage[]{algorithm2e}

\headsep = .25in
\oddsidemargin = +.25in 
\textwidth = 460pt

\begin{document}

\begin{equation*}
\begin{split}
J^3 (2) &\leftarrow \max_{a \in A} \left[\overline{r} (2,1) + \lambda \left( p(2, 1, 1) * J^2 (2) + p(2,1,2) * J^2 (2) \right);\\
& \overline{r} (2,2) + \lambda \left( p(2, 2, 1) * J^2 (2) + p(2,2,2) * J^2 (2) \right) \right] \\
\end{split}
\end{equation*}

\begin{multline*}
J^3 (2) \leftarrow \max_{a \in A} \left[\overline{r} (2,1) + \lambda \left( p(2, 1, 1) * J^2 (2) + p(2,1,2) * J^2 (2) \right); \overline{r} (2,2) + \lambda \left( p(2, 2, 1) * J^2 (2) + p(2,2,2) * J^2 (2) \right) \right] \\
\end{multline*}

\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

! Extra alignment tab has been changed to \cr.

Post by Stefan Kottwitz »

Hi symolon,

welcome to the forum!

You cannot use a dynamic \left and \right delimiter pair over several lines, standard amsmath formula environments cannot handle it. You can "close" then temporarily and open again by \right. and \left. that are invisible delimiters.

Code: Select all

\begin{equation*}
\begin{split}
J^3 (2) &\leftarrow \max_{a \in A} \left[\overline{r} (2,1) + \lambda \left( p(2, 1, 1) * J^2 (2) + p(2,1,2) * J^2 (2) \right)\right.;\\
& \left.\overline{r} (2,2) + \lambda \left( p(2, 2, 1) * J^2 (2) + p(2,2,2) * J^2 (2) \right) \right] \\
\end{split}
\end{equation*}
Luckily your formula parts are of the same size, otherwise one would need to tweak the delimiter heights when the line height is different.

Stefan
LaTeX.org admin
Post Reply