0

The following code:

\documentclass[12pt, a4paper, twoside, titlepage]{article}

\usepackage{amsmath}
\begin{document}

  \begin{flalign}
    J(1)=\\
    \sum\limits_{i=1}^{m} (h_\Theta(x^i)-y^i)^2=&&\\
    \sum\limits_{i=1}^{3} (\Theta_1(x^i)-y^i)^2=&&\\
    \frac{1}{3}((1-1)^2+(2-2)^2+(3-3)^2)=&&\\
    \frac{1}{3}(0+0+0)=0
  \end{flalign}

\end{document}

Gives the following equation alignment:

enter image description here

Aligning by the = is great when developing two sides of an equation. However, when developing an expresion line-by-line, I prefer that the expressions will be aligned to the left:

enter image description here

I assume that after seeing my handwriting skills, my need for Latex is self-explanatory.

What have I tried

My question

How do I align a running numbered list of expressions, similar to the one listed above, in which the expressions are aligned to the left?

  • flalign (full length align) has nothing to do with fleqn (fixed length [from the margin] equations). Remember that align and the other environments with align in their name make columns in pair, the first right aligned and the second left aligned. So you just need & in front of each line. – egreg Mar 20 '17 at 7:49
2

How about this:

\documentclass[12pt, a4paper, twoside, titlepage]{article}

\usepackage{amsmath}
\begin{document}

  \begin{align}
    &J(1)=\\
    &\sum\limits_{i=1}^{m} (h_\Theta(x^i)-y^i)^2=\\
    &\sum\limits_{i=1}^{3} (\Theta_1(x^i)-y^i)^2=\\
    &\frac{1}{3}((1-1)^2+(2-2)^2+(3-3)^2)=\\
    &\frac{1}{3}(0+0+0)=0
  \end{align}

\end{document}

enter image description here

  • I changed flalign into align, because the former does nothing different in this case. – egreg Mar 20 '17 at 7:45

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.