# Re: LyX 2.0: problems using XeTeX and thesis template

On 2010-12-08, Jürgen Spitzmüller wrote:
> Jürgen Spitzmüller wrote:

>> Justin Wood wrote:
>>> 1. conflict with AMS package
>>> I've found that simply activating XeTeX under *Document Settings –
>>> Fonts*will cause parsing errors on viewing if the document also has
>>> *Math Options – Use AMS math package* checked; eg, LaTeX Error: Command
>>> \Finv' already defined, etc. I think this is a known conflict between
>>> XeTeX and the AMS package, is that right? By changing the setting to *Use
>>> AMS math package automatically* though, these particular errors go away.
>>> Note that this occurs in the generic default new document (*article*
>>> class) as well as the *KOMA-script book *class that the thesis uses.

>> Yes, I've seen this too. Not sure what to do. We could disable "AMS
>> always" for XeTeX, if necessary, but I guess we need to do some more
>> research yet.

Please never disable "AMS always" but not "AMS automatically": this would
lead to errors as soon as an AMS-requiring construct is put into the
document.

> This should be fixed as well in the next release. The trick is to load all
> AMS packages before fontspec (which itself loads xunicode, which has to be
> loaded after the AMS packages). See
> http://www.macfreek.nl/mindmaster/LaTeX_package_conflicts#Amssymb_with_Xunicode

I am glad you found the core of the problem.
(BTW: the current version of fontspec does no longer load xunicode, but
we should care for users with older versions.)

Testing here with a pre-beta-2 SVN version,

LyX 2.0.0svn (not released yet)
Built on Nov 26 2010, 14:31:19

I get

%% LyX 2.0.0svn created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[british]{article}
\usepackage{fontspec}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{polyglossia}
\setdefaultlanguage[variant=british]{english}
\begin{document}
Hallo $\Rrightarrow$.
\end{document}

which compiles fine.

However, I also found that even if I do not check any of the AMS math
options, LyX 2 behaves as if the "Load AMS math automatically" option
were set:

a) the "AMS symbols" toolbox is enabled.
b) inserting a symbol from it inserts \usepackage{amssymb} in the preamble.
c) even writing \Rrightarrow in a math box (converts this to the symbol and)
inserts \usepackage{amssymb} in the preamble.

Because of c), a work-around with disabling AMS math in the checkbox and
loading in the LaTeX preamble will fail.

Günter

Günter

`