4

I have some quite long lines of maths I have to put into a two-colum document format, so the maths often needs to be split between multiple lines.

In the example below, I'd like to align the open parentheses in the last line with that in the line above.

\begin{align}
P(&\mathcal{X},\mathcal{C},\xi|\alpha,\beta,\theta^0) \notag\\
&= \prod_d P(\mathcal{X}_d|\beta)P(\mathcal{C}_d|\alpha,\xi) \prod_c P(\xi^c|\theta^0) \notag\\
&\propto\prod_d \beta^d_c \left(F(\mathcal{C}_d)\prod_t (\mathcal{C}_{dt})^{\alpha\xi_t}\right) \notag\\
&                          \left( \prod_c F(\xi^c)\prod_t(\xi_t)^{\theta^0_t} \right)
\end{align}

enter image description here

Adding another alignment mark pushes the last parts to the right (see below):

\begin{align}
P(&\mathcal{X},\mathcal{C},\xi|\alpha,&\beta,\theta^0) \notag\\
&= \prod_d P(&\mathcal{X}_d|\beta)P(\mathcal{C}_d|\alpha,\xi) \prod_c P(\xi^c|\theta^0) \notag\\
&\propto\prod_d \beta^d_c &\left(F(\mathcal{C}_d)\prod_t (\mathcal{C}_{dt})^{\alpha\xi_t}\right) \notag\\
&                         &\left( \prod_c F(\xi^c)\prod_t(\xi_t)^{\theta^0_t} \right)
\end{align}

I tried a command called \shoveleft to shove them to the left, but it didn'nt work:

\begin{align}
P(&\mathcal{X},\mathcal{C},\xi|\alpha,&\shoveleft{\beta,\theta^0)} \notag\\
&= \prod_d P(&\shoveleft{\mathcal{X}_d|\beta)P(\mathcal{C}_d|\alpha,\xi) \prod_c P(\xi^c|\theta^0)} \notag\\
&\propto\prod_d \beta^d_c &\shoveleft{\left(F(\mathcal{C}_d)\prod_t (\mathcal{C}_{dt})^{\alpha\xi_t}\right)} \notag\\
&                         &\left( \prod_c F(\xi^c)\prod_t(\xi_t)^{\theta^0_t} \right) \notag\\
\end{align}

Both the previous two attempts produce something like the image below. I also tried a split environment with bizzare results.

enter image description here

Even if \shoveleft worked, this wouldn't be ideal, as it'd mess with the internal spacing of the first two lines. Ideally, I'd like the first two lines to ignore the & position markers in the last two lines (something like \multicolumn in a table).

3 Answers 3

7

With amsmath there is the aligned environment you can use inside other building blocks; it inserts a tiny space before it which may be undone with \!.

If you use the combination of split inside equation instead one align, then only one equation number is attached and you avoid writing \notag many times. By default the number is centered, but the tbtags option will place it on the final line.

If you load mathtools, which loads amsmath, you can shove the first line left easily with \MoveEqLeft, rather than having to find specify a unusual alignment point in that line. The command takes an optional argument, a number specifying how many ems to move left, the default is 2.

I illustrate two different ways of including an aligned block, they give different vertical spacing to the equation number.

Sample output

\documentclass{article}

\usepackage[tbtags]{mathtools}

\begin{document}

\begin{equation}
  \begin{split}
    \MoveEqLeft
    P(\mathcal{X},\mathcal{C},\xi|\alpha,\beta,\theta^0) \\
    &= \prod_d P(\mathcal{X}_d|\beta)P(\mathcal{C}_d|\alpha,\xi)
    \prod_c P(\xi^c|\theta^0) \\ 
    &\propto\prod_d \beta^d_c\!\begin{aligned}[t]
      &\left(F(\mathcal{C}_d)\prod_t
        (\mathcal{C}_{dt})^{\alpha\xi_t}\right)\\
      & \left( \prod_c F(\xi^c)\prod_t(\xi_t)^{\theta^0_t} \right)
    \end{aligned}\\
  \end{split}
