# [XeTeX] A small tip

Ross Moore ross at ics.mq.edu.au
Thu Nov 17 22:37:20 CET 2005

Hi Will,

On 17/11/2005, at 6:16 PM, Will Robertson wrote:

> Hi Ross,
>
> Thanks for all your info. Some of it's really helpful. I've got a
> big rambling reply for you, I'm afraid.

> Somehow, I think you've been mistaken here...try:
>
> \documentclass{article}
> \usepackage[utf8]{inputenc}
> \DeclareUnicodeCharacter{2014}{2014}
> \DeclareUnicodeCharacter{8212}{8212}
> \begin{document}
> —
> \end{document}

This gives me  8212 .

If you get  2014  then maybe it's a package-version thing.
The relevant files are:

(/usr/local/teTeX/share/texmf/tex/latex/base/inputenc.sty
\ProvidesPackage{inputenc}
[2001/07/10 v0.99a Input encoding file ]

(/usr/local/teTeX/share/texmf/tex/latex/unicode/utf8.def))
\ProvidesFile{utf8.def}[2001/11/05 UCS: Input encoding UTF-8]%

(/usr/local/teTeX/share/texmf/tex/latex/unicode/ucs.sty
%% ucs.dtx  (with options: ucs.sty')
%%
%% Copyright 2001 Dominique Unruh <dominique at unruh.de>

These are quite old -- all from 2001 .
What versions do you have ?

> On a related note, I thought xunicode might provide an equivalent
> to inputenc's \DeclareUnicodeCharacter,
> but it seems that xunicode's \DeclareUTFcharacter is for a
> different purpose (at least, I couldn't get it to do what I expect).

Xunicode's \DeclareUTFcharacter  translates *into* Unicode for the
output.
Inputenc's \DeclareUnicodeCharacter  translates *out of* UTF8 into
a TeX macro.

> Have I missed something? I tried both of
>
>   \DeclareUTFcharacter{x8212}{\emdashwithspaces}
>   \DeclareUTFcharacter{x2014}{\emdashwithspaces}
>
> (I'll never remember when to do hex and when to do decimal...is the
> preceding "x" supposed to remind me? Why is it there, out of
> curiousity?)

Yes; it's just a reminder that this is hex, not decimal.
It plays no role at all in the processing.

>
>> Furthermore, for LaTeX, there are minor flaws with your coding.
>
> :)
> Thanks, I just knew something good would come out of my posting
> this snippet here. I hadn't given it much thought beyond "wow, this
> is neat".
>

>> And speaking of hyperlinking, look what happens with  hyperref.sty .
>> Generating bookmarks via the  .out  file, we see:
>>
>>   \BOOKMARK [1][]{section.1}{meow\204meow}{}
>>
>> This comes from a declaration in  pd1enc.def :
>>      \DeclareTextCommand{\textemdash}{PD1}{\204} % emdash
>> and may not be what you want here.
>
> Well, it wouldn't be so bad (are all the kerns and nobreaks, etc.,
> stripped out by hyperref?),

No, it doesn't work that way.

With \DeclareTextCommand  the robust macro \textemdash  can have
different
expansions according to the current encoding.
When processing the .out  file, this encoding is  PD1 ,
so you get the PD1-expansion, which is the octal sequence:  \204 .
This was defined in  pd1enc.def .

This doesn't conflict with other definitions of \textemdash
such as:
DeclareTextCommand{\textemdash}{OT1}{---} % emdash
since the ultimate expansion depends upon the encoding parameter,
not just the macro-name.

> but in the general case (using robust commands and using
> \pdfstringdefDisableCommands as you say to put the right things
> where they're going) this technique is very necessary.
>
>> ([hxetex.def]'s something that I'll try to provide sometime.)
>
> Let me know if you need help...I can't promise anything, of course :)
> Speaking of your packages, I wonder if it would be useful to
> provide a "lean" version of xunicode as a package option so as to
> only load the necessary portions of the unicode characters you define.

Not in the near future, sorry.
There are things missing from XeTeX support which have a higher
priority than reorganising what *is* available.

>
> I haven't done any tests, but XeTeX seems slower than I would have
> expected loading the xunicode package, which is why I bring it up.
> (fontspec has a similar problem, which I'll do sometime.)
>
>> Hope this helps,
>
> Whenever I think I'm getting the hang of this LaTeX thing, I can
> rely on you to educate me to the next step.

... and there's plenty of other work going on that I don't know

Cheers,

Ross

>
> Will
>
> _______________________________________________
> XeTeX mailing list
> postmaster at tug.org
> http://tug.org/mailman/listinfo/xetex
>

------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114
------------------------------------------------------------------------

`