[XeTeX] xyling.sty compatibility with Xelatex
Ross Moore
ross at ics.mq.edu.au
Fri Jan 9 22:05:50 CET 2009
Hello Alan, Pavel, and others
On 10/01/2009, at 12:57 AM, Alan Munn wrote:
> At 10:23 AM +0100 1/9/09, Pavel Stranak wrote:
>> Hello,
>>
>> I am just typesetting a paper that draws trees using macros \B and \K
>> from xyling.sty.
>> It works fine in latex, but in xelatex I get errors while processing
>> xyling saying that the macros \B and \T are already defined. Then the
>> edges in a tree are not drawn (thats what \B and \K are for).
>>
>> Renaming the macros in the xyling.sty and in the paper helps, but I
>> wonder whether there is a solution that would make xyling really
>> compatible with xelatex.
>
> This IS the solution, unfortunately. When two packages use the same
> command names, one of them has to change them. xunicode.sty defines
> both \T and \B; either it changes or xyling changes. Should it
> change its names or should xyling? Who decides?
>
> Perhaps since the commands in xunicode.sty are not intended as user
> commands, whereas those in xyling are, they should be changed in
> xunicode.
Well, I beg to differ in this assessment.
The use of single character macro names within specialised
packages is well-recognised to be poor programming practice.
There is a large possibility of incompatibility with other
packages where short-name macros are used for more fundamental
purposes (such as accented letters in non-english languages,
or some other special character).
For example, the default TeX uses:
\a \c \d \i \j \k \l \o \r \t \u \v
\A \H \L \O \P \S
(and maybe some others also).
And all of: \@ \# \$ \% \^ \& \' \" \` etc.
With LaTeX, the standard support for other latin-based
(or cyrillic) languages, and phonetics, add a few more:
\b \f \g \h \m
\B \C \G \I \M \T \U
(and maybe some others also).
I've not checked all the non-latin-based encodings, so there
may be others that are used in some of those.
Oh, and there is \x from xspace.sty
and maybe some other generally useful cases.
Thus the obvious implication is that if your package uses
single-letter macro names for a vital purpose, conflicting
with usage required for a particular language or phonetics,
then it cannot be used in conjunction with "whole languages".
That surely cannot be the intention of the package-writer.
Lesson: don't use single-letter macro-names in packages!
Now xunicode.sty is rather special, as it is designed to
be a replacement for the myriad of encoding files for different
languages. It uses the single-letter macros for exactly the same
purpose --- namely special characters, accents and diacritics.
Thus there is no incompatibility introduced this way.
> I don't know if there's a set protocol for this sort of
> situation.
I think my comments above state this (unwritten) protocol.
But having said all that, there is a simple way to overcome
incompatibilities between packages, when you are
*absolutely certain* that your document is only going to
use a macro in just one way. For the case at hand:
\usepackage{xunicode}
\let\B\relax
\let\T\relax
\usepackage{xyling}
Of course this will mean that you cannot put words requiring
\B and \T within the content of the linguistic-tree nodes.
If this is in fact needed, then a better approach would be:
\usepackage{xunicode}
\let\realB\B
\let\B\relax
\let\realT\T
\let\T\relax
\usepackage{xyling}
\let\lingB\B
\let\lingT\T
Now you can locally reset \B to the original one:
{{\let\B\realB
some words needing ...\B.... }}
within linguistic tree nodes.
Similarly for \T .
Yes, this requires great care; but at least it is possible.
It just a pity that xyling was written using some
single-letter macro names, giving preference to expediency
of typing rather than compatibility with all languages.
>
> Alan
>
> --
> 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
Hope this helps,
Ross
------------------------------------------------------------------------
Ross Moore ross at maths.mq.edu.au
Mathematics Department office: E7A-419
Macquarie University tel: +61 (0)2 9850 8955
Sydney, Australia 2109 fax: +61 (0)2 9850 8114
------------------------------------------------------------------------
More information about the XeTeX
mailing list