# Problem getting expression of formula to compile

I am trying to write a line of a formula as follows:

{\emph{P}($\emph{c}\mid\emph{d}$) =} \emph{P}(\emph{c})\prod \textsubscript{\emph{w}\in$\emph{d}}\emph{P}($\emph{w}\mid\emph{c}$) \textsuperscript{\emph{n}\textsubscript{\emph{wd}}}  Which should produce: Yet upon compiling this LaTeX, I get: ! Missing$ inserted.
<inserted text>
$l.658 ...\mid\emph{d}$) =} \emph{P}(\emph{c})\prod
\textsubscript{\emph{w}\i...

?


I am not using the formula package because it is not something I know and this is the existing code I have to maintain.

Can anyone suggest why?

• Formula package? Do you mean amsmath? You should use an introductory book on LaTeX, perhaps – user31729 Dec 30 '15 at 21:31
• When I get the chance. This is what I have for now. – Mr Morgan Dec 30 '15 at 21:32
• What do the $P$s for? Conditional probabilities? – Bernard Dec 30 '15 at 21:35
• @Christian Hupfer: There does seem to be an old formula package, dating back to 1998, used to typeset physical units, the TeX Catalogue says… – Bernard Dec 30 '15 at 21:37
• @Bernard: Never heard of it – user31729 Dec 30 '15 at 21:47

Without any formula package (;-))

 \documentclass{article}

\begin{document}

$$P(c\mid d) = P(c) \prod_{w\in d} P(w\mid c)^{n_{wd}}$$

Inline:   $P(c\mid d) = P(c) \prod_{w\in d} P(w\mid c)^{n_{wd}}$

or display-style

$P(c\mid d) = P(c) \prod_{w\in d} P(w\mid c)^{n_{wd}}$

And here again with \verb!\mathcal!:

$\mathcal{P}(c\mid d) = \mathcal{P}(c) \prod\nolimits_{w\in d} \mathcal{P}(w\mid c)^{n_{wd}}$

\end{document}


• The only problem I have here is that the characters w \in d should be to the right of \prod. Can that be done? – Mr Morgan Dec 30 '15 at 21:41
• Yes, using \textstyle, but this looks weird, \prod\nolimits is better – user31729 Dec 30 '15 at 21:45
• @Mico: Yes, thanks. Forgot about that \nolimits – user31729 Dec 30 '15 at 21:49
• I guess the math style complainers will come anyway ;-) The code works -- contrary to the version by the O.P. ;-) – user31729 Dec 30 '15 at 21:50
• @MrMorgan When the product sign is in display math mode, it is customary to place the condition below it, for better clarity; when the formula is inline, the condition is placed to the side. – egreg Dec 30 '15 at 21:56