Is it possible to hyperlink a drawn line to a specific page in the document? I use following command to draw a line: \line(1,0){20} Many thanks! Here is MWE:

\documentclass[a4paper]{article}
\usepackage{hyperref}
\usepackage{polyglossia}

\usepackage{geometry}
\geometry{hmargin={0.2in,0.2in},vmargin={0in,0in},
paperwidth=3.56in, paperheight=5.95in}

\hypersetup{
citecolor=black,
filecolor=black,
urlcolor=black
}
\pagenumbering{gobble}

\begin{document}
\phantomsection \label{PP1}
First page \newpage

\phantomsection \label{PP2}
Second page \newpage

\centering
\line(1,0){20}

\end{document}

-
Toc might be little complicated. Suppose I labeled a specific page as PP1, now I need a drawn line linked to this page. How do I do it? – Nina May 21 '12 at 17:21
I added MWE. Please ignore TOC. How do you link a drawn line to a page labeled as PP1? – Nina May 21 '12 at 17:38
@ Marco, I understand the work around. However, that doesn't solve my problem, because now the hyperlinked area becomes the size of a font, and placed under a line. I need that line hyperlinked only. – Nina May 21 '12 at 18:12
I found the problem, but no solution ;-). It's XeLaTeX related. With PDFLaTeX and \hyperlink{PP1}{\hbox{\line(1,0){50}}} it works well. – Marco Daniel May 21 '12 at 18:23
– Marco Daniel May 21 '12 at 18:24

Vairis has shown in his answer, that XeTeX has some problems, if the link does not contain character glyphs. LaTeX's picture environment uses glyphs of a special font for \line, \vector and \circle. This is also the reason for the limitations (only some angles, the sizes are restricted, …). Horizontal and vertical lines are the exception, because they are drawn by rules.

• Detected by XeTeX: character glyphs.

• Not detected by XeTeX: rules, images, boxes without glyphs, ...

As solution I have now implemented \XeTeXLinkBox in hyperref 2012/08/18 v6.83b, from README:

When XeTeX generates a link annotation, it does not look at the boxes (as the other drivers), but only at the character glyphs. If there are no glyphs (images, rules, …), then it does not generate a link annotation. Macro \XeTeXLinkBox puts its argument in a box and adds spaces at the lower left and upper right corners. An additional margin can be specified by setting it to the dimen register \XeTeXLinkMargin. The default is 2pt.

Example:

% xelatex
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{Hello World}
\newpage
\label{sec:hello}
\hyperref[sec:hello]{%
}
\end{document}


Modified example from Vairis:

\documentclass[a4paper]{article}

\usepackage{hyperref}

\usepackage{pifont}

\makeatletter
\@ifpackagelater{hyperref}{2012/08/18}{%
}{%
% Space is taken from Zapf Dingbats with zero height and depth
}
\begingroup
\leavevmode
\sbox0{#1}%
\begingroup
\dimen0=\dp0 %
\setbox2=\llap{%
\hss
}%
}%
\dp2=\dp0 %
\ht2=\ht0 %
\copy2 %
\endgroup
\copy0 %
\dimen0=\ht0 %
\setbox2=\rlap{%
\hss
}%
}%
\dp2=\dp0 %
\ht2=\ht0 %
\copy2 %
\endgroup
}%
}
\makeatother

\begin{document}
\phantomsection \label{PP1}
First page \newpage

\phantomsection \label{PP2}
Second page \newpage

\centering

\hyperref[PP1]{\line(1,1){10}}
\hyperref[PP1]{\vector(1,0){10}}
\hyperref[PP2]{%
\begin{picture}(10,10)%
\put(5,10){\line(0,-1){10}}%
\end{picture}%
}%
}
\hyperref[PP2]{%
\begin{picture}(10,10)%
\end{picture}%
}
\end{document}


Result:

The reason for using the space from Zapf Dingbats are:

• There is a space glyph.
• Package pifont is already loaded, therefore the fonts are very likely installed.
• The height and depth of the space glyph is zero.
• The width is minimized by loading the font at the size of 1sp.
-

\documentclass[a4paper]{article}
\usepackage{polyglossia}

\usepackage{geometry}
\geometry{hmargin={0.2in,0.2in},vmargin={0in,0in},
paperwidth=3.56in, paperheight=5.95in}
\usepackage{url}
\usepackage{hyperref}
\hypersetup{
citecolor=black,
filecolor=black,
urlcolor=black
}
\pagenumbering{gobble}

\begin{document}
\phantomsection \label{PP1}

First page \newpage

\phantomsection \label{PP2}
Second page \newpage

\centering
\hyperref[PP1]{\line(1,1){10}} %works

\hyperref[PP1]{\vector(1,0){10}} %works

\hyperref[PP1]{\dotfill} %works

\hyperref[PP2]{\begin{picture}(10,10)\put(0,-1){\line(0,-1){10}} \end{picture}} %not working