Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaTeX multiple URLs within the same href command

I am trying to embed two URLs in the same clickable text; so after a person clicks on the text, he/she is directed to two webpages (I don't really care if this happens in two windows or two tabs). A command like:

\href{https://projecteuler.net/about;https://en.wikipedia.org/wiki/Project_Euler}{Project Euler}

Is this possible?

like image 479
philomathic_life Avatar asked Jan 17 '26 22:01

philomathic_life


1 Answers

That is an interesting quest. It is a good question with HTML alone, not to mention Latex.

Doing this with Javascript for the browser is standard fare. See this post for the simplest case by JS onclick method, or this post, or this post (for the same or other methods).

<p><a href="#" onclick="
        window.open('http://google.com');
        window.open('http://yahoo.com');
   ">Click to open Google and Yahoo</a></p>

Javascript is supported by the hyperref package, according to the long list of accepted methods in the hyperref docs. So it may be possible to do even exactly as shown, with onclick="..." in \href{} (untested). For a demonstration of far more involved JS see this post (with insdljs package). For a possible non-JS approach using 'nested actions' via hyperref's option nextactionraw see this post.

In short, it should be quite possible to use Javascript with hyperref and then you're golden.


There is also an old trick of how to do it with HTML, see first answer in a link above

<a href="#" class="yourlink">Click Here</a>

If this still works perhaps it is possible to slip it to hyperref, which may then just do it, without JS. (See an answer in one of the links above for how to define the css class if this is of interest.)

like image 104
zdim Avatar answered Jan 19 '26 19:01

zdim