Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I realise this sounds like a daft question, but I have a lot of missing symbols coming up in my work, but they are there!

One such example is

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

As you can see I do indeed have all of the $. Also I have the \begin{center} and \end{center}

Another error, is that it says \begin{document} ended by \end{equation}

Here is the header I am using

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

I do have an \end{document}

Thanks for your help!

share|improve this question
2  
You can't change in math-mode (started by \begin{equation} to inline-math-mode ($) as far as I know. Also i don't think you can use center in an equation, but I didn't test it. –  Juri Robl Aug 30 '12 at 13:14
    
The problem has nothing to do with TeXstudio. –  Guido Aug 30 '12 at 13:40
add comment

1 Answer

up vote 3 down vote accepted

There are four mistakes in your example.

  • You don't need \begin/end{center} for displayed equations; they are centred by default.

  • You don't need dollar signs inside an equation environment; you are in maths mode already.

  • You can't have \left without a matching \right, though you can use \right. if you don't want the right delimiter.

  • You can't have empty lines inside an equation environment.

A corrected version (with unnecessary material removed) is as follows. If you don't want the equations to be numbered, you can use equation* in place of equation, and you can abbreviate\begin{equation*} and \end{equation*} to \[ and \]. Finally, note that there are predefined commands \max and \min which produce better results than just typing 'max' and '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}

The amsmath package (which is automatically loaded when you load mathtools) provides lots of other environments for formatting mathematics, some of which (e.g. gather) may be better than equation, depending on the structure of your actual document. You might also find it useful to read the Not so Short Introduction to LaTeX.

share|improve this answer
    
\[ \] is unnumbered, equation is numbered. It could appear that the OP wished a single number for everything, in which case one could replace center with gathered. Last suggestion, perhaps use \max and \min? –  Torbjørn T. Aug 30 '12 at 13:35
    
@Guido --- Indeed. I was thinking of equation*. –  Ian Thompson Aug 30 '12 at 13:35
1  
Sorry for nagging, but one more thing: I think one generally should not have several equations in sequence, but rather use a gather. –  Torbjørn T. Aug 30 '12 at 13:41
    
@TorbjørnT. --- I wasn't sure exactly what result the OP wanted, so I just fixed the errors. However, I have added a link to the amsmath documentation. –  Ian Thompson Aug 30 '12 at 13:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.