I have a file with the following environment
\newenvironment{system}{\begin{equation} \left \{ \begin{aligned} }{\end{aligned} \right . \end{equation}}
Which produced the result that I'm looking for except from the fact that adds a little extra space on the new line after the environment so for instance, if I write
\begin{system}
x + y &= 1\\
x - y &= 2
\end{system}
foo
foo gets printed one space after the next line. On the other hand, if I have
\begin{equation}
\left \{
\begin{aligned}
x + y &= 1\\
x - y &= -1
\end{aligned}
\rigth .
\end{equation}
foo
Then foo gets printed where it should. On the other hand if I write foo
right after \end{system}
with no spaces or newline I get the correct result but then the text file gets a little harder to read.
Am I doing something wrong in defining the environment? Or is there an easy way to solve it.
Edit: For context, this is the preamble I am testing it in
\documentclass{article}
\usepackage{amsmath}