This is not quite a programming question, but it’s about a programming environment, so hopefully not too out of place. I need to be able to write chemical formulas in Mathematica text (this is specifically about text, not input/code). Something like: H3O+. But Mathematica can’t seem to do this. If you use the normal sub/superscript functions, or hit Cntl-_ or Cntl-6, it puts you in “math mode” even when you are in text, and so the letters become italic, and it puts a space between the 3 and the O. Like this: H3 O+. Ugly, especially with longer chemicals.
Other things in Mathematica work like normal word processors — you can style fonts as italic, bold, big, small, colored — but the subscript and superscript functions common in word processors seems to be missing.
Am I missing something? I hope so…
thanks,
Rob
You could use a trick similar to that used in LaTeX for printing subscripts on the left. That is place the subscript on an object with no width.
To enter math mode type Cntl-( and to exit type Cntl-) .
Attach the sub and superscripts to ⋮null⋮ or ⋮ ⋮ or ⋮- ⋮ (where ⋮ = escape)
Here’s how it displays – compared to some expressions in mathmode:
![the chemical formula for hydronium is HSubscript[[Null], 3]O[Null]^+](https://i.stack.imgur.com/exCaG.png)
I’ve placed the Cell Expression in a gist for you.