\end{equation}
or
\begin{equation}
  \begin{split}
    \MoveEqLeft
    P(\mathcal{X},\mathcal{C},\xi|\alpha,\beta,\theta^0) \\
    &= \prod_d P(\mathcal{X}_d|\beta)P(\mathcal{C}_d|\alpha,\xi)
    \prod_c P(\xi^c|\theta^0) \\ 
    &\,\begin{aligned}[b]\propto\prod_d \beta^d_c
      &\left(F(\mathcal{C}_d)\prod_t
        (\mathcal{C}_{dt})^{\alpha\xi_t}\right)\\
      & \left( \prod_c F(\xi^c)\prod_t(\xi_t)^{\theta^0_t} \right)
    \end{aligned}
  \end{split}
\end{equation}

\end{document}
0
3

You can use the \phantom command

\documentclass{article}

\usepackage{multicol,amsmath,amssymb,geometry}

\begin{document}
\begin{multicols}{2}

\begin{align}
P(&\mathcal{X},\mathcal{C},\xi|\alpha,\beta,\theta^0) \notag\\
&= \prod_d P(\mathcal{X}_d|\beta)P(\mathcal{C}_d|\alpha,\xi) \prod_c P(\xi^c|\theta^0) \notag\\
&\propto\prod_d \beta^d_c \left(F(\mathcal{C}_d)\prod_t (\mathcal{C}_{dt})^{\alpha\xi_t}\right) \notag\\
&\phantom{\propto\prod_d \beta^d_c } \left( \prod_c F(\xi^c)\prod_t(\xi_t)^{\theta^0_t} \right)
\end{align}

\begin{align}
P(&\mathcal{X},\mathcal{C},\xi|\alpha,\beta,\theta^0) \notag\\
&= \prod_d P(\mathcal{X}_d|\beta)P(\mathcal{C}_d|\alpha,\xi) \prod_c P(\xi^c|\theta^0) \notag\\
&\propto\prod_d \beta^d_c \left(F(\mathcal{C}_d)\prod_t (\mathcal{C}_{dt})^{\alpha\xi_t}\right) \notag\\
&\left( \prod_c F(\xi^c)\prod_t(\xi_t)^{\theta^0_t} \right)
\end{align}
\end{multicols}

\end{document}

enter image description here

3

Andrew Swann’s answer is clearly superior; but after all, in the end I decided to leave my poor attempt (I had previously deleted it) for the purpose of documenting how the correct spacing could be obtained by combining the \! mentioned by A.S. with the \; called for by a (nonscript) \mathrel:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\begin{document}

\begin{align}
P(&\mathcal{X},\mathcal{C},\xi|\alpha,\beta,\theta^0) \notag\\
&= \prod_d P(\mathcal{X}_d|\beta)P(\mathcal{C}_d|\alpha,\xi) \prod_c P(\xi^c|\theta^0) \notag\\
&\;\!\begin{aligned}[b]
    \propto\prod_d \beta^d_c
        &\left(F(\mathcal{C}_d)\prod_t (\mathcal{C}_{dt})^{\alpha\xi_t}\right) \\
        &\left( \prod_c F(\xi^c)\prod_t(\xi_t)^{\theta^0_t} \right)
    \end{aligned}
\end{align}

\end{document}

Or, equivalently (and perhaps better):

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\begin{document}

\begin{align}
P(&\mathcal{X},\mathcal{C},\xi|\alpha,\beta,\theta^0) \notag\\
&= \prod_d P(\mathcal{X}_d|\beta)P(\mathcal{C}_d|\alpha,\xi) \prod_c P(\xi^c|\theta^0) \notag\\
&\!\begin{aligned}[b]
    {}\propto\prod_d \beta^d_c
        &\left(F(\mathcal{C}_d)\prod_t (\mathcal{C}_{dt})^{\alpha\xi_t}\right) \\
        &\left( \prod_c F(\xi^c)\prod_t(\xi_t)^{\theta^0_t} \right)
    \end{aligned}
\end{align}

\end{document}

Output (at 300dpi):

Output of the code

You must log in to answer this question.

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