# How can I justify equations?

I want these equations be justified. How can I do that? I mean all equation started at the same margin. Can anyone help me?

S.t.

$$\alpha_{ng}^{min}-\alpha_{ng}^{max}+\gamma_n\leq C_{ng}~~\forall g\in\phi^{G-n},\forall n\in\phi^N$$
$$\beta_l^{min}-\beta_l^{max}+\frac{\epsilon_l^{min}}{\beta_l}-\frac{\epsilon_l^{max}}{\beta_l}-\gamma_{n}=0~~\forall l\in\phi^L\mid SB(l)=n\\$$
$$\beta_l^{min}-\beta_l^{max}+\frac{\epsilon_l^{min}}{\beta_l}-\frac{\epsilon_l^{max}}{\beta_l}+\gamma_{n}=0~~\forall l\in\phi^L\mid RB(l)=n\\$$
\begin{gather}
\begin{split}
&-\sum_{\forall l \in\phi^l\mid SB(l)=n}\epsilon_l^{min}+\sum_{\forall l \in\phi^l\mid RB(l)=n}\epsilon_l^{min}\\
&+\sum_{\forall l \in\phi^l\mid SB(l)=n}\epsilon_l^{max}-\sum_{\forall l \in\phi^l\mid RB(l)=n}\epsilon_l^{max}\nonumber\\
&+\delta_n^{min}-\delta_n^{max}=0~~\forall n\in \phi^n\\
\end{split}
\end{gather}

• Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). – Jesse Oct 11 '14 at 6:02
• Also, please try to post a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. – Peter Grill Oct 11 '14 at 6:13
• OK. I will do that for my next question surely. Tnx. – mostafa Oct 11 '14 at 9:45

The default is for equations is to center them, and there are several way you can get the equations left aligned.

1. If you want all your equations left aligned you can use the fleqn option to the amsmath package:

Note that equations are aligned on the left but not flush with the margin. If you desire them further to the left you can adjust \mathindent. For instance, to get them to be flush with the margin you can apply \setlength{\mathindent}{0pt}:

2. If you don't want all the equations to be left aligned then you could use the flalign environment for the ones which you desire to be left aligned. This yields and output similar to the first image with the equations aligned to the left, but not flush with the margin.

If you add a trailing & to at least one of the equations then you end up with the equations flush with the margin.

3. And, as egreg pointed out, you can also use the align (or alignat) environment which can be used to specify that the equations be left aligned. These won't be flush with the margin so the output will be as in the first image above.

# Code: fleqn option:

\documentclass{article}
\usepackage{showframe}
\usepackage[fleqn]{amsmath}

\newcommand*{\MyEquations}{%
$$\alpha_{ng}^{min}-\alpha_{ng}^{max}+\gamma_n\leq C_{ng}~~\forall g\in\phi^{G-n},\forall n\in\phi^N$$
$$\beta_l^{min}-\beta_l^{max}+\frac{\epsilon_l^{min}}{\beta_l}-\frac{\epsilon_l^{max}}{\beta_l}-\gamma_{n}=0~~\forall l\in\phi^L\mid SB(l)=n\\$$
$$\beta_l^{min}-\beta_l^{max}+\frac{\epsilon_l^{min}}{\beta_l}-\frac{\epsilon_l^{max}}{\beta_l}+\gamma_{n}=0~~\forall l\in\phi^L\mid RB(l)=n\\$$
\begin{gather}
\begin{split}
&-\sum_{\forall l \in\phi^l\mid SB(l)=n}\epsilon_l^{min}+\sum_{\forall l \in\phi^l\mid RB(l)=n}\epsilon_l^{min}\\
&+\sum_{\forall l \in\phi^l\mid SB(l)=n}\epsilon_l^{max}-\sum_{\forall l \in\phi^l\mid RB(l)=n}\epsilon_l^{max}\nonumber\\
&+\delta_n^{min}-\delta_n^{max}=0~~\forall n\in \phi^n\\
\end{split}
\end{gather}%
}

\begin{document}
\noindent
Using \verb|fleqn| option:
\MyEquations

\noindent
With \verb|fleqn| option and \verb|\mathindent=0pt|:
\setlength{\mathindent}{0pt}
\MyEquations
\end{document}


## Code: flalign environment:

\documentclass{article}
\usepackage{showframe}
\usepackage{amsmath}

