# Argument of align has an extra '}'

Okay, this was compiling just fine yesterday. I've since been making some changes, and now get the following error:

! Argument of \align has an extra }.
<inserted text>
\par
l.85     f(t) = ((x_t - x_{t-1})} + (x_{t-1} - x_{t-2})) \times \frac{1}{2}
?


The section it's complaining about is the following:

\begin{center}
\begin{align}
f(t) = ((x_t - x_{t-1})} + (x_{t-1} - x_{t-2})) \times \frac{1}{2}
\end{align}
\begin{align}
\frac{ \sum\limits_{i=0}^{n-1} (x_{t-i}-x_{t-(i+1)}) }{n}
\end{align}
\end{center}


And the top of my main .tex file has this:

\documentclass[abbrevs,bsc,logo]{styles/infthesis}
\usepackage{hyperref}
\usepackage[pdftex]{graphicx}
\usepackage{minted}
\usepackage{amsmath, amsthm, amssymb}

\begin{document}

\include{a/bunch/of/sections}
\end{document}


It's driving me crazy. I've looked at this page: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=extrabrace, but can't for the life of me work out how to fix the error. Most of the methods listed on that page I can't get to work out...

If I take out that specific equation, all works fine. Even leaving in the \begin{align} etc works, as long as that one line isn't in the document.

Do I need to put something like \protect or \ensuremath in there somewhere?

-
The environment center is useless in this contents. –  Marco Daniel Apr 2 '12 at 14:28
The first align has a curly brace instead of a round one, thus producing the error: f(t) = ((x_t - x_{t-1})} should be f(t) = ((x_t - x_{t-1))}. –  diabonas Apr 2 '12 at 14:29
isn't this your extra brace: ((x_t - x_{t-1})} ..? An editor that can check parentheses/braces matching is a good idea. Emacs, e.g., has M-x check-parens. It's helped me out a few times! –  jon Apr 2 '12 at 14:29
Never use center for this and put both equations in a gather environment. –  egreg Apr 2 '12 at 14:29
Yep, I just couldn't see the ) from the }. Thanks all. Fresh pair of eyes always helps. –  shearn89 Apr 2 '12 at 14:30

The expression

 f(t) = ((x_t - x_{t-1})}


has one opening brace and two closing braces and that triggering the error message. The proper way to write the expression would be

f(t) = ((x_t - x_{t-1}) + (x_{t-1} - x_{t-2}))


or even better

f(t) = \bigl((x_t - x_{t-1}) + (x_{t-1} - x_{t-2})\bigr)


so the outer parentheses will be longer and this will increase readability.

On a side note, as egreg has mentioned, your code has also some other problems: the center environment is not necessary here and will add extra unwanted vertical space. For a single equation you should use equation instead of align. You shouldn't use two consecutive align environments; you can use a gather environment instead.

It's not clear why you want to split in that way a single formula; the breaking point that you've chosen and the numbering schema introduce ambiguity since the reader could get the impression that you are talking about two different expressions instead of two parts of a same formula. Perhaps you culd consider using \underbraces? Here are some options:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{gather}
f(t) = \big((x_t - x_{t-1}) + (x_{t-1} - x_{t-2})\big) \times \frac{1}{2} \\
\frac{ \sum_{i=0}^{n-1} (x_{t-i}-x_{t-(i+1)}) }{n}
\end{gather}

$$\label{avggrad} f(t) = \big((x_t - x_{t-1}) + (x_{t-1} - x_{t-2})\big) \times \frac{1}{2} \frac{ \sum_{i=0}^{n-1} (x_{t-i}-x_{t-(i+1)}) }{n}$$

$$\label{avggrad} f(t) = \underbrace{\big((x_t - x_{t-1}) + (x_{t-1} - x_{t-2})\big)}_{\text{some explanation}} \times \frac{1}{2} \underbrace{\frac{ \sum_{i=0}^{n-1} (x_{t-i}-x_{t-(i+1)}) }{n}}_{\text{some description}}$$

\end{document}


-

The "correct" input is

\begin{gather}

Don't use align for single equations and never have two consecutive equation alignment environments.
@shearn89 There's really no point, as the equations are centered by default anyway. In addition, I would think the center environment introduces extra spacing which shouldn't be there. –  Torbjørn T. Apr 2 '12 at 15:06
@shearn89 Try this minimal example: \documentclass{article} \usepackage{amsmath} \usepackage{kantlipsum} \begin{document} \kant[3] %\begin{center} $$f(x) = x^2$$ %\end{center} \kant[2] \end{document} and then uncomment the center lines to see the difference. –  Torbjørn T. Apr 2 '12 at 15:10