Reputation: 16409
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
Upvotes: 6
Views: 4987
Reputation: 14731
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:
I've placed the Cell Expression in a gist for you.
Upvotes: 6
Reputation: 61016
In ChemData, Mathematica uses contructs like
Style[
Row[
{Subscript["H",3],Superscript["O","+"]}
],
Rule[ScriptBaselineShifts,{0.5`,0.75`}]
]
Example:
HTH!
Upvotes: 4