I would like to typeset an equation, with multiple equalities and long terms.
Each equals sign should be left-aligned on a new line. But leftover terms that flow to a new line should be right-aligned.
Here's a minimal example, I've used alignment symbols to position the parts of the equation:
\begin{align*}
&p_{very\;long\;function}(x) =&& \\
&&\int f_{very \; long \; integral \; terms}(x)&\\
&&\mathcal{N}(x; 0, \sigma^2) dx&\\
&= 2&&
\end{align*}
The alignment pushes the equation apart. It does left- and right- align it, but the individual columns can't overlap. So it's not the same as just flowing the lines left and right.
What I would like to get is this:
In the image above, the equation is as wide as the widest line. And individual lines are left or right-aligned.
I've searched for related questions, on how to configure alignment. There are many similar questions, but none of them seem to answer my problem:
- Aligning equations with text with alignat
- https://stackoverflow.com/questions/62330024/latex-alignat-syntax
- Aligning equations across multiple lines with proper \left( and \right)
- Aligning equations with left and right comment
UPDATE:
To clarify my question: The document is in two-column mode. That's why I need a compact way to typeset my equations.
Here is an example equation with 4 lines. The first and last should be left-bound. The second one determines the width of the equation, the third one should be right-bound.
I think the key problem is that align and alignat columns may not overlap.
The code is this:
\begin{align*}
&p_{long \; function}(x) =\\
& \int f_{many\; very \; long \; integral \; terms}(x)\\
&\mathcal{N}(x; 0, \sigma^2) dx\\
&= 2
\end{align*}
It should look like this:
Best Answer
I supposed you're in two-column mode, and, if I understand well your requirements, they can be satisfied with an
aligned
environment nested in the outeralign*
(with a single alignment column). However, I also propose another solution, based onmultlined
: