Is there a way to get the superscript math mode behavior without using ^?

By way of background: I work at a large school that has a large web site that occasionally has math content on pages. I recently convinced the powers that be to start using MathJax to render all of the math content, but they have encountered a hitch. There is a collection of pages that is processed by complicated subsystems in an automated way, and I'm told that the ^ character is a control character at some stage(s).

So either they have to work around that, or I could start communicating the math without using ^ symbol. (I understand that I may still have a MathJax issue to move on to, but my issue starts with this LaTeX question.)

  • 2
    Is this a LaTeX question? MathJax questions are off-topic – user31729 May 21 '15 at 21:03
  • 3
    In (La)TeX it's possible to use \sp instead of ^ for exponents; it doesn't seem possible in MathJax. Nothing can be done other than making a feature request to the developers. However, I have tried $\def\sp{^}a\sp{b}$ on a page where MathJax is used and it appears to work, so it may be possible to add \def\sp{^} to some initialization file. – egreg May 21 '15 at 21:06
  • 1
    @ChristianHupfer But mathjax is a recognized tag at this site, as you can see. So is that really true? In any case, it is not necessarily a MathJax question. If there exists a LaTeX command like, say, \mathsuperscript{}, then that would answer my question here. I'd move on to see if MathJAx supports it. – alex.jordan May 21 '15 at 21:13
  • 2
    @alex.jordan: MathJax uses the same syntax (or supports at least some commands) as (La)TeX, but the engine behind it is different. – user31729 May 21 '15 at 21:16
  • 2
    If your page is pre-processed before being sent to the browser, you might be able to use ^ in place of the ^ (either in your math expressions, or in the definition of \sp) in order to get past the pre-processing of ^. This is will be converted to the circumflex by the browser, but is not a literal ^ in the source file. – Davide Cervone May 22 '15 at 10:25

in latex.ltx there is a line


so there is an alternate command, \sp, that will produce a superscript.

@egreg notes in a comment that this isn't available for mathjax, so it's apparently not "portable". however, david cervone (mathjax lead developer) says that

MathJax does handle \let\sp=^ [...]. MathJax's \let only works to set a control sequence name, not another character, so you can't do \let!=^, for example, but setting \sp would certainly work.

this command is inherited from plain.tex. in the texbook (p.135)

\danger If for some reason you cannot use ^ and _ for superscripts and subscripts, because you have an unusual keyboard or because you need ^ for French accents or something, plain TeX lets you type \sp and \sb instead. For example, $x\sp2$ is another way to get x2. On the other hand, some people are lucky enough to have keyboards that contain additional symbols besides those of standard ASCII.

  • 1
    Why is the macro named \sp? \stackpowers? – user31729 May 21 '15 at 21:09
  • 3
    @ChristianHupfer \let\sb=_ is the analog: SuPerscript and SuBscript. – egreg May 21 '15 at 21:10
  • 2
    @ChristianHupfer -- shorthand defined by knuth. this line in plain.tex': \let\sp=^ \let\sb=_`. adding note to answer. – barbara beeton May 21 '15 at 21:12
  • 3
    Can you add the original |verb| to the quote? I was a bit confused reading $x\sp2$ is another way to get $x\sp2$. Or simply leaving out the code-markup for the second instance might do just as fine. – Johannes_B May 21 '15 at 21:40
  • 1
    @ChristianHupfer, MathJax does handle \let\sp=^, so I'm not sure where that claim is coming from. MathJax's \let only works to set a control sequence name, not another character, so you can't do \let!=^, for example, but setting \sp would certainly work. Perhaps that is the source of the claim. – Davide Cervone May 22 '15 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.