數學環境分隔符號錯誤。 \end{方程式}

數學環境分隔符號錯誤。 \end{方程式}

你好,我是乳膠初學者,我正在嘗試編寫這兩個方程,但是我遇到了不同的錯誤,這段程式碼有什麼問題嗎?請問有人可以幫忙嗎?先致謝

\begin{equation}


$Support(X  )= \frac{No,of\; transactions\;  that \; contain\;  X}{No,of \;transactions\; in\; the \;database}$

\end{equation}

%\noindent
\begin{equation}

$confidence(X \longrightarrow Y)$=$ \frac {Support (X \cup Y) }{ support(X)}$
\end{equation}

錯誤訊息是:

Missing $ inserted. 
Display math should end with $$.
Bad math environment delimiter. \end{equation} 
  Missing $ inserted. \end{equation}
  You can't use `\eqno' in vertical mode. 

答案1

我認為以下內容可能就是您想要寫的內容。觀察\text第一個方程式的分子和分母中的使用。我將X第一個分子中的術語用$符號括起來,以通知 LaTeX 它(X)應該在數學模式下處理。

另請注意,顯示數學環境中不得有空行(例如equation)。

在此輸入影像描述

\documentclass{article}

\usepackage{amsmath} % for "\text" and "\DeclareMathOperator" macros
\DeclareMathOperator{\Support}{Support}
\DeclareMathOperator{\Confidence}{Confidence}

\begin{document}

\begin{equation}
\Support(X) = \frac{\text{No of transactions that contain $X$}}%
                   {\text{No of transactions in the database}}
\end{equation}

\begin{equation}
\Confidence(X \longrightarrow Y) = \frac{\Support(X\cup Y)}{\Support(X)}
\end{equation}

\end{document} 

相關內容