[Tex/LaTex] Unicode “undefined control sequence” in XeLaTeX


I have got a TeXLive 2011 on an Apple Time Machine and TeXShop on my local MacBook.
When I try to typeset the XeLaTeX template from TeXShop, I get “undefined control sequence” for some of the Unicode text.

The relevant section of the template goes as follows:

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode


\setromanfont[Mapping=tex-text]{Hoefler Text}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Gill Sans}
\setmonofont[Scale=MatchLowercase]{Andale Mono}


\newfontfamily{\A}{Geeza Pro}
\newfontfamily{\H}[Scale=0.9]{Lucida Grande}

Here are some multilingual Unicode fonts: this is Arabic text: {\A السلام عليكم},
this is Hebrew: {\H שלום}, 
and here's some Japanese: {\J 今日は}.


When I typeset this, I get:

./Untitled.tex:44: Undefined control sequence.
l.44 ...s: this is Arabic text: {\A \UTF

Strangely, this occurs only for the Arabic and Hebrew texts, however, if I comment these out and leave only the Japanese section, the document is typeset without any errors and correct output.

At first, I thought that something was not passed correctly via the shell, but both bash and tcsh (used by TeXShop) return upon a locale:


I even tried adding setenv LC_CTYPE en_US.UTF-8 (cf. this) to the XeLaTeX engine for TeXShop but that did not help, either.

This is the Log I get with the posted example.

I hope that you have any ideas concerning this problem.
Thank you in advance.

Best Answer

I would say your editor has exchanged the unicode chars by this \UTF-commands when saving the file. A search in the TeXshop forum came up with this advice: "Please UNCHECK TeXShop->Preferences->Misc->pTeX support-> utf export".