Inserting Mathjax and making posts look nice is rewarding, but it can often be, well, repetitive and boring :( Well, not any more. I have been testing and improving this userscript for quite some time now, and here it is in its first release! :D

Markdown Shortcuts for Stack Exchange

Because textual descriptions are boring, here's a video demo of the ninja capabilities: Video demo. In short:

  • Alt-your choice => insert LaTeX command (text => \mathrm{text})
    • prepend Ctrl (Ctrl-Alt-your choice) => inserts LaTeX command with $ surrounded ($\mathrm{text}$)
  • Alt-Z => dollar-ifying (text => $text$)
  • Alt-C => double dollar-ifying (text => $$text$$)
  • Alt-S => frac-ify (A/B => \frac{A}{B})
  • Alt-A => align-ify (image demo)

All the commands (hotkeys, insertions) are completely customizable. It supports wrapping and unwrapping text, as well as custom caret positioning via the pipe character. If this wasn't enough, this also works in comment boxes and in chat! :D

If you're interested in detail in the ninja editor capabilities, here's the detailed Stack Apps entry for this userscript.

One-click install userscript

(read this page to know how to install userscripts in your browser)

List of default LaTeX commands

Keycode Command
Alt-I   \pi
Alt-R   \mathrm{}
Alt-E   \ce{}
Alt-W   \pu{}
Alt-T   \text{}

Alt-Z   dollarify
Alt-C   double dollarify
Alt-S   frac-ify
Alt-A   align-ify

Finally, your feedback is encouraged! What more additional features or improvements would you like to see incorporated in the userscript, to make editing even easier? Remember, this is a userscript, almost everything is possible, so feel free to ask ;)

  • $\begingroup$ Seems similar to stackapps.com/questions/3373/mathjax-buttons ? That script also adds buttons -- perhaps you'd like to roll the extra buttons into that? I'm not actually sure if it still works, but if it does would love to keep it maintained. $\endgroup$ Jul 19, 2018 at 19:00
  • $\begingroup$ @Manish hello! Yep, both of these userscripts have the same motivation, but the newer one has several features more than the original one. I had also thought about the buttons, but the problem with them is that the latex command list is user-editable in this case, so it is possible that the number of buttons would overflow into two lines on the toolbar and clutter it :/ if you've anyway of avoiding that, i'm open to suggestions. Perhaps, I could add a button just for the top 4-5 latex commands? $\endgroup$ Jul 20, 2018 at 0:29
  • $\begingroup$ Hi Gaurang! Thanks a lot for your efforts. I found this only yesterday and it seems to be a real time saver. To insert $\mathrm{}$, the combination (Ctrl+Alt+R) creates a small $_\circ$ near the } which disappears when I backspace once. This screenshot might be helpful. Is this intentional? Or if possible, could you fix it? $\endgroup$
    – Vishnu
    May 30, 2020 at 5:07
  • $\begingroup$ @GuruVishnu Hey Guru, glad you like this tool. I am unable to replicate the issue though. See image. The relevant code does not contain a $\circ$ either, so I am not sure why this issue appears. Let me know if it also doesn't work in incognito, i'll ask others in chat then. ![](i.sstatic.net/dh5rv.png) $\endgroup$ May 30, 2020 at 7:05
  • $\begingroup$ I noticed there was no $\circ$ while adding one extra line in your code for a different purpose. I guess that's an issue on my end and it existed even before my edit. It seems all the Alt combinations work well, however, now I found multiple issues with the Ctrl+Alt commands. Please see this screenshot. The same issues exist even when I perform these commands in an InPrivate window. Sorry for the disturbance. $\endgroup$
    – Vishnu
    May 30, 2020 at 7:38
  • $\begingroup$ It's ok @GuruVishnu. I am checking for altkey press in this method, you can search for "altKey". Most probably your alt key is system bound to some other character. $\endgroup$ May 30, 2020 at 10:31


You must log in to answer this question.

Browse other questions tagged .