How to align this equation?
In addition to switching from an equation
/split
combination to a multline
setup, you should (a) replace \Pi
with \prod
, (b) replace both instances of |
with \mid
, and (c) use \boldsymbol
instead of \mathbf
in many cases. In addition, you could (d) change all instances of P(
to \P(
and define \P
as a math operator. (Operators are generally supposed to be typeset using upright letters.)
\documentclass{article}
\usepackage{amsmath} % for 'multline' env. and '\text' and '\DeclareMathOperator' macros
\let\P\relax % undefine '\P'
\DeclareMathOperator{\P}{P} % probability "operator"
\begin{document}
\begingroup
\Large
\begin{multline}\label{eq: eq1}
\P(\mathbf{W}_{\!d}, \mathbf{Z}_{d},\boldsymbol{\theta}_d, \boldsymbol{\Phi}; \boldsymbol{\alpha}, \boldsymbol{\beta}) \\
= \prod_{n=1}^N \underbrace{\underbrace{\underbrace{%
\P(\mathbf{W}_{\!d,n}\mid \boldsymbol{\varphi}_k) \P(\boldsymbol{\Phi};\boldsymbol{\beta})}_{\text{word level}}
\cdot \P(\mathbf{Z}_{d,n}\mid\boldsymbol{\theta}_d)}_{\text{topic level} }
\cdot \P(\boldsymbol{\theta}_d;\boldsymbol{\alpha})}_{\text{corpus level}}
\end{multline}
\endgroup
\end{document}
While I endorse Mico's answer, I have a few improvements to it and want to deal with the \Large
and \large
in your code.
The suggested improvements are
a
\ubrace
command that adds braces around\underbrace
and avoids the weird_
syntax.using
\bm
instead of\boldsymbol
: it's shorter and better (you have to loadbm
as indicated).
Whether P should be upright I leave to your decision.
Let's turn to the \Large
business. A \Large
command immediately before a display will have nasty effects on the preceding text (because there must never be a blank line before a math display).
If you're typesetting with a global \large
declaration, don't. Use extarticle
at 14pt
if you really want such a big font size: usually 12pt size is more than big enough.
Here's a sizeddisplay
that cures the problem of having a larger font in the display. On the other hand, the display is already very prominent and will not benefit from larger type size. See the image below to judge about it.
\documentclass[14pt]{extarticle}
\usepackage{amsmath,mathtools,bm}
\usepackage{lipsum}% mock text
\newenvironment{sizeddisplay}[1][]{%
\par\nopagebreak
\skip0=\abovedisplayskip
\skip2=\abovedisplayshortskip
\skip4=\belowdisplayskip
\skip6=\belowdisplayshortskip
#1% size command
\abovedisplayskip=\skip0
\abovedisplayshortskip=\skip2
\belowdisplayskip=\skip4
\belowdisplayshortskip=\skip6
\mbox{}\vadjust{\nopagebreak\vskip-\baselineskip}%
}{\ignorespacesafterend}
\newcommand{\ubrace}[2]{{\underbrace{#1}_{#2}}}
\begin{document}
\lipsum[1][1-4]
\begin{sizeddisplay}[\large]
\begin{multline}\label{eq:probability}
P(\mathbf{W}_{d}, \mathbf{Z}_{d}, \bm{\theta}_{d}, \mathbf{\Phi};
\bm{\alpha}, \bm{\beta}) \\
= \prod_{n=1}^N
\ubrace{
\ubrace{
\ubrace{
P(\mathbf{W}_{d,n}\mid\bm{\varphi}_{k})
P(\mathbf{\Phi};\bm{\beta})
}{\text{word level}}
\cdot P(\mathbf{Z}_{d,n}\mid\bm{\theta}_{d})
}{\text{topic level}}
\cdot P(\bm{\theta}_{d};\bm{\alpha})
}{\text{corpus level}}
\quad % don't go too near to the equation number
\end{multline}
\end{sizeddisplay}
\lipsum[1][1-4]
\begin{multline}\label{eq:repeated}
P(\mathbf{W}_{d}, \mathbf{Z}_{d}, \bm{\theta}_{d}, \mathbf{\Phi};
\bm{\alpha}, \bm{\beta}) \\
= \prod_{n=1}^N
\ubrace{
\ubrace{
\ubrace{
P(\mathbf{W}_{d,n}\mid\bm{\varphi}_{k})
P(\mathbf{\Phi};\bm{\beta})
}{\text{word level}}
\cdot P(\mathbf{Z}_{d,n}\mid\bm{\theta}_{d})
}{\text{topic level}}
\cdot P(\bm{\theta}_{d};\bm{\alpha})
}{\text{corpus level}}
\quad % don't go too near to the equation number
\end{multline}
\lipsum[1][1-4]
\end{document}
You mean like this?
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\Large
\begin{multline}\label{eq: eq1}
P(\mathbf{W_{d}}, \mathbf{Z_{d}}, \mathbf{\theta_d}, \mathbf{\Phi}; \mathbf{\alpha}, \mathbf{\beta}) \\
= \Pi_{n=1}^N \underbrace{\underbrace{\underbrace{P(\mathbf{W_{d,n}}|\mathbf{\varphi_k}) P(\mathbf{\Phi};\mathbf{\beta})}_\text{word level} \cdot P(\mathbf{Z_{d,n}}|\mathbf{\theta_d})}_\text{topic level} \cdot P(\mathbf{\theta_d};\mathbf{\alpha})}_\text{corpus level}
\end{multline}
\end{document}