I discovered that latex don't like a formula with the "\notin" symbol when it appear in a section heading. But "\protect\notin" works fine. So I type "\protect" in the math editor, and the word disappear when finished. Seems like it is recognised as something that should be invisible? Other commands tend to remain in red (or transform into proper math symbols)
I can then view dvi or print. Saving the document saves the "\protect" too. Reading in the document don't work though. The \protect is lost, and have to be added everytime I load and want to print the document. There is a mini testcase below, try loading & saving it and see the protect disappear. The same happens with lyx-1.3.1 Helge Hafting #LyX 1.3 created this file. For more info see http://www.lyx.org/ \lyxformat 221 \textclass article \language norsk \inputencoding auto \fontscheme default \graphics default \float_placement htb \paperfontsize default \spacing single \papersize Default \paperpackage a4 \use_geometry 1 \use_amsmath 0 \use_natbib 0 \use_numerical_citations 0 \paperorientation portrait \paperwidth 17cm \paperheight 24cm \secnumdepth 3 \tocdepth 3 \paragraph_separation skip \defskip medskip \quotes_language french \quotes_times 2 \papercolumns 1 \papersides 1 \paperpagestyle default \layout Section \begin_inset Formula $A\protect\notin B$ \end_inset \the_end