2

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.

Werner
  • 603,163
  • 6
    $$ should never be used in LaTeX. In your case, substitute them with \begin{align*} and \end{align*} respectively. – egreg Mar 11 '19 at 18:23

2 Answers2

7

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.

Bernard
  • 271,350
6

For reasons not to use $$ to start and stop an unnumbered displayed equation in a LaTeX document, see Why is \[ ... \] preferable to $$ ... $$? For still more information on this subject, see What are the differences between $$, \[, align, equation and displaymath?

Anyway, all you need to do to salvage your code is to replace the first instance of $$ with \begin{align*} and the second instance of $$ with \end{align*}.

While you're at it, though, you may want to enlarge the (, |, and ) delimiters, and you may want to either replace : with \colon or use double-sum notation. Both options are pursued in the following example.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'align*' environment
\begin{document}
\begin{align*}
  S(k+1)  
    &= \sum \bigl( a[i] \cdot a[j] \bigm| i,j \colon 0 \leq i \leq j < k + 1 \bigr) \\
    &= \sum_{i = 0}^j \sum_{j = 0}^{k + 1} \bigl( a[i] \cdot a[j] \bigr)
\end{align*}
\end{document}
Werner
  • 603,163
Mico
  • 506,678