\begin{document}
\noindent
Using \verb|flalign| environment:
\begin{flalign}
&\alpha_{ng}^{min}-\alpha_{ng}^{max}+\gamma_n\leq C_{ng}~~\forall g\in\phi^{G-n},\forall n\in\phi^N \\
&\beta_l^{min}-\beta_l^{max}+\frac{\epsilon_l^{min}}{\beta_l}-\frac{\epsilon_l^{max}}{\beta_l}-\gamma_{n}=0
\forall l\in\phi^L\mid SB(l)=n\\
&\beta_l^{min}-\beta_l^{max}+\frac{\epsilon_l^{min}}{\beta_l}-\frac{\epsilon_l^{max}}{\beta_l}+\gamma_{n}=0~~\forall l\in\phi^L\mid RB(l)=n \\\nonumber
&-\sum_{\forall l \in\phi^l\mid SB(l)=n}\epsilon_l^{min}+\sum_{\forall l \in\phi^l\mid RB(l)=n}\epsilon_l^{min}\\\nonumber
&+\sum_{\forall l \in\phi^l\mid SB(l)=n}\epsilon_l^{max}-\sum_{\forall l \in\phi^l\mid RB(l)=n}\epsilon_l^{max}\\\nonumber
&+\delta_n^{min}-\delta_n^{max}=0~~\forall n\in \phi^n
\end{flalign}
Using \verb|flalign| environment
with a trailing \verb|&|:
\begin{flalign}
&\alpha_{ng}^{min}-\alpha_{ng}^{max}+\gamma_n\leq C_{ng}~~\forall g\in\phi^{G-n},\forall n\in\phi^N &\\
&\beta_l^{min}-\beta_l^{max}+\frac{\epsilon_l^{min}}{\beta_l}-\frac{\epsilon_l^{max}}{\beta_l}-\gamma_{n}=0
\forall l\in\phi^L\mid SB(l)=n\\
&\beta_l^{min}-\beta_l^{max}+\frac{\epsilon_l^{min}}{\beta_l}-\frac{\epsilon_l^{max}}{\beta_l}+\gamma_{n}=0~~\forall l\in\phi^L\mid RB(l)=n \\\nonumber
&-\sum_{\forall l \in\phi^l\mid SB(l)=n}\epsilon_l^{min}+\sum_{\forall l \in\phi^l\mid RB(l)=n}\epsilon_l^{min}\\\nonumber
&+\sum_{\forall l \in\phi^l\mid SB(l)=n}\epsilon_l^{max}-\sum_{\forall l \in\phi^l\mid RB(l)=n}\epsilon_l^{max}\\\nonumber
&+\delta_n^{min}-\delta_n^{max}=0~~\forall n\in \phi^n
\end{flalign}
\end{document}


## Code: align environment:

\documentclass{article}
\usepackage{showframe}
\usepackage{amsmath}

\begin{document}
\noindent
Using \verb|align| environment:
\begin{align}
&\alpha_{ng}^{min}-\alpha_{ng}^{max}+\gamma_n\leq C_{ng}~~\forall g\in\phi^{G-n},\forall n\in\phi^N \\
&\beta_l^{min}-\beta_l^{max}+\frac{\epsilon_l^{min}}{\beta_l}-\frac{\epsilon_l^{max}}{\beta_l}-\gamma_{n}=0
\forall l\in\phi^L\mid SB(l)=n\\
&\beta_l^{min}-\beta_l^{max}+\frac{\epsilon_l^{min}}{\beta_l}-\frac{\epsilon_l^{max}}{\beta_l}+\gamma_{n}=0~~\forall l\in\phi^L\mid RB(l)=n \\\nonumber
&-\sum_{\forall l \in\phi^l\mid SB(l)=n}\epsilon_l^{min}+\sum_{\forall l \in\phi^l\mid RB(l)=n}\epsilon_l^{min}\\\nonumber
&+\sum_{\forall l \in\phi^l\mid SB(l)=n}\epsilon_l^{max}-\sum_{\forall l \in\phi^l\mid RB(l)=n}\epsilon_l^{max}\\\nonumber
&+\delta_n^{min}-\delta_n^{max}=0~~\forall n\in \phi^n
\end{align}
\end{document}

• Why not simply align? – egreg Oct 11 '14 at 17:59
• @egreg: Thanks. Can't believe I had missed the most obvious solution. :-) – Peter Grill Oct 11 '14 at 18:49