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$

  • 1
    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
  • 5
    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!!!!! – user481610 May 22 '14 at 16:20

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.

| improve this answer | |

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.