[XeTeX] Hyperref query

Ross Moore ross at ics.mq.edu.au
Wed May 12 00:15:38 CEST 2010


Hi Vafa,

On 11/05/2010, at 10:11 PM, Vafa Khalighi wrote:

> Even more condensed:
>
> \documentclass{article}
> \makeatletter
> \def\vafa#1{\ifcase#1\or ا\or ب\or ح\or ح\or خ\fi}
> \let\@Alph\vafa
> \makeatother
> \usepackage{hyperref}
> \begin{document}
> \tableofcontents
> \section{Test}
> \newpage
> \appendix
> \section{Another Test}
> \end{document}
>
> It seems that the actual problem is because of the presence of  
> Persian characters.

Isn't the problem more fundamental than this?

Strings cannot be put directly into a PDF document in UTF8 encoding.
It needs to be either Latin-1 + octal codes, or UTF16 as Hexadecimal.

So when writing destination names, and into the .out file for
bookmarks, you need to adjust your macros to produce strings
in one of these formats.


But in your example, it is the destination name that is
causing the problem, when constructing a value for
    \theHsection
via  \Alph {section} .

At the relevant place in the coding there is no reason at all
to be using unicode characters, as this number is only being
used internally.
So you should be adjusting a macro somewhere to *not* patch in
the Persian form of \@Alph but keep using the usual Latin form.

In particular, the following is wrong:

    \let\@latinalph\@alph%
    \let\@latinAlph\@Alph%
    \let\@alph\abjad%
    \let\@Alph\abjad%

This rebinding of \@Alph and \@alph  should not be done *globally*.
It should be a *local* rebinding, made only when creating numbers
for visual display, but not when the numbers are being used
to create destination and label names.

Alternatively, it may be easier to make the global change,
but *also* locate all the places where you need to switch back,
using:

      \let\@alph\@latinalph
      \let\@Alph\\@latinAlph




Hyperref recognises commands \0 \1 \2 \3 \8 \9 which
allows octal codes \000 up to \377  (giving 0--255)
and \8** and \9***  for octal couplets to obtain 16-bit codes.

So if you were to be putting Persian numbers to be displayed within
PDF bookmarks, then you would need macros such as the following:


\def\abj at oct@i#1{%
  \ifcase#1\or\814\047\814\104\814\101\or\814\050\or\814\054\or\814\057%
           \or\814\007\840\015\or\814\110\or\814\062\or\814\055\or\814 
\067\fi%
   \ifnum#1=\z@\abjad at zero\fi}
\def\abj at oct@ii#1{%
   \ifcase#1\or\814\315\or\814\241\or\814\104\or\814\105\or\814\106%
            \or\814\063\or\814\071\or\814\101\or\814\065\fi
   \ifnum#1=\z@\fi\abj at oct@i}
\def\abj at oct@iii#1{%
   \ifcase#1\or\814\102\or\814\061\or\814\064\or\814\052\or\814\053%
             \or\814\056\or\814\060\or\814\066\or\814\070\fi
   \ifnum#1=\z@\fi\abj at oct@ii}
\def\abj at oct@iv#1{%
   \ifcase#1\or\814\072\fi
   \ifnum#1=\z@\fi\abj at oct@iii}

\pdfstringdefDisableCommands{%
   \let\abj at num@i\abj at oct@i
   \let\abj at num@ii\abj at oct@ii
   \let\abj at num@iii\abj at oct@iii
   \let\abj at num@iv\abj at oct@iv
}

I think I've got the octets correct.
If not, then Heiko might point out any errors.




>
> -- 
> Best wishes,
> Vafa Khalighi


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