# context menu should allow easy copying of $\TeX$ commands

In more than $99\%$ of all cases in which I use the context menu option "Show Math As", I select "TeX Commands" and then press the keyboard shortcuts for "Select All", "Copy" and "Close". This takes several keystrokes and causes a short delay for opening and closing the window. Since I suspect that I'm not the only one who uses this option almost exclusively for this purpose, it would seem useful to have an option "Copy TeX Commands" in the context menu, or perhaps "Copy Math As -> TeX commands" if people also use the "MathML Code" option a lot (I currently don't).

• I'm not sure how much control the Stack Exchange people have over the MathJax context menu, but presumably not much. But I could be wrong. – Clive Newstead Sep 25 '12 at 9:52
• Like @Clive said, perhaps this should instead be a feature request directed to MathJax.org? – Willie Wong Sep 25 '12 at 10:42
• But the MathJax guys read and follow this forum, so it's not unreasonable to make this suggestion here. In fact we heavy users this is a good place to get further input on the idea anyway. – Asaf Karagila Sep 25 '12 at 11:24
• Apparently there is no good way to copy to the clipboard from Javascript in most browsers. (And good grief, I would be furious at my browser if it allowed untrusted JavaScript from the network to clobber my clipboard content without myself explicitly requesting it to). – Henning Makholm Sep 25 '12 at 13:37
• Henning is right, the main reason MathJax doesn't do this is that javascript is not allowed to modify the clipboard. The purpose of the separate window is to allow you to select and copy the math, since you can use the clipboard. It would probably be possible to have the output come preselected, so you wouldn't have to do that, but that is about it. – Davide Cervone Sep 25 '12 at 22:58
• @Davide I hate that new window. I would usually click the "edit" button instead, but that's an ugly solution. – Asaf Karagila Sep 25 '12 at 23:34
• @AsafKaragila, if it were handled as a "fake" window (like the About MathJax box) so that it is just a floating element in the same window, say with a textarea where the TeX or MathML is shown, would that help? I expect to revisit how this is done in the release that follows the bug-fix one we are finalizing right now. – Davide Cervone Sep 26 '12 at 0:02
• @Davide: It would be somewhat better, but I think the best option would be (if possible!) to have something like the "share" option on the site, which opens a floating text box. However if the code is long it will be annoying to look at, and a multiline field would be needed... – Asaf Karagila Sep 26 '12 at 11:47
• @AsafKaragila, yes, that is the type of thing I was trying to describe, and had in mind. – Davide Cervone Sep 26 '12 at 11:56
• I've asked this here but cannot find it now. Anyway, I feel your pain too. It used to be easier before. – lhf Sep 26 '12 at 13:20
• @AsafKaragila: if you right click on the "share" link, you can choose "Copy Link Location" from the contextual menu (at least using Firefox on the Mac) and you don't even need to open the window and copy the text. I don't know if this could be made to work for the MathJax contextual menu. – robjohn Oct 1 '12 at 17:23
• @robjohn: Yes, this is what I proposed to have the LaTeX code in. – Asaf Karagila Oct 1 '12 at 17:28
• @robjohn, that works because "share" is an actual link to something, and the browser's menu provides the "copy link" function; it is not handled through javascript. To do that for MathJax would require every equation to be a link, with the target being the original TeX code. This would have bad side effects: clicking the math would try to take you to that non-existent page, you would not have the MathJax menu (since you need to use the browser menu to access "copy link"), it would be harder to click or double-click to zoom, and you could not have internal links within the math. – Davide Cervone Oct 4 '12 at 10:36
• There may also be limitations on how long the text of a link can be, and that could prevent longer math from being copyable. – Davide Cervone Oct 4 '12 at 10:37
• @DavideCervone: I thought that might be the case, but I wasn't sure if there might be some sort of workaround. However, it sounded quite similar to the other desired copying scenario. Thanks for the confirmation, although negative. – robjohn Oct 4 '12 at 16:10