I want to write a long calculation with the align-environment. One of the lines is too long for one line though, so I want it to split into two lines , with the second line right-attached. Example: See picture.
I tried every combination with equation, align, aligned, split, multline, multlined,… I could think of, sadly nothing worked so far. At the moment I solve the problem with &\hspace + ...
, but I want to have a solution that is independent of the chosen font, margin, etc.
Here is a more specific example, where I need this function. It is a split cross product and I think that it looks weird if the second part of the cross product is left attached:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align*}
\mathcal{A} &= \int_0^T\int_{K_1}\left[c(\alpha,n)+\alpha|u|^2-\alpha^2(u\cdot(x-x_0))^2\left(|x-x_0|^2+h^2 \right)^{-1} \right]\\
&\hspace{7.2cm}\times\left[|x-x_0|^2+h^2 \right]^{\alpha}\tau~dx~dt\\
&\leq K\int_0^T\int_{K_1}\pi~dx~dt
\end{align*}
\end{document}
I want to replace the \hspace{7.2cm}
with a margin-independent command.
Best Answer
IMHO, splitting long equations should always be done with more care from the author. So I always split my equations manually to get the desired output.
My preferred solution below uses the following tricks:
\phantomrel
command which creates a “phantom” relation symbol that occupies the same space as the underlying symbol, thus the\phantomrel{=}
.\hphantom{\int_0^T \int_{K_1}}
that creates a horizontal phantom space which serves as indent for the\times ...
contents.\diff
command dedicated for differentials.A
\abs
command dedicated for absolute values, which must be created using\DeclarePairedDelimiter
from themathtools
package. This\abs{...}
has several advantages over|...|
:$|-x|$
and$\abs{-x}$
to see the wrong spacing of the negative sign in the former expression.\abs[\big]{-x}
,\abs[\Big]{-x}
,\abs[\bigg]{-x}
and\abs[\Bigg]{-x}
.\abs*{-x}
which extends delimiters automatically (like a\left
and\right
pair), but acts like\mathopen...\mathclose
and not like\mathinner
, which is better.Please don’t abuse
\left
and\right
. Sometimes they create delimiters that are too big or too small, and they create\mathinner
. I used manual sizing throughout your example.The environments you mentioned work perfectly fine.