3

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.

3
  • I think you need to also adjust the value of \mathindent. Setting that to 0pt should left align to the margin. Commented Feb 22, 2013 at 18:05
  • The package nccmath offers this. But I'd advise against doing it. First ask yourself why you should do it.
    – egreg
    Commented Feb 22, 2013 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
    Commented Feb 22, 2013 at 23:42

1 Answer 1

3

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.

Sample output

\documentclass{article}

\usepackage{amsmath}

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

\begin{document}

\begin{equation}
  x=y
\end{equation}

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

\begin{equation}
  s=t
\end{equation}

\begin{fleqns}[2em]
  \begin{equation}
    z=t
  \end{equation}
  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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .