我正在尝试写一行如下的公式:
{\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}}}
其应该产生:
然而,在编译这个 LaTeX 后,我得到:
! Missing $ inserted.
<inserted text>
$
l.658 ...\mid\emph{d}$) =} \emph{P}(\emph{c})\prod
\textsubscript{\emph{w}\i...
?
我没有使用该formula
包,因为它不是我了解的东西而且这是我必须维护的现有代码。
有人能解释一下原因吗?
答案1
没有任何公式包(;-))
\documentclass{article}
\begin{document}
\begin{equation}
P(c\mid d) = P(c) \prod_{w\in d} P(w\mid c)^{n_{wd}}
\end{equation}
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}