# Can We Have Links in Tags?

In a recent comment correspondence between Jack D'Aurizo, SimplyBeautifulArt, and myself, it was asked whether one can put links in a tag. A quick and naive test fails, as such: $$\text{Direct Link} \tag{http://www.google.com/}$$ $$\text{Replaced Text} \tag{[link](http://www.google.com/)}$$ $$\text{Number Link} \tag{[enter link description here][1]}$$

Where the third test is link notation where the link is stored at the bottom of the post in the format of "[1]: URL".

Jack proposed that by mashing together available $\LaTeX$ and Markdown libraries we might be able to make something work, and appears to have somewhat achieved this by using artificial spacing $\displaystyle\hspace{5cm} I(a)=\int_{0}^{+\infty}\frac{x^a}{e^x+1}\,dx\hspace{5cm}$ (Google)

Generated with the following code:

$\displaystyle\hspace{5cm} I(a)=\int_{0}^{+\infty}\frac{x^a}{e^x+1}\,dx\hspace{5cm}\$ \[$(\text{Google})$]($\text{http://www.google.com}$})

However, this is abuses in-line styles and isn't a true tag even if we can get it to work with individual-line equations (those wrapped in \$\$)

What are some known ways to get this to work?

Important Edit:

It appears that the intended way to do this is to use the command \href, but the SE devs disabled this to avoid malicious code being executed. However, MathJax has included a safe-mode for years to keep this from happening, which the SE devs seem to have completely neglected. See here for a documentation of this feature and here for an old feature request on this meta from 2014 asking for safe \href to be enabled

• Actually MathJax has the \href macro to provide exactly this; however it is apparently disabled here, probably for security reasons. – celtschk Feb 22 '17 at 0:07
• @celtschk Yeah, I was aware of \href; mixedmath addresses this in his post as well, but it seems completely disabled – Brevan Ellefsen Feb 22 '17 at 0:10
• @celtschk this is relevant to your point meta.math.stackexchange.com/questions/12674/… – Brevan Ellefsen Feb 22 '17 at 0:15
• I'm intrigued by the fact that I was downvoted. Someone apparently doesn't want this feature? – Brevan Ellefsen Feb 22 '17 at 2:37
• I wasn't the downvoter, but I don't actually care if we have this feature or not. It seems totally acceptable to me to either link the whole equation, or to tag each line and explain each tag with a link. But I do think it's interesting that \href isn't allowed, and I do wish that I knew the reason. – davidlowryduda Feb 22 '17 at 2:41
• I requested this before, see here.. For some reason SE has not yet enabled this MathJax feature. That's a shame, since it would prove quite beneficial. It's very cumbersome not to be able to link to proofs in MathJax code. – Bill Dubuque Feb 22 '17 at 4:27
• I had downvoted it.Somewhat complicated MJ constructs cause more issues than they solve. Better to keep things simple and straightforward. – quid Feb 22 '17 at 14:20
• There is a way to do it within MathJax, even with \href disabled, but I hesitate to give it because it allows unfiltered URL's and so would allow the type of security issues that the folks at SE have tried to avoid by disabling \href. (If they used MathJax's Safe extension, it would prevent the problem even with the technique I have in mind.) I'm not sure whether it is right or wrong to expose the technique. It might encourage the powers that be to implement Safe, but in the meantime, it would be a security concern. – Davide Cervone Feb 23 '17 at 0:05
• @DavideCervone I can respect that decision. It's unfortunate SE won't just use the Safe extension :/ – Brevan Ellefsen Feb 23 '17 at 0:22
• @DavideCervone that being said, if you feel like sending a message to the SE devs about this in order to convince them to allow the Safe extension it would be great, even if you have moral qualms about sharing any existing techniques :) – Brevan Ellefsen Feb 23 '17 at 0:44
• @BrevanEllefsen, we have brought it up with them more than once, but it is up to them, and it seems to be a low priority. The Safe extension was actually designed around the issues raised here, so I was disappointed that they didn't adopt it. – Davide Cervone Feb 23 '17 at 15:49
• @DavideCervone really??? How unfortunate :/ I'm generally impressed with the Devs' decisions, but the fact they would ignore such a fantastic feature shocks me. That being said, I appreciate all the work you do to create such a wonderful platform for expressing mathematical equations :) – Brevan Ellefsen Feb 23 '17 at 17:08

What if I try $$2 + 2 = 4 \tag{\href{http://davidlowryduda.com}{davidlowryduda.com}}$$

$\href{http://google.com}{google.com}$

Nope.

So the best I have is to use $$2 + 2 = 4, \tag{1}$$ (where the entire equation is clickable) or to use $$2 + 2 = 4, \tag{2}$$ where $(2)$ is shown at url. [Or equivalently, where (2) is proved at davidlowryduda.com, or whatnot].

• Nope. And oddly, this breaks spacing on my renderer. Weird. I note that the \href command is parsed correctly, but does not seem to function meaningfully. – davidlowryduda Feb 22 '17 at 0:04
• Odd, isn't it? I tried the same thing earlier – Brevan Ellefsen Feb 22 '17 at 0:04
• – Brevan Ellefsen Feb 22 '17 at 0:15
• We have just discovered a way for writing answers twice as large as usual :D – Jack D'Aurizio Feb 22 '17 at 1:27
• @JackD'Aurizio I'm not sure what you mean by that? – Brevan Ellefsen Feb 22 '17 at 2:38
• @BrevanEllefsen: we have discovered that we may break formatting by inserting a href inside a tag. This is an issue that may give a way to write answers taking twice the horizontal space they usually deserve. – Jack D'Aurizio Feb 22 '17 at 4:16
• This is unrelated to the \href itself, only to the fact that the context of the tag is excessively wide. See this post for details. – Davide Cervone Feb 22 '17 at 23:45