How do I do subscripts and superscripts to use in any application?

How do I program a macro to do subscripts and superscripts to use in any application?

Hi,
Do you have an example or app in mind?

Hey @rlsymonds,

Welcome to the forum!   :smile:

Please be more specific.

You are wanting to insert actual subscript/superscript characters?

Or are you wanting to insert the subscript/superscript character style?

If the former then the Insert Text by Typing action or the Insert Text by Pasting action will do the job.

You can use a Typed String trigger for each individual character, or there are other methods available.

-Chris

Subscript or Superscript - how to create a macro

No technicalities. I want a macro to write a subscript or a superscript, in all applications.

You didn't answer my question.

Superscript what?

Subscript what?

What font?

What size?

-Chris

OK for example, in writing' CO2 '(Carbon dioxide), how can you create a macro to make the '2', subscript - in all apps?

There are several ways, one is to create a "Typed String" macro as @ccstone already mentioned.
You type a defined sequence of characters, and then Keyboard Maestro detects it and replaces your typed sequence with your desired outcome:

Example:
Typing the sequence of comma+slash+1 will activate a macro to type a superscript 1

,\1 --> ยน

Screen Shot 2021-02-01 at 10.49.01 AM

Download example:
Superscript 1.kmmacros (2.0 KB)

NOTE: Macro is disabled, you'll need to enable it, you'll see it's grayed out.
Select it and press the Checkmark at the bottom of KM, then the macro will become a solid black color instead of grayed out.
Screen Shot 2021-02-01 at 10.55.41 AM

Thanks, thats a start. Any other alternatives welcomed.

As @hello has shown you can have many different macros to insert various characters.

I'd think creating them would be a bit tedious, and then you've got issues with font and size.

I don't do this often, so I don't have a prebuilt macro and haven't thought through all the possible issues.

That said โ€“ I think I would take the approach of converting a selected character to a superscript/subscript character and preserving its font.

Something like this.

Select the character you want to convert and hit the keyboard shortcut.

Superscript a Selected Character v1.0.kmmacros (5.8 KB)

-Chris

1 Like

Regret to say it doesnt work. It would seem to insert a superscript'1' rather than superscripting the next two numbers to be typed, which is what I am looking for.
Tricky