I wish to format a system of equations. I use:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$\begin{cases}
\begin{aligned}
q_1 S_1^1 &+ q_2 S_2^1 &+ ... &+ q_n S_n^1 &= (1+r) S_0^1, \\
q_1 &+ q_2 &+ ... &+ q_n &= 1.
\end{aligned}
\end{cases}$$
\end{document}
I expect the q's and the equality sign to be below each other, but instead there is an indent in front of the q_1 and the =1 is totally on the right. How do I obtain my desired behavior?



$$to initiate and terminate (unnumbered) display math mode in a LaTeX document. Instead, please use\[and\]. For more information on this topic, please see the posting Why is\[ ... \]preferable to$$ ... $$and the associated answers. – Mico Dec 19 '22 at 11:12