[XeTeX] How to enable hyperlinks with hyperref

Peter Dyballa Peter_Dyballa at Web.DE
Sat Nov 21 23:58:23 CET 2009


Am 21.11.2009 um 16:53 schrieb Maxim Cournoyer:

> \special{pdf: docinfo <<
> 	/Author		(Autor name)
> 	/Title		(Title name)
> 	/Keywords	(keyword1, keyword2)
> 	/Subject	(Subject name)
>>> }

This is documented since decades in the dvipdfm manual (texdoc  
dvipdfm)... Of course this works, since xdvipdfmx descends from dvipdfm.

>
> \usepackage[xetex]{hyperref}   % or
> \usepackage[dvipdfm]{hyperref}

None of these specialised forms is needed nowadays, hyperref  
determines automatically which TeX variant in which mode is running.

>
> I'm using babelbib

I haven't used it yet...

> Here's my preamble :
>
> \documentclass[12pt,letterpaper,draft]{article}

If you pass the letterpaper option to geometry, then you can save the  
\special line.
>
>
> % Packages
> \usepackage[canadien,english]{babel}
> \usepackage[top=2.75cm, bottom=3cm, left=2.5cm, right=2.5cm]{geometry}
> \usepackage{fancyhdr}
> \usepackage{ifpdf}

Ifxetex is a nice package, too!

> \usepackage[fixlanguage]{babelbib}
> \usepackage[dvipdfm]{hyperref}
>
> % Layout et options
> \special{papersize=8.5in,11in}
> \setlength{\headheight}{15pt}

Isn't this line better put to the geometry options? Or is it specific  
for fancyhdr?

> \renewcommand{\baselinestretch}{1.5}
> \hypersetup{urlcolor=cyan}
>
> % XeTeX specific
> \usepackage{xunicode}

If xunicode, or xltxtra, find that fontspec wasn't loaded before, it  
gets load.

> \usepackage{fontspec}
> \usepackage{xltxtra}


And you can swear every oath that the following minimal code fails on  
your PC?

\documentclass[12pt]{article}
\usepackage{ifpdf,ifxetex}
\usepackage[svgnames]{xcolor}
\usepackage[letterpaper]{geometry}
\ifxetex
   \immediate\write16{==High ¡I'm from XeTeX!==}
   \usepackage[no-math]{fontspec}
%  \usepackage{xltxtra,xunicode}
   \usepackage[raiselinks=true]{hyperref}
   \defaultfontfeatures{Mapping=tex-text}
%  \setromanfont{Lucida Bright}		% The Lucida fonts are in Java...
%  \setsansfont{Lucida Sans}
%  \setmonofont{Lucida Sans Typewriter}
%  \newfontface\slanted[RawFeature={slant=0.194},Colour=884444] 
{Lucida Bright}
%  \DeclareRobustCommand{\textsl}[1]{{\slanted #1}}
\else
   \immediate\write16{==Notice: No XeTeX==}
   \usepackage[utf8]{inputenc}
   \ifpdf
     \immediate\write16{==\jobname: Bonjour, PDF!==}
     \usepackage{cmap}
     \usepackage[activate={true,nocompatibility}]{microtype}
     \usepackage[bookmarks=true,backref=section,debug=true]{hyperref}
     \makeatletter
     \@ifundefined{pdffilemoddate}{%
        \PackageError{sourcetime}{%
          pdfTeX >= 1.30.0 required%
        }%
        \let\pdffilemoddate\@gobble
     }{}%
     \newcommand*{\SourceFile}[1]{%
       \edef\@SourceFileDate{\pdffilemoddate{#1}}%
       % empty in case of errors, but don't harm in next comparison
       \ifnum\pdfstrcmp{\@SourceFileDate}{\@CurrentSourceFileDate}>0 %
         \let\@CurrentSourceFileDate\@SourceFileDate
         \expandafter\@ParseDate\@SourceFileDate\@nil
         \hypersetup{%
           pdfcreationdate={\@SourceFileDate},%
           pdfmoddate={\@SourceFileDate}%
         }%
         \PackageInfo{sourcetime}{%
           Using file `#1'%
         }%
       \fi
     }
     \newcommand*{\@CurrentSourceFileDate}{}
     \expandafter\def\expandafter\@ParseDate\detokenize{D:} 
#1#2#3#4#5#6#7#8{%
       \year=#1#2#3#4\relax
       \month=#5#6\relax
       \day=#7#8\relax
       \@ParseTime
     }
     \def\@ParseTime #1#2#3#4#5\@nil{%
       \time=\numexpr #1#2 * 60 + #3#4\relax
     }
     \makeatother
     \SourceFile{\jobname.tex}
   \else
     \immediate\write16{==Bad luck – \jobname: DVI==}
     \usepackage[protrusion=true,expansion=false]{microtype}
   \fi
   \usepackage[T1]{fontenc}
   \usepackage[full]{textcomp}
%  \usepackage{lucida}
   \renewcommand{\sfdefault}{pag}
   \renewcommand{\rmdefault}{ppl}
   \renewcommand{\ttdefault}{pcr}
   \makeatletter
   \newcommand*\TeX at logo@spacing[6]{%
     \def\xxt at kern@Te{#1}%
     \def\xxt at kern@eX{#2}%
     \def\xxt at lower@e{#3}%
     \def\xxt at kern@La{#4}%
     \def\xxt at kern@aT{#5}%
     \def\xxt at kern@eL{#6}%
   }
   \DeclareRobustCommand\XeTeX{%
     \leavevmode
     \smash{%
       X\lower\xxt at lower@e
       \hbox{\kern\xxt at kern@eX
         \setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0%
         \reflectbox{E}%
      }\kern\xxt at kern@Te\TeX}}%
   \DeclareRobustCommand\XeLaTeX{%
     \leavevmode
     \smash{%
       X\lower\xxt at lower@e
       \hbox{\kern\xxt at kern@eX
         \setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0\relax
         \reflectbox{E}%
     }\kern\xxt at kern@eL\LaTeX}}
   \TeX at logo@spacing{-0.15em}{-0.125em}{0.5ex}{-0.36em}{-0.12em} 
{-0.13em}
   \makeatother
\fi
\def\TheTitle{The Common Planet}
\hypersetup{%
       unicode,
      pdftitle=\TheTitle,
     pdfauthor=directly from the author,
    pdfsubject=The Refferrentz,
   pdfkeywords={A one too three!},
      urlcolor=DarkBlue,
     linkcolor=NavyBlue,
     verbose,
     colorlinks
}
\begin{document}
\title{\textcolor{DarkGoldenrod}{\TheTitle}}
\author{Clark Kent\\
\href{mailto:Clark_Kent at FlatEarth.NET}{\small\itshape Clark 
\textunderscore Kent at FlatEarth.NET}}
\date{\today}
\maketitle
\tableofcontents
\newpage

\section{First Page}
The text body of the first page.
\newpage
\section{On Second Page}
The text continues on the second page.
\newpage
\section{The Third Page}
The text \textsl{further} continues on the third page.

\end{document}

--
Greetings

   Pete

A common mistake that people make when trying to design something  
completely foolproof is to underestimate the ingenuity of complete  
fools.



More information about the XeTeX mailing list