2

I have following code in my tex file.

\\href{DEListComparison/inputFilesForGENE_E/}{link caption} \\

The link in the output pdf file turn out to be *DEListComparison/inputFilesForGENE_E/.pdf*. I got unnecessary .pdf in the link. Is this a bug or I did something stupid? How can it be resolved ?

2
  • Is DEListComparison/inputFilesForGENE_E/ a complete URL string? If so, try prefixing http:// to the string. If it's something else, please advise. (It would appear that hyperref thinks it's a shortcut to a file, with extension .pdf, located somewhere on your computer.)
    – Mico
    Jan 16, 2014 at 6:45
  • it is a relative url of a directory which is in same root directory as the output pdf file (generated by latex).
    – World
    Jan 16, 2014 at 6:52

1 Answer 1

3

There is an ambiguity in \href between a file link and an incomplete relative URL without protocol. Package hyperref chooses the former.

The following example provides macro \hrefurl that directly chooses the URL link type:

\documentclass{article}
\usepackage{hyperref}

\makeatletter
\providecommand*{\hrefurl}{\hyper@normalise\hrefurl@}
\providecommand*{\hrefurl@}[2]{\hyper@linkurl{#2}{#1}}
\makeatother

\begin{document}
\hrefurl{DEListComparison/inputFilesForGENE_E/}{link caption}
\end{document}

Now the PDF file contains an URI action for the link:

/A <<
  /Type /Action
  /S /URI
  /URI(DEListComparison/inputFilesForGENE_E/)
>>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.