[XeTeX] How to prevent Chinese chars to be treated as part of TeX command?
Michiel Kamermans
pomax at nihongoresources.com
Sat Oct 17 10:44:49 CEST 2009
mhbezine2009 wrote:
> I find a problem of XeTeX: I often encounter errors like "! Undefined
> control sequence l.6 \TeXä½ å¥½" when I typeset Chinese documents with
> XeTeX.
Be aware that in TeX, commands without arguments need to be
'terminated': you must use "\TeX ä½ å", so that the TeX engine can go
"aha, first process '\TeX', which is terminated by ' ' (which I will not
interpret as an actual character, but as terminator), and then the text
'ä½ å'" so your final text will look like "TeXä½ å" with the appropriate
macro replacement. Because XeTeX is unicode aware, using "\TeXä½ å"
means it will look for the command "TeXä½ å" somewhere in your documents
definitions list, and then can't find it, so you get your error.
Even though there are no spaces in Chinese (and various other
languages), you will still need to use them in your document to
terminate commands without arguments. Regular commands with arguments
should be fine, since their control sequence is terminated by the
accolades that surround arguments, but commands without arguments are
always tricky this way.
It's also why an English text "I am writing \TeX code, look at me" will
come out as "I am writing TeXcode, look at me". There, too, the first
non-command character that follows a command without arguments is
considered a terminator, not a character to place on the page (which is
why for languages with spaces, the advice is usually to add an extra
slash behind the command, so that TeX sees the slash as terminator,
instead of the character that follows)
Because argument count is not enforced by TeX (you'll just get an error
if you use the wrong number of them), you can also use an empty argument
with commands that don't take arguments: "\TeX{}ä½ å" will also do what
you want it to do, and might be easier if you're in an input mode that
makes typing spaces harder than typing accolades.
- Mike "Pomax" Kamermans
nihongoresources.com
More information about the XeTeX
mailing list