Error - ! Extra alignment tab has been changed to \cr

I'm new on latex, today I try to use de environment gather of the package "amsmath" but get the fallowing error:

! Extra alignment tab has been changed to \cr.

<template> }}\savetaglength@ \endtemplate

l.173     \end{gather}


My source code:

\documentclass[a4paper, 12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{paracol}
\usepackage{blindtext}
\usepackage{mathtools}
\usepackage{amsmath}

\begin{document}
...
\begin{gather}
40y - 2x + x + 2 &= 40 \\
y &= \frac{38}{40} + x \\
\frac{P(x)}{Q(x)}\int_{-\infty}^\infty f(x)dx, \; P(x) = y' + x
\end{gather}

\end{document}


Sorry for my English, I google the problem but the only things that i get its table errors that don't have relevant to this case.

• Welcome to TeX SX! The gather environment doesn't align whatever: it centres each row, so don't use & with it. If you do want to align the = signs, use the align environment – Bernard Jan 5 at 23:38
• Thanks, that was the problem – Jean Persia Jan 6 at 0:32

gather does not support alignment. You' ve got two choices. Either avoid alignment or use align environment.

In the former case:

\documentclass[a4paper, 12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{paracol}
\usepackage{blindtext}
\usepackage{amsmath,amsthm,mathtools}
\begin{document}
\begin{gather}
40y - 2x + x + 2 = 40 \\
y = \frac{38}{40} + x \\
\frac{P(x)}{Q(x)}\int_{-\infty}^\infty f(x)dx, \; P(x) =   y' + x
\end{gather}
\end{document}


whereas in the latter case:

\documentclass[a4paper, 12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{paracol}
\usepackage{blindtext}
\usepackage{amsmath,amsthm,mathtools}
\begin{document}
\begin{gather}
\begin{align*}
40y - 2x + x + 2 &= 40 \\
y &= \frac{38}{40} + x \\
\frac{P(x)}{Q(x)}\int_{-\infty}^\infty f(x)dx, \; P(x) = y' + x
\end{align*}
\end{gather}
\end{document}