# XeTeX hebrew problem with LyX

I am using LyX and trying to write in Hebrew using XeTeX. I get the following error messages:

undefined control sequence
Package polyglossia error


Is this a package I should get manually? I would mention that the problem is only with Hebrew fonts. If I am writing an English document it compiles fine and there is no problem.

Edit

Ok, I have written a MWE and exported it to a TeX file, I got the following:

%% LyX 2.0.0 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english,hebrew]{article}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{David}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{theorem}
\theorembodyfont{\upshape}
\newtheorem{theorem}{\R{משפט}}[section]
\AtBeginDocument{\make@lr\thetheorem}

\makeatother

\usepackage{xunicode}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\begin{document}
שלום עולם. זוהי דוגמה למסמך עברי\L{
$E=mc^{2}$
}זו הנוסחה המפורסמת של אינשטיין
\end{document}


The error messages are:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Fatal fontspec error: "cannot-use-pdftex"
The fontspec package requires either XeTeX or LuaTeX to function
You must change your typesetting engine to, e.g., "xelatex" or "lualatex"
instead of plain "latex" or "pdflatex"
See the fontspec documentation for further information
For immediate help type H <return>
...............................................  :    }

-
Welcome to TeX.sx! The message snippets you've posted do not look like the full error messages you will be getting: could you edit the question to include the full text? Also, a minimal working example (MWE) would be really useful. –  Joseph Wright Dec 26 '11 at 13:01
Since this is LyX and not a TeX editor, these are the errors I'm getting. But if there is a way to see more detailed report I'd be happy to know –  Simcha Dec 26 '11 at 13:10
The errors will be in the .log file that TeX generates. They will include the text you've posted, but should be longer, for example naming the undefined control sequence. –  Joseph Wright Dec 26 '11 at 13:14
Ok. I have written an example for a TeX file. Obviously it seems that XeTeX is not defined, but I am working usually with LyX, how can I make it define this properly? –  Simcha Dec 26 '11 at 13:27
If you have a full TeXLive distribution, xelatex should be installed already, and you should be able to choose Document→Settings...→Fonts→Use non-TeX fonts (via XeTeX/LuaTeX) in LyX to have your document compile with xelatex. If that doesn't work, you need to tell us more about how your TeX distribution was installed. –  Alan Munn Dec 26 '11 at 16:52
show 1 more comment

If you have a full TeXLive distribution, xelatex should be installed already, and you should be able to choose Document→Settings...→Fonts→Use non-TeX fonts (via XeTeX/LuaTeX) in LyX to have your document compile with xelatex. If that doesn't work, you need to tell us more about how your TeX distribution was installed.

-