方程式環境中缺少符號的恆定錯誤

方程式環境中缺少符號的恆定錯誤

我意識到這聽起來像是一個愚蠢的問題,但我的工作中出現了很多缺失的符號,但它們就在那裡!

一個這樣的例子是

\begin{equation} \label{eq:rgbtohsb}
\begin{center}
$Hue = \left\{\begin{array}{ccc}
\frac{g - b}{max(r,g,b)- min(r,g,b)} & \quad \text{if } & max(r,g,b) =  r\\
\frac{b-r}{max(r,g,b)- min(r,g,b)} & \quad \text{if } & max(r,g,b) = g \\
\frac{r-g}{max(r,g,b)- min(r,g,b)} & \quad \text{if } & max(r,g,b) = b \\
\end{array}

Saturation = \left \{ \begin{array}{ccc}
0 & \text{if } & r = g = b\\
\frac{max(r,g,b)}{V} & \quad \text{ otherwise} \\
\end{array} $

$Value = max(r,g,b)$

$Lightness = \frac{1}{2}(max(r,g,b) + min(r,g,b)) $
\end{center}
\end{equation}

正如你所看到的,我確實擁有所有的$.我還有\begin{center}\end{center}

另一個錯誤是它說\begin{document}結束於\end{equation}

這是我正在使用的標題

\documentclass[a4paper,11pt,twoside]{article}
\usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{fancyhdr}
\usepackage{mathtools}
\usepackage[parfill]{parskip}
\usepackage{program}
\pagestyle{fancyplain}
\fancyhf{}
\rhead{\fancyplain{}{\today}}
\cfoot{\fancyplain{}{\thepage}}
\usepackage{graphicx}
{\tiny }

我確實有一個\end{document}

感謝您的幫忙!

答案1

你的例子中有四個錯誤。

  • 您不需要\begin/end{center}顯示方程式;它們預設居中。

  • 您不需要在方程式環境中使用美元符號;你已經處於數學模式了。

  • \left沒有匹配就不能使用,但如果您不需要正確的分隔符,\right則可以使用。\right.

  • 方程式環境不能有空行。

更正後的版本(刪除了不必要的材料)如下。如果您不想對方程式進行編號,可以使用,equation*來代替equation, 並且可以將\begin{equation*}and縮寫\end{equation*}\[\]。最後,請注意,有預先定義的命令\max\min它們比僅鍵入“max”和“min”產生更好的結果。

\documentclass[a4paper,11pt,twoside]{article}
\usepackage{mathtools}
\begin{document}
\begin{equation} \label{eq:rgbtohsb}
\text{Hue} = \left\{
\begin{array}{ccc}
\frac{g - b}{max(r,g,b)- \min(r,g,b)} & \quad \text{if } & \max(r,g,b) =  r\\
\frac{b-r}{max(r,g,b)- \min(r,g,b)} & \quad \text{if } & \max(r,g,b) = g \\
\frac{r-g}{max(r,g,b)- \min(r,g,b)} & \quad \text{if } & \max(r,g,b) = b \\
\end{array}
\right.
\end{equation}
%
\begin{equation}
\text{Saturation} = \left \{ \begin{array}{ccc}
0 & \text{if } & r = g = b\\
\frac{\max(r,g,b)}{V} & \quad \text{ otherwise} \\
\end{array}
\right.
\end{equation}
%
\begin{equation}
\text{Value} = \max(r,g,b)
\end{equation}
%
\begin{equation}
\text{Lightness} = \frac{1}{2}(\max(r,g,b) + \min(r,g,b))
\end{equation}
\end{document}

數學包(在載入 時會自動載入mathtools)提供了許多其他用於格式化數學的環境,其中一些(例如gather)可能比 更好equation,具體取決於實際文件的結構。您可能還會發現閱讀以下內容很有用LaTeX 不那麼簡短的介紹

相關內容