[XeTeX] Need some input about \newcommand to create alias

Michiel Kamermans pomax at nihongoresources.com
Sat Nov 28 10:17:53 CET 2009


Just as an elaborating comment,
> 1) Using \codeux\, as proposed by Joe Pleso, does work.
>
> 2) Adding a pair of { } such as in \newcommand\{codeux}{CO$_2${ } does 
> work. Do not forget the space between the accolades.
Now you've misplacd the block, but this is because there was no 
explanation why {} has to go in your text, not in your macro: the reason 
the offered solutions work is because while tex is running through its 
input, it considers \ to start a special (series of) letter(s), and 
something has to finish that series. In "\codeux ", because tex's 
running through the text "codeux" in 'this is command label' mode, the 
space is not seen as an actual character, but as 'ah, this character 
takes me out of command label interpretation mode'. { does the same 
thing, and \ presents TeX with "the character following is either text, 
in which case stay in command label mode but a new command has started, 
or it will be a reserved single character and you must go out of command 
mode and print this character". That's why "\codeux{} " in your document 
body will work, as well as "\codeux\ " (note spaces in both). In the 
first, the {} tells TeX to go back to normal text parsing, and when it 
reaches the space it will just consider it proper text, the second tells 
tex that a reserved character may follow after the \ and the follows up 
with a space, which makes tex first go into normal text mode and then 
prints that character.

Although as Alan pointed out, this is more basic tex behaviour, so 
comp.text.tex and the tex faq would have been more suitable places to 
ask - that said, how are you going to know they're tex questions rather 
than xetex questions when your first exposure to tex is xetet, right? =)

you'll probably also want to spend a little time on 
http://en.wikibooks.org/wiki/LaTeX which explains most of the basics in 
a low number of pages, which is good, because it means you'll run 
through it quickly, and is bad because it also *only* explains the bare 
minimum. there's virtually no suggestions on how to tackle slightly more 
exotic things like your chemical formulas. Usually when you want 
something exotic done in (xe)(la)tex, someone will have done it before 
you, so it's quite likely "there's a package for it". http://ctan.org/ 
will be your friend in these cases. If you can't find it there, hit up 
comp.text.tex and quite likely someone will have already done what you 
wanted to do.

Good luck with your TeX adventures =)

- Mike "Pomax" Kamermans
nihongoresources.com


More information about the XeTeX mailing list