I am having trouble aligning my comments and equations in the align environment. I would like my equations as far left as possible, the numbers to the equations as far right as possible (but guaranteed to stay on the same line!), and the comment right aligned to the number of the equation, with as much space as possible between the equation and comment.
It seems like the issue is that the text comments will not start farther to the left than the right-most part of the longest equation (like the third equation below).
Example:
\documentclass[12pt, letterpaper]{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
&f'\left(0\right)=\lim\limits_{x\to 0} \frac{f\left(x\right)-f\left(0\right)}{x-0}
&\text{ limit definition of derivative}\\
&=\lim\limits_{x\to 0} \frac{x^2 \sin\left(\frac{1}{x}\right)}{x}=\lim\limits_{x\to 0} x\sin\left(\frac{1}{x}\right)
&\text{ simplifying the limit}\\
&0\leq\left| \sin \left(\frac{1}{x}\right) \right| \leq 1 \implies 0\leq \left|x \sin \left(\frac{1}{x}\right)\right|\leq \lvert x\rvert
&\text{bound for sine}
\end{align}
\end{document}
Output:
So far I have tried using the double &&
and the flalign
package, but neither have helped me.
Best Answer
If you measure the left part in the last line and right part in the first line, you find that their sum exceeds the line width.
The
align
environment will never make two columns overlap. You might exploit the particular case, where the longer text will fit in the first line even if a small overlap with the final line appears.Not a general method, I'm afraid: each elephant needs its particular method to be stuffed in a suitcase.
I tried with
\hspace{-2em}
without success. With\hspace{-2.5em}
the amount of overlap is smaller.Avoid
\left
and\right
unless necessary (and consider that they essentially only work well with fractions or arrays).Also
\limits
is to be very rarely used when doing inline math and does nothing when in display math.