TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've read a few posts here about center math equations and all of them make use of

\begin{align} *Math symbols* \end{align}

Now I've included the \usepackage{amsmath} before the begin document line. But I keep getting this error:

enter image description here

Any ideas guys? I'm a latex noob

Here is some code:



\section{Situation 1}

$J_{(j)} = \sum\limits_{i:r(i,j)=1} ((\theta\textsuperscript{(j)})\textsuperscript{T}x\textsuperscript{(i)} - Y_{i,j})^2 + \frac{\lambda}{2}\sum\limits_{k=1}^n(\theta_k\textsuperscript{(j)})^2$

share|improve this question
Can you post a MWE (see here) that illustrates your problem? A basic program works for me...: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align} x = y \end{align} \end{document} – cslstr May 22 '14 at 16:07
Take out the $ around your math... \begin{align} puts you in math mode already. – cslstr May 22 '14 at 16:12
Equations are centered by default. You need align for multiline equations. You may find useful examples here: tex.stackexchange.com/questions/98397/enumerate-formulas/… – Ethan Bolker May 22 '14 at 16:17
@cslstr do you mind writing up a post so that I can accept the answer? THANK YOU!!!!! – user1638809 May 22 '14 at 16:20
up vote 5 down vote accepted

TeX is great for math typesetting; so it's unlikely that a formula like that is so complicated to input:



\section{Situation 1}

J_{(j)} = 
  \sum_{i:r(i,j)=1} \bigl((\theta^{(j)})^{T} x^{(i)} - Y_{i,j}\bigr)^2 + 


There should never be \textsuperscript inside a formula.

Using \bigl and \bigr in the first formula makes the parentheses slightly bigger, which is good for reading in this case. Since they are almost necessary in the furst summation, I used them also in the second one, for symmetry.

enter image description here

The align environment is for multiline displays; if you want the equation numbered, then use equation instead of equation*.

But in any case, the contents of equation, align and similar environments is already assumed to be math, so adding $ will give errors.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.