5

I have the following equation:

\begin{document}
\Large
\begin{equation}\label{eq: eq1}
\begin{split}
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{split}
\end{equation}
\large
\end{document}

What I would like to do is to store on the left the first part, while on the right the second one. I tried to structure it using this code but I failed:

\begin{document}
\Large
\begin{equation}
\label{eq: eq1}
\begin{aligned}
\left(P(\mathbf{W_{d}}, \mathbf{Z_{d}}, \mathbf{\theta_d}, \mathbf{\Phi}; \mathbf{\alpha}, \mathbf{\beta}) \right.
\notag \\
\left.
= \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}
\right)
\end{aligned}
\end{equation}
\large
\end{document}

Can anyone help me?

Thanks!

1
  • 1
    Do you really need to use \ Large before the equation? – Bernard Jan 23 at 20:53
10

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

enter image description here

\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}
0
9

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

  1. a \ubrace command that adds braces around \underbrace and avoids the weird _ syntax.

  2. using \bm instead of \boldsymbol: it's shorter and better (you have to load bm 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}

enter image description here

4
4

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}
1
  • 2
    You may also want to suggest to the OP to replace \Pi with \prod. – Mico Jan 23 at 21:07

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.