LatexIt not rendering properly

I've been trying to figure out how latexit works, however, when I enter this simple piece of code, I get a long message of different errors as "LaTeX Error Bad environment delimiter", "You can't use \eqno' in math mode", "Missing \endgroup inserted." ... etc.

Here is the code:

$$\label{xx} x^2 - 5 x + 6 = 0$$


What am I doing wrong?

-
It's because LaTeXit has some code written before and after where you write. Under the space where you write, you have four buttons (align, text, ...). You are probably in align (which means that everything you write is between \begin{align} and \end{align}. If you select text it works. –  Manuel Dec 15 '12 at 13:51

Latexit will have a preamble and a postamble of its own which you can access through its preferences (Edit > Preferences)

The standard preamble contains a \begin{displaymath} and the postamble \end{displaymath}:

Hence if you add and in your code, you will get an error:

! LaTeX Error: \begin{document} ended by \end{displaymath}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.11 \end{displaymath}

! Extra \endgroup.

PS: Since the equations are exported as images from latexit and inserted elsewhere, I feel that it is not a good idea to use equation number (which is inserted by equation environment) and a label. It is better if they are included in the main document. However, for your own reasons if you want them, replace \begin{displaymath} with in the preamble and \end{displaymath}` with in the postamble of latexit.