2

Is it possible to force Latex to maintain the left margin for wide equations?

I have a document with fleqn option enabled to left align all equations. If the equation is longer than available space LaTeX moves the equation left and, if this does not yield enough space, moves the equation tag to the next line. I would like to force LaTeX to always maintain the left margin even if the equations are longer than available space. I would like to enforce this in the entire document, even at a cost of violating the right margin. Is there any way to achieve this?

Problem example

MWE:

\documentclass{article}
\usepackage[fleqn]{amsmath}
\begin{document}

What I have now:
\begin{equation}
    f(x) = x^2
\end{equation}
\begin{equation}
    f(x) = x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^{10} + x^{11} + x^{12} + x^{13} + x^{14} + x^{15} + x^{16}
\end{equation}
\begin{equation}
    f(x) = x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^{10} + x^{11} + x^{12} + x^{13} + x^{14} + x^{15} + x^{16} + x^{17}
\end{equation}
\begin{equation}
    f(x) = x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^{10} + x^{11} + x^{12} + x^{13} + x^{14} + x^{15} + x^{16} + x^{17} + x^{18}
\end{equation}

What I want:
\begin{equation}
    f(x) = x^2
\end{equation}
\begin{equation}
    \qquad\,\, f(x) = x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^{10} + x^{11} + x^{12} + x^{13} + x^{14} + x^{15} + x^{16}
\end{equation}
\begin{equation}
    \qquad\,\,\, f(x) = x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^{10} + x^{11} + x^{12} + x^{13} + x^{14} + x^{15} + x^{16} + x^{17}
\end{equation}
\begin{equation}
    \qquad\,\,\,f(x) = x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^{10} + x^{11} + x^{12} + x^{13} + x^{14} + x^{15} + x^{16} + x^{17} + x^{18}
\end{equation}
\end{document}
1
  • 1
    it always preserves the left margin,which is why your last line sticks out on the right, but it relaxes \mathindent so simplest thing is to set that to zero \setlength\mathindent{0pt} producing this Mar 1 at 8:55

1 Answer 1

3

I'd break the long terms. Anyway, you're the ultimate judge.

Use gather.

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

\begin{document}

\begin{equation}
0=0
\end{equation}
Now let's see the result
\begin{gather}
  f(x) = x^2
\\
  f(x) = x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^{10} 
       + x^{11} + x^{12} + x^{13} + x^{14} + x^{15} + x^{16}
\\
  f(x) = x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^{10}
       + x^{11} + x^{12} + x^{13} + x^{14} + x^{15} + x^{16} + x^{17}
\end{gather}
It also works for a single equation
\begin{gather}
  f(x) = x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^{10}
       + x^{11} + x^{12} + x^{13} + x^{14} + x^{15} + x^{16} + x^{17} + x^{18}
\end{gather}

\end{document}

enter image description here

2
  • Thanks, simple solution, but I would have never guessed it. Is there any official reason why gather behaves differently from equation in this matter?
    – Raddeo
    Mar 1 at 15:56
  • 1
    @Raddeo Yes, there are many reasons: basically, equation is based on the standard $$...$$, whereas gather uses \halign.
    – egreg
    Mar 1 at 16:26

You must log in to answer this question.

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