# How to left-align particular equations using own environment?

I'm trying to left align particular equations. To do that I created a new environment (because I need it a few times).

Now, I found that there are various options to do that:

• using the fleqn option - but that does a left alignment for all the equations in the document
• flalign - but for that I always have to write && at the end and it doesn't seem to work in an environment I defined

I would like to be able to use for this kind of special equations some code like this

\begin{leftalignedequation}
...
\end{leftalignedequation}


and it should do all the magic itself.

And so my question is: What would you see as the best way to achieve that? I don't seem to find a good solution.

-
I think you need to also adjust the value of \mathindent. Setting that to 0pt should left align to the margin. – Peter Grill Feb 22 '13 at 18:05
The package nccmath offers this. But I'd advise against doing it. First ask yourself why you should do it. – egreg Feb 22 '13 at 21:53
But mathindent does so for the whole document, right? @egreg I will have a look at nccmath, thanks. I know, and I think you are right in asking whether it's really necessary. The document is about defining a relational algebra (for databases) and I mix a more mathematic and more computer science view and the latter I would like to align left. – navige Feb 22 '13 at 23:42

You can toggle the left aligning of equations via \@fleqntrue and \@fleqnfalse. Changing \@mathindent will change how much they are offset from the left margin. Perhaps the simplest way is to turn this on off for parts of a document by defining a new environment fleqns:

\makeatletter
\newenvironment{fleqns}[1][0pt]{\@mathmargin=#1\@fleqntrue}{\@fleqnfalse}
\makeatother


Here there is an optional argument allowing you to set the indent.

\documentclass{article}

\usepackage{amsmath}

\makeatletter
\newenvironment{fleqns}[1][0pt]{\@mathmargin=#1\@fleqntrue}{\@fleqnfalse}
\makeatother

\begin{document}

$$x=y$$

\begin{fleqns}
$$z=t$$
text
\begin{gather}
p=q\\
y=r
\end{gather}
\end{fleqns}

$$s=t$$

\begin{fleqns}[2em]
$$z=t$$
text
\begin{gather}
p=q\\
y=r
\end{gather}
\end{fleqns}

\end{document}


You could extend this to define flushleft versions of the different equationing environments, but that would require a new definition for each case.

-