# Hyper referencing in MathJax

I've Googled and searched mathstackexchange, but cannot find out how to insert a blue URL reference in a question or answer. Can you give me an example that I can edit it to look at the Latex code?

• Perhaps you meant markdown and not MathJax? The way to include links is explained in editing help. One possibility is to use this: [editing help](http://math.stackexchange.com/editing-help#links). See also: meta.math.stackexchange.com/questions/845/… In the editor you also have button for inserting links and the keyboard shortcut Ctrl+L works, too. – Martin Sleziak Feb 1 '14 at 7:00
• @MartinSleziak's answer (it should be an answer) is the way to go. In $\LaTeX$, one needs to load hyperref.sty or similar to include hyperlinks. – robjohn Feb 1 '14 at 9:20
• @robjohn If this is indeed what the OP wanted to ask, then I think the question can be closed as a duplicate. – Martin Sleziak Feb 1 '14 at 9:35
• @MartinSleziak: I searched for a previous instance of this question, but could not find one. Do you have one? – robjohn Feb 1 '14 at 10:00
• @robjohn I thought that the question I linked in my first comment could be a reasonable candidate. – Martin Sleziak Feb 1 '14 at 10:22
• @Martin: The link you provide is for having a link included via markdown. What robjohn is suggesting that the question is about including links via MathJax. – Asaf Karagila Feb 1 '14 at 11:09
• @MartinSleziak: Okay, if the OP intended markdown as you suggest, then yes, it is a duplicate of the question to which you link. If not, then there is no way to add a link within MathJax to my knowledge (and the question seems to be unique). – robjohn Feb 1 '14 at 11:20
• @robjohn: If I recall correctly, t.b. did that at least once. – Asaf Karagila Feb 1 '14 at 13:29
• @AsafKaragila: MathJax has the \href function that inserts hyperlinks. However, as I mention in a comment to AlexR's answer, the MathJax header on MathSE contains Macros: { href: "{}" }. Davide Cervone explains that \href is disabled since it is not considered safe. Perhaps t.b. did his magic before \href was disabled. – robjohn Feb 1 '14 at 15:18
• @robjohn: See Davide's answer. I think that this is what I remembered being done. – Asaf Karagila Feb 4 '14 at 16:32
• @AsafKaragila: oh, I remember doing that. I thought you were talking about a link to a URL. – robjohn Feb 4 '14 at 16:48

@AlexR's suggestion can be implemented using \label and \eqref macros in order to get links from within an equation to another equation (but only such links). E.g.

$$\sin^2(\theta) + \cos^2(\theta) = 1\tag{1}\label{dpvc-1}$$

and then a link in the text: \eqref{dpvc-1} is due to the Pythagorean theorem, and

$$\cos^2(\eta) + \sin^2(\eta)-1 \stackrel{\eqref{dpvc-1}}= 0$$

follows.

Note, however, that you do face the problem described in this post when using labels. There is a work-around using the SOUP script.

See here for a reference, however this does not seem to work on this site:
$$E \href{javascript:alert("Einstein says so!")}{=} mc^2$$ (C&P'ed the example from the MathJax page):
$$E \href{javascript:alert("Einstein says so!")}{=} mc^2$$

## Suggestion

If Links are really required, try this:

$$\sin^2(\theta) + \cos^2(\theta) = 1\tag{1}$$ (1) Is due to the pythagorean theorem $$\cos^2(\eta) + \sin^2(\eta)-1 \stackrel{(1)}= 0$$

• I tried \href because it is listed here, but, as you say, it is not enabled here. – robjohn Feb 1 '14 at 11:45
• @robjohn Is there anyone (SE employee?) who can officially confirm this? – AlexR Feb 1 '14 at 11:46
• I tried this example on a local page to which I have added a MathJax header. The example works on my local page, but I see Macros: { href: "{}" } in the MathJax header on the pages here, and that disables \href. – robjohn Feb 1 '14 at 12:18
• The \href macro is considered "unsafe" because it can allow answers to include javascript (like the alert in AlexR's message), and that means that posts could include evil code that a user could trigger inadvertently. MathJax now includes a safe extension (see the documentation and options for details) that disables all such macros, but SE hasn't updated to use that. Note that you can configure \href to allow http:// references but not javascript:// ones. – Davide Cervone Feb 1 '14 at 13:01
• @Davide Imo this is a major flaw, about which I've been meaning to make a feature request. Often I want to post a long proof (e.g. in an \eqnarray) where each line links to prior answers to justify the inferences. To insert the links, I have to break it into numerous MathJax lines, so losing the two-dimensional alignment afforded by the array. For me, this is one of the greatest pains currently in MathJax (besides the frequent Chrome crashes). Is there any workaround? – Bill Dubuque Feb 2 '14 at 0:40
• @BillDubuque You could use \tag{1} to set reference "labels" at the right: $$a^2+b^2=c^2 \tag{1}$$ $$c \stackrel{(1)}= \sqrt{a^2+b^2}$$ – AlexR Feb 2 '14 at 15:10
• It is not clear to me what "this" refers to when you say "this is a major flaw", the fact that SE has disabled \href (the subject of the comments above yours) or that you haven't been able to make a link from a line of an alignment (a new topic). I suspect it is the latter, but in that case, you should be posting a new question, not asking a new one in comments. Indeed, since \href is not enabled in SE, it would be better to do it on the Mathjax forum, since none of what you are discussing can be done here. – Davide Cervone Feb 2 '14 at 16:14
• In any case, the answer to your question would require more than just a comment from me, but since it is not an answer to the original post, I am not able to use an answer, here. If you post to the MathJax forum (or make a new question here in meta), I will respond there. Note, however, that you can't use \href to make link from an entire line of an \eqnarray in $\rm\TeX$ either, so I'm not sure why you would expect to be able to in MathJax, and personally I don't consider this a flaw, let alone a major one. There are some things you could do to get the effect I think you want, however. – Davide Cervone Feb 2 '14 at 16:17
• @BillDubuque, forgot to tag you, so weren't sure you'd see the two comments above. – Davide Cervone Feb 2 '14 at 17:15
• @Davide I am requesting the same functionality as the OP, i.e. the ability to embed a URL in MathJax code. Does that functionality currently exist? If not, can it be provided? – Bill Dubuque Feb 2 '14 at 17:57
• @Bill, yes, as pointed out by AlexR, MathJax supports the \href command (he links to the docs as well). But StackExchange has disabled it, as indicated by robjohn. That is not a flaw in MathJax, so your comment was confusing. The inclusion of \eqnarray into the mix led me astray since I thought you were talking about not being able to use \href across the column breaks (which you can't, but that is also true in $\rm\LaTeX$). The fact that you are breaking up the alignment in order to use Markdown links around the lines is not a flaw in MathJax either, so that was a confusion as well. – Davide Cervone Feb 2 '14 at 19:23
• I pointed out that the safe extension allows a more fine-grained control over the URL's that can be included in \href, and that javascript: URL's can be excluded while http: and https: ones are allowed. So yes, MathJax provides the functionality, but SE disables it, and yes, it could be provided safely if they chained the configuration. But since all that was said before your comment, I was confused about what additional information you were after. – Davide Cervone Feb 2 '14 at 19:29
• @Bill, the ability to separate safe from unsafe URL's did not exist in MathJax before several months ago, which is why SE had the entire macro disabled. At this point, it is a matter of getting the SE developers' attention rather than a capabilities issue. It was not clear from your message that you meant only http:, https: and ftp: links, since you said "urls", which includes all protocols. You seemed confused by why SE would have disabled \href, which is why I tried to explain it (not defend it). – Davide Cervone Feb 2 '14 at 22:43
• @Bill, actually not. It is a support request, which is asking about how to use the current features of the site. It has already been marked as "status-bydesign" (correctly), with no additional comment. I suggest you make a question tagged as "feature-request" that asks for enabling of the MathJax safe extension. – Davide Cervone Feb 3 '14 at 11:45
• @BillDubuque I've opened a feature-request over here – AlexR Feb 3 '14 at 12:47