Textexpander help: Superscript and Subscript?

textexpander

#1

I’ve been wracking my brain for the last hour trying to figure out how to apply superscript and subscript to a document, such as the case when writing a chemical formula for a specific product. For instance, Peroxide is H202, with the “2’s” in subscript type. As seen here: image

However, there does not appear to be a way to set this up in text expander so that the subscript characters are immediately formatted in this fashion. Normally, you would highlight the number on your document (in this case Pages) and then select the formatting option (in Pages the shortcut for this is CTRL+CMD+ - (the subtraction symbol).

Anyone have a macro or other workaround to overcome this limitation?


#2

Seems like this would be doable in Keyboard Maestro.


#3

I may have to plunge into KM again and check it out, thanks :slight_smile:


#4

This raises an interesting problem.

I’ve been using TextExpander for years, and have many such snippets in it, including Na±K±ATPase, pKa, O2-• and many other chemistry/biochem/cell bio snippets. Oddly, in spite of working with H2O2 extensively in the past (my research has mostly involved oxidative stress and antioxidant defenses), I do not have that one. (But I do now!)

I found soon after I joined MPU forum started that Discourse won’t honor the formatting, but my snippets include the superscripts and subscripts. I’m not inclined to add them right now because I’m sure you know what I mean.

So I looked at Textexpander (version 6.2.8) just now to see why you couldn’t make the same kinds of snippets and found that superscripts and subscripts have been removed from the formatting options. That’s disappointing. I created these on, I’d guess, version 4 and I’m sure I created some in Version 5, too. So this ability has been removed in Version 6.

Even stranger, when I use the snippets in Mail, MS Word, and so on, (but not Discourse) the formatting is honored, even though those formatting options have apparently been removed from TE’s own editor.

I did come up with a workaround, but it’s disappointing that I should have to do this.

I created H2O2 in Word, properly formatted with subscripts, and copied it into TE, selected “Formatted Text, Pictures” in the Content dropdown, assigned the shortcut, and used TE to add H2O2 to a document, and it works fine. So you need to do the formatting outside of TE and paste it in.

Thanks for posting this – now I have an H2O2 snippet!


#5

Thank you for this! The weird thing is I seem to remember having used TE for this very purpose before, but like 5+ years ago for a document and then either didn’t need it again or had fallen into the habit of learning how to complete the shortcuts, etc.

That’s a very odd workaround indeed, but I thank you! My new work requires me to make many references to electrochem, and peroxide comes up constantly.


#6

You’re welcome!

I wonder if they left out anything other than the most basic formatting options because most people create the formatted text of a snippet somewhere else and then paste it into TE.


#7

That seems feasible, sort of like they just dumped specificity for one generalized function to cover a variety of formatting issues.


#8

I’m surprised no one suggested using HTML tags for super- and sub- scripts. I occasionally need to write O2 so I’ve created a TextExpander snippet that inserts the letter O and a sub 2 using HTML.

The tag is < s u b > (without spaces) in front of the 2 then < / s u b > after the 2. Superscript would be the same thing with ‘sup’ in place of ‘sub.’

Caveat: It doesn’t work in all applications so YMMV. It works great in every app that recognizes Markdown. Apple Mail is a no-go, but it works in Airmail.


#9

Right. The point about Markdown is you can embed HTML in it.

In my (sadly private) code where I encounter sup elements, for example, I render it as superscript.

The question I was going to ask the original poster was: “How were you expecting superscripts and subscripts to be encoded”? You @cincymacgrrl have shown one common way - and the way I would want to do it. Maybe RTF also has a way but plain text generally doesn’t.


#10

The lack of information on how to do sub and superscripts in TE snippets is really surprising.

Maybe it’s time to plunge into LaTeX?
It would be easy to create TE replacements that expand to LaTeX, but the LaTeX isn’t that bad in itself. When writing it is just \ce{H2O2}.
If you need Word output, pandoc should handle the conversion.

Here’s a sample using Texpad on my iPad.


Pretty snazzy!


#11

@JohnAtl’S mention of Latex (no attempt on my part at formatting that properly) :slight_smile: made me go back and read the original post.

The OP mentioned Pages. I don’t know what format you can type into Pages - whether RTF or HTML or (unlikely) Markdown.

The issue to me is not what bytes you can coax TextExpander into emitting but rather what bytes would be useful from the Pages POV.

(I don’t use Pages so don’t know the answer to that one. Anyone?)


#12

You’re right!

I just tested the solution I provided above, in Pages and… it works!


#13

So I wonder if that is taking advantage of Unicode codepoints. probably there are superscript and subscript variants of numbers, at least.

(I’m not a Unicode expert.)


#14

I dunno. I’m not that powerful of a power user. I formatted the text in word, pasted it into TE, and it works everywhere I’ve used it except for Discourse and Excel.

Whatever way formatted text is coded in Word must be how this snippet is coded.