# How do you provide subscripts and superscripts in your comments?

I want to write a comment (text) describing what's happening in my function. I want the text to appear like this:

Note that the ElectronNumberDensity is in units of $$cm^{-3}$$. Thompson cross section is in units of $$cm^2$$.

(With no line break). However, as soon as I type the superscript (using ctrl-^), Mathematica inserts a hard line break like there's a new style or something.

Note that the ElectronNumberDensity is in units of

$$cm^{-3}$$. Thompson cross section is in units of $$cm^2$$.

What is the proper way to type in comments or helpful text that makes use of typesetting?

• Enter in InputForm, e.g., TraditionalForm@Superscript[cm, -3] then highlight and evaluate in place. Aug 28 '19 at 14:49
• That appears to be the answer. Please post it as an answer and I'll upvote it. Aug 28 '19 at 15:05

## 2 Answers

Enter in InputForm, e.g., TraditionalForm@Superscript[cm, -3] then highlight and Evaluate in Place.

Alternatively, you can use CTRL+SHIFT+9 to start an inline cell (see this page for keyboard shortcuts). Oddly, while the shortcut for ending an inline cell is CTRL + ), I need to use CTRL - 0 (i.e. no shift).