# [XeTeX] A small tip

Will Robertson will at guerilla.net.au
Thu Nov 17 08:16:36 CET 2005

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.

On 17/11/2005, at 4pm, Ross Moore wrote:
> On 17/11/2005, at 12:04 AM, Will Robertson wrote:
>
> Yes; it is a useful aspect of any TeX-based system that this
> kind of thing can be done.
>
> But there is a mistake here --- it should be:
>
>    \DeclareUnicodeCharacter{8212}{\dash}
>
> using the decimal form of  2014 (Hex).

Somehow, I think you've been mistaken here...try:

\documentclass{article}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{2014}{2014}
\DeclareUnicodeCharacter{8212}{8212}
\begin{document}
—
\end{document}

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). 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?)

> 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".

> Secondly, consider what happens when you use the emdash
> ...
> This may seem trivial, since the displayed result appears the same.
> It would not be trivial, however, when these auxiliary files are
> reused with other applications; e.g., to construct indexes or
> hyperlinked tables of contents, of several such documents.

You are totally correct, of course. In truth, I should have spent
particular advantage to robust commands -- I've really benefited from
your explanation; although I knew all the individual bits and pieces,

> 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?), 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.

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,