[Tex/LaTex] Latex does not go to next line

indentationmath-mode

I am working on a document for school, trying to make some equations lines. However, the double dollar command for making equations omits the next line command.

$$
    S(k+1)  &= \sum(a[i]\cdot a[j] \mid i,j : 0\leq i\leq j < k + 1)\\
            &=
$$

I would expect the equation to go to the next line and continue indentation from the = character, however the document shows me this:

enter image description here

I have tried disabling packages but this offers no solution.

When I started working in this document there were no issues, a few hours later it suddenly stopped working correctly.

Any help is very much appreciated.

Best Answer

This cannot work: the construct $$ ····· $$ (which anyway is a plain TeX construction and should be replaced in LaTeX with \[ ····· \]) is for a one-line centred equation.

For what you want you should use the amsmath align (lines numbered) or align*(unnumbered), with the alignment point specified with an ampersand. For other types of multiline equations, please take a look at the documentation of amsmath, or its extension mathtools.