Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I wonder if there is any way to stop hyperref's \href{url}{text} command from opening a new window of a browser each time. What I mean is this. Suppose you use a web address for url, say, www.mywebsite.com/page.html. On a compiled PDF, you click on it, and it opens the website. Click on it again, or on another \href with the same address: it opens the same page with another window.

I would rather just come back to the page opened earlier.

share|improve this question
3  
I am (100-epsilon)% sure this is not possible, since the same "problem" exists even in browsers and is therefore not limited to hyperref or LaTeX. It (the browser) doesn't consider that you have another window open on the same page that is contained in the link. Moreover, even if this were possible, it may be user-dependent; some people may want to have another window open up while others do not. –  Werner Nov 8 '11 at 15:09
3  
This doesn't depend on how the PDF is created. It depends on how you configured your system. If you prefer to open a new tab, instead of a new window, then configure your system to open a new tab. –  Marco Nov 8 '11 at 15:12
    
hyperref does not open anything. It writes only links to the pdf. Depending on the pdf reader, the reader runs external programs to open external links or shows the file itself or asks the OS to open it. Best chance is if the external program knows, that it is already running an contacts the other instance to show or open a new file. That's more or less a problem of the used software but not a hyperref problem. –  Schweinebacke Nov 8 '11 at 15:18
    
This is definitely a matter of browser settings and not of how the hyperlinks inside a pdf document are created. Each browser (firefox, chrome, safari, opera, IE, etc.) has its own set of instructions on how to proceed when a URL is being requested -- your browser(s) must be set to open a new window when a new URL is requested. –  Mico Nov 8 '11 at 15:23
1  
To potential question closers: I don't think this question is off topic, even though the answer turns out to be "you can't do it". We should let the comments turn into answers as @egreg suggests. –  Alan Munn Nov 8 '11 at 16:34
show 4 more comments

1 Answer

hyperref does not open links (internal or external) and does not produce any code to open links. It only adds the information to the document, that an object, e.g., a text or image, is a link. If the program, that shows the document, is able to handle links, it does at least the analysis, if the link is an internal link, that means it is from one place of the document to another place at the same document, or if it is an external link, that means a link to another document or a place at another document.

If a link is an internal link, the program simply jumps to the destination, if you activate the link.

If the link is an external link, the program has three alternatives:

  1. It is able to handle the type of external document itself.
  2. It knows another program, that is able to handle the type of external document.
  3. It may ask the OS to handle the external document.

The third alternative is almost the same like the second (OS is a kind of program). So what about the first and the second alternative?

With the first alternative, it simply can open the external document and jump to the link destination at this document. In this case the program may either be able to detect, if the external document is already open, and simply bring it to the foreground and jump to the destination. But some programs may even not be able to do this and will always open a new instance of the external document. Some programs may be able to allow the user to configure how they should handle links to external but already opened documents. It's your turn to find out, how the programs you are using handle this.

With the second alternative, it my be easy for a program to find out, if there's already an instance of the program for the external document running. But it is not easy for the program to find out, how that other program may be asked, if the external document is already open. It is not easy to instruct the other program to bring that open document into foreground. It is not easy to instruct the other program to jump to a link at the already opened document. It is easy to call a new instance with one argument: the external link.

A simple example of the problem is: For simple cooperation with the PDF viewer TeXnicCenter users have not only to reconfigure their editor if they switch, e.g., from Acrobat Reader to BlinkyBill, but even if they switch from Acrobat Reader 8 to Acrobat Reader X.

A good solution would be, if every document viewer program could be configured to search for already running instances of itself and instruct this instance to open the link. But not every program can be configured to do this.

Conclusion: The idea is nice, but it needs cooperation of several different programs and is nothing hyperref could handle or something that may be handled from document source code. It's more or less a problem of which programs you are using and what features these programs support.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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