5

I have a webpage where I keep my PDF documents which are connected with other HTML pages and PDFs using hyperlinks.

All of my PDFs have command \hyperbaseurl{http://ziga-lausegger.netau.net/} at the top. This command should prepended base url to any other \href{} hyperlinks in documents. But I noticed that if:

  • \href{} command ends with .html like \href{foo.html} base url is prepended,
  • \href{} command ends with .pdf like \href{foo.pdf} base url is NOT prepended.

What would be the source of my problems, and how to fix this. Is this a BUG with hyperref package?

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
71GA
  • 3,573

1 Answers1

8

The hyperref packages auto-detects the difference between a link to a webpage and a link to a file: with the standard settings, you will see this as different border colours for the links. The \hyperbaseurl macro is about URLs, so applies to links which are detected as web pages but not to those detected as files (which are treated as local).

You can disable this difference in behaviour by setting extension to an empty value:

\documentclass{article}
\usepackage{hyperref,trace}
\hyperbaseurl{http://www.foo.bar/}
\hypersetup{extension = }
\begin{document}
\href{foo.html}{text} text \href{foo.pdf}{text}
\end{document}
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • Can you tell me only how can i make all hyperrefs in document colored, as it happens that in PDF viewer links are colored, but while opened in browser (Chrome, Firefox) they are not. I am familliar with color package and have some of my colors already defined. – 71GA Sep 27 '11 at 22:09
  • @71GA Please post a new question for this (it helps to keep the site organised), including a minimal example. I'm not quite sure what you want to colour and in what way. – Joseph Wright Sep 28 '11 at 05:42
  • 1
    @JosephWright this may have worked in 2011, but it doesn't look like it is still working at all with pdftex – Frank Mittelbach Sep 15 '19 at 21:21
  • @FrankMittelbach Er, it's not my fault! – Joseph Wright Sep 15 '19 at 21:25
  • @JosephWright no :-) and I was wrong, it just depends on what program you use to view the pdf afterwards ... it works with acrobat but not within, say TeXshop, sigh, so sorry for false alarm – Frank Mittelbach Sep 15 '19 at 21:29