2

I would like to left-align two groups of equations that are gathered in the same environment centred on a page. I tried a few approaches and the best result I achieved so far is by using environments aligned inside align and playing with extra column separators &. The only problem is that the aligned environment adds only one equation, while I would like to number the last two lines in the first group.

I know align environment numbers each line with an equation but I can't nest them together. I don't think it's possible to "force" it; anything that works opposite to \nonumber. I also tried to use tabular with equations inside \vbox, \mbox, \minipage etc. but the latter completely messes the layout, particularly equation numbers.

The MWE

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage[margin=2cm]{geometry}

\newcommand{\eqdef}{\overset{\mathrm{def}}{=\joinrel=}}

\begin{document}

\begin{align}
    &\begin{aligned}[b]
        f_X(X|A,B,C) &\eqdef\ A \\
    &=\ B + C \\
    &=\ D + E + F \\
    &=\ \frac{1}{Z} Y
    \end{aligned} \\[1em]
    &\begin{aligned}
        Z(\mu_0, \kappa_0, \alpha_0, \beta_0)\ &=\
            \frac{\Gamma(\alpha_0)}{\beta^{\alpha_0}} \left( \frac{2\pi}{\kappa_0} \right)
    \end{aligned}
\end{align}

\end{document}

enter image description here

3
  • Side remark: don't use standalone for MWE. article works well enough and unless you are writing your entire document inside a standalone, chances are there's nothing in article that would hurt any diagnostic process. Apr 30 at 14:30
  • standalone was only there to generate a document with custom paper size to fit the content, so I could paste it here as an image. I meant to post a correct MWE.
    – Celdor
    Apr 30 at 14:35
  • 1
    Ah! I used to do that. Then I realized it is just as quick to just write/build using article and take a screen cap... Apr 30 at 14:39
3

I'd go for the simplest solution, that is, aligning the equals signs. The second solution would require some shift to center everything, but this depends on the actual equations in the first block and their widths.

The third solution, centering the two blocks should be generally preferable, but in this case it's not as nice as it could be, because the final equals signs are too near to each other.

\documentclass{article}
\usepackage{mathtools}
\usepackage{calc} % for the second solution

\newcommand{\eqdef}{\overset{\mathrm{def}}{=\joinrel=}}

\begin{document}

\paragraph{Simplest solution, no left alignment}
\begin{align}
f_X(X|A,B,C)
  &\eqdef A \notag \\
  &= B + C \notag \\
  &= D + E + F \\
  &= \frac{1}{Z} Y \\
Z(\mu_0, \kappa_0, \alpha_0, \beta_0)
  &= \frac{\Gamma(\alpha_0)}{\beta^{\alpha_0}} \left( \frac{2\pi}{\kappa_0} \right)
\end{align}

\paragraph{Not so nice solution, with left alignment}
\begin{align}
f_X(X|A,B,C)
  &\eqdef A \notag \\
  &= B + C \notag \\
  &= D + E + F \\
  &= \frac{1}{Z} Y \\
\mathmakebox[\widthof{$f_X(X|A,B,C)$}][l]{Z(\mu_0, \kappa_0, \alpha_0, \beta_0)
  = \frac{\Gamma(\alpha_0)}{\beta^{\alpha_0}} \left( \frac{2\pi}{\kappa_0} \right)}
\end{align}

\paragraph{Possibly better, with centering of the blocks}
\begin{gather}
\begin{align}
f_X(X|A,B,C)
  &\eqdef A \notag \\
  &= B + C \notag \\
  &= D + E + F \\
  &= \frac{1}{Z} Y
\end{align} \\
Z(\mu_0, \kappa_0, \alpha_0, \beta_0)
  = \frac{\Gamma(\alpha_0)}{\beta^{\alpha_0}} \left( \frac{2\pi}{\kappa_0} \right)
\end{gather}

\end{document}

enter image description here

1

In your specific case that is shown, alignat gives a nice alternative to the various solutions that egreg showed. This also helps with the fact that your \eqdef is longer than the normal equals sign.

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage[margin=2cm]{geometry}

\newcommand{\eqdef}{\overset{\mathrm{def}}{=\joinrel=}}

\begin{document}

\begin{alignat}{2}
        & f_X(X|A,B,C) &\eqdef & A \\
        &&= &B + C \\
        &&= &D + E + F \\
        &&= &\frac{1}{Z} Y\\
        &Z(\mu_0, \kappa_0, \alpha_0, \beta_0) &=&
            \frac{\Gamma(\alpha_0)}{\beta^{\alpha_0}} \left( \frac{2\pi}{\kappa_0} \right)
\end{alignat}

\end{document}

(If you are not familiar with it, alignat is explained in detail in the amsmath manual. It is basically align but suppressing a lot of extra spaces normally included in align, so the output may look a bit cramped. You are supposed to add spacing yourself. For example, you may choose to replace each of the = by =~ and \eqdef by \eqdef~ to move the RHS a bit farther away.)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.