[Tex/LaTex] Line break within an align-environment

alignequationsformattingmultlinesplit

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.
Example

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.
example2

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:

  1. A \phantomrel command which creates a “phantom” relation symbol that occupies the same space as the underlying symbol, thus the \phantomrel{=}.
  2. A \hphantom{\int_0^T \int_{K_1}} that creates a horizontal phantom space which serves as indent for the \times ... contents.
  3. A \diff command dedicated for differentials.
  4. A \abs command dedicated for absolute values, which must be created using \DeclarePairedDelimiter from the mathtools package. This \abs{...} has several advantages over |...|:

    • Try typing $|-x|$ and $\abs{-x}$ to see the wrong spacing of the negative sign in the former expression.
    • You get to enlarge the delimiters by variants \abs[\big]{-x}, \abs[\Big]{-x}, \abs[\bigg]{-x} and \abs[\Bigg]{-x}.
    • There is another variant \abs*{-x} which extends delimiters automatically (like a \left and \right pair), but acts like \mathopen...\mathclose and not like \mathinner, which is better.
  5. 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.

\documentclass{article}
\usepackage{mathtools}% For `multlined' and loads `amsmath'
\newcommand*\phantomrel[1]{\mathrel{\phantom{#1}}}% My preferred typesetting
\newcommand*\diff{\mathop{}\!d}% Just in case your editor asks for \mathrm{d}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}

\begin{document}
\noindent
Using \verb|align*| and \verb|multlined| works fine:
\begin{align*}
A & = \text{something something something} \\
  & = \begin{multlined}[t][10cm]
        \text{something something something anything anything} \\
        + \text{anything anything anything}
      \end{multlined} \\
  & = \text{anything anything anything anything}
\end{align*}
However, I~would typeset as follows instead:
\begin{align*}
A & = \text{something something something} \\
  & = \text{something something something anything} \\
  & \phantomrel{=} {} + \text{anything anything anything anything} \\
  & = \text{anything anything anything anything}
\end{align*}
So your specific example becomes
\begin{align*}
\mathcal{A} & = \int_0^T \int_{K_1}
    \Bigl[ c(\alpha,n) + \alpha\abs{u}^2
           - \alpha^2 \bigl(u\cdot(x-x_0)\bigr)^2
             \bigl(\abs{x-x_0}^2 + h^2\bigr)^{-1} \Bigr] \\
 & \phantomrel{=} \hphantom{\int_0^T \int_{K_1}}
    \times \bigl[\abs{x-x_0}^2 + h^2 \bigr]^\alpha \tau \diff x\diff t \\
 & \leq K \int_0^T \int_{K_1} \pi \diff x\diff t
\end{align*}
\end{document}

split example

Related Question