[XeTeX] Need some input about \newcommand to create alias
Alan Munn
amunn at msu.edu
Sat Nov 28 05:38:02 CET 2009
At 11:23 PM -0500 11/27/09, Maxim Cournoyer wrote:
>Dear XeTeX fidels,
>
>In my first document written with XeTeX, I wanted to do an alias for
>the abbreviation CO_2 (carbon dioxyde), but had two difficulties.
>
>My first one was to try to use something like this :
>%\newcommand{\co2}{CO$_2$}
>The problem was that it seems we cannot use "numbers" in the command
>name, such as the '2' in \co2. Is there a way to circumvent this?
Not really. Numbers aren't allowed in macro names.
>
>Another weird issue I ran into was, after changing \co2 to
>something more wordy as \codeux, my actual replacement would delete
>all trailing space. Let me explain by an example :
>ex : The traffic in developed nations is the cause to an average of
>26% of the \codeux emissions.
>
>Results : The traffic in developed nations is the cause to an
>average of 26% of the CO_2emissions.
>
>Note the lack of a space character between the _2 subscript and
>emissions. Using CO$_2$ straight in my text solved the problem,
>surprisingly. Is there an explanation for this?
Yes, commands gobble the spaces after them.
> What should I do to prevent this from happening?
Two solutions:
\newcommand{codeux}{CO$_2${}}
or
\usepackage{xspace}
\newcommand{codeux}{CO$_2$\xspace}
Alan
P.S. Neither of these questions is actually related to xetex. You
might want to check the TeX FAQ, and get a good introduction to
LaTeX. Or post your questions to the comp.text.tex newsgroup.
http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes
--
Alan Munn amunn at msu.edu
Department of Linguistics
and Germanic, Slavic, Asian and African Languages Tel.
517-355-7491
Michigan State University, East Lansing MI 48824 USA Fax 517-432-2736
More information about the XeTeX
mailing list