85

I use ² and ³ a lot in e-mails. When using my Belgian Windows keyboard and a custom keymap it was easy to type this in Mac OS X as I assigned the appropriate key. These are the mathematical symbols for squared and cubed, or raised to the power of 2 and power of 3.

Now I switched to a QWERTY International English Apple keyboard and I'm unable to type these characters easily. I've to copy-paste them or select them and make them superscript.

Is there a way to easily type these characters with touching my mouse or need to copy-paste?

1
  • Make sure you understand the nature of the superscript. In some cases there are fonts that have superscript numeral characters. In other cases a word processor creates the image of a superscript by taking a regular numeral character, displaying it in a smaller font, and shifting the placement of the character higher up from the baseline of the rest of the text.
    – user9290
    Commented Mar 23, 2012 at 15:20

12 Answers 12

71

There are some important gotchas with the other solutions posted here.

For one, symbol and text substitution entries only work in Cocoa apps. If you want a truly system-wide solution that works in all applications, this is not an option.

Also, apps like KeyRemap4MacBook are great, but relying on them means you have to keep the app running in the background all the time, which may not be what you want.

Custom keyboard layouts to the rescue

Luckily, remapping keys can be done in a way that will work for any type of application, and without any additional software!

Mac OS X has supported .keylayout files since version 10.2 (Jaguar). You can create your own keyboard layout, or rather, tweak the default one you’re using right now. Simply remap a keyboard combination you never use (for me, there are plenty of those) to the ² and ³ symbols, and that’s it.

In my custom QWERTY keyboard layout, I can simply press + + 2 to enter ², and + + 3 to enter ³. (My custom AZERTY layout has these mappings, too.)

How to create a custom keyboard layout

To create new keyboard layouts or modify existing ones, I’d recommend Ukelele.app. It has an option to create a new keyboard layout based on the one that’s currently in use.

After you’ve created your custom layout, there’s no need for the application anymore — you certainly don’t need to keep it running in the background.

How to install a custom keyboard layout

  1. Copy the .keylayout file to the Keyboard Layouts folder within ~/Library (if you want to install it only for the current user) or /Library (if you want to install the layout system-wide).
  2. Reboot (if you installed the layout system-wide), or log out and log in again (if you installed it for the current user only).
  3. Enable the new keyboard layout via System PreferencesLanguage & TextInput Sources.

How to make a custom keyboard layout the system default

Optionally, you could make the custom keyboard layout the system default by running the Setup Assistant with root privileges. This way, it will be used for the login screen, and any new user accounts you create will default to this layout as well. Note that this can only be done for keyboard layouts in /Library/Keyboard Layouts (i.e., layouts that have been installed system-wide).

sudo rm /var/db/.AppleSetupDone; sudo "/System/Library/CoreServices/Setup Assistant.app/Contents/MacOS/Setup Assistant"

You will have to create a new user account in order to complete the Setup Assistant — but don’t worry, you can delete the new account afterwards.

Adding a custom icon to the keyboard layout

OS X will use the following default icon for your custom keyboard layout:

Options showing "U.S." with an American flag, and "AZERTY" with a keyboard icon

This icon will show up in the preference pane, and in the “Input menu” in the menu bar.

To replace this with your own icon, create a 16×16px image, and save it in .icns format in the same directory as the keyboard layout itself, using the same file name (only the extension differs). For example, my custom QWERTY layout is named qwerty.keylayout, so if I wanted to use a custom icon, it’d have to be named qwerty.icns.

8
  • 1
    One of the "other solutions posted here" is in fact to make a custom keymap using Ukelele. But your extensive explanation is of course a very useful addition. Commented Mar 23, 2012 at 13:13
  • The only thing I don’t know is how to remove or disable a built-in keyboard layout. See apple.stackexchange.com/q/44921/4408 for that. Commented Mar 23, 2012 at 13:14
  • I suspect you might be able to do that if you could figure out how to insert your custom layout into the AppleKeyboardLayouts.bundle. Commented Mar 23, 2012 at 14:48
  • I know that is still on beta, but I'll add here anyway. This didn't work on Yosemite =( Commented Aug 6, 2014 at 14:50
  • @MichelAyres What didn’t work exactly? Are you saying Yosemite doesn’t support custom .keylayout files? Commented Aug 6, 2014 at 20:15
32

If you can enter the ² and ³ once, you can put it in as a substitution in System Preferences, Language & Text -> Text.

Put something unique on the left side, like ^^2, then paste your symbol in on the right.

You'll may have to quit & restart each application for it to work, and some applications it may not work correctly in. Any that use a web view (including Mail, which was what you specifically asked about, and Safari) will need you to specifically enable Text Substitution from the Edit menu. Individually. Or you can run this command once in Terminal, and it will change the default for every web view:

defaults write -g WebAutomaticTextReplacementEnabled -bool true

This is from Macworld, but the Macworld article assumes Lion would make this step unnecessary. It didn't. Maybe Mountain Lion will.

As for entering the ² and ³ into System Preferences: You can use the character palette or paste to enter the symbol into the right side. It sounds like you already have this part figured out, though.

Language & Text

6
  • 1
    This is reeeeally nice! :)
    – gentmatt
    Commented Mar 16, 2012 at 8:20
  • This only works in Cocoa applications, though. Commented Mar 23, 2012 at 9:55
  • 1
    True. However, most Carbon apps have Cocoa interfaces these days. Certainly, this'll work with any 64 bit app. :) Commented Mar 23, 2012 at 17:25
  • 3
    Aha, I like your ^^2 shortcut, that's nice. I also added ^^n for ⁿ. This has moved, it's now in "keyboard" instead of "language & text," and you don't have to restart apps. This synchronizes between OS X and iOS if you have the iCloud stuff set up right. I've also set up shortcuts for ½ ⅓ ⅔ ¾ ∞ ॐ and other fun things, even large snippets of text I use regularly. I love wishing my Facebook friends a ¡ʎɐpɥʇɹıq ʎddɐɥ or signing off chat with लॉका: समस्ता: सुखिनो भवंतु ! Another handy one I use is @@@ for my email address. Commented Mar 4, 2016 at 2:04
  • 1
    I mapped € to ² and ‹ to ³ because those first characters are the defaults for Opt + Shift + 2 or 3. Now, to type ² or ³, I just hit the corresponding combination and press space.
    – Ben
    Commented Nov 15, 2017 at 14:50
18

(None of the other answers explain how to type a superscript besides copy/pasting.)

To type a superscript character in an application that doesn't support superscript, you can use Character Viewer:

  1. Edit > Emoji & Symbols Space
  2. You'll find these under the Symbols > ① Digits list

Here they are for copy pasting:

  • Superscript: ⁰¹²³⁴⁵⁶⁷⁸⁹
  • Subscript: ₀₁₂₃₄₅₆₇₈₉
2
  • 2
    Edit > Emoji & Symbols and typing the digit in search bar helped
    – AamirR
    Commented Jul 10, 2018 at 12:22
  • 2
    I am a simple man. I Saw copy paste option and I said, Yes.
    – rptwsthi
    Commented Feb 9, 2020 at 20:42
4

Making custom keymaps for OS X is very easy using Ukelele

http://scripts.sil.org/ukelele

2

For those looking for simple shortcut to do this in a Word document or other Office program:

(Command + Shift) + plus/equals key

Then type number you want then repeat above shortcut to return script size to normal.

(Also works without the Shift on some systems.)

1
  • With that approach you're substituting a Unicode character U+00B2 "²" or U+00B3 "³" with a superscript-formatted plain "2" or "3". Commented Feb 24, 2021 at 8:41
1

If you are using 10.7, you could also perhaps add the desired characters to the Character Picker, as described in

How to add characters to the press and hold character picker in OS X Lion?

1
  • Welcome to Ask Different. Consider expanding this answer to be more than just a link. What happens if that link goes away in the future?
    – jaberg
    Commented Mar 23, 2012 at 14:58
1

Based on another answer, I made Text Substitutions.plist so you don't have to manually enter all the numbers.

  1. Download this file Text Substitutions.plist and extract it
  2. Go to System Settings > Keyboard > Text Replacements
  3. Drag the Text Substitutions.plist file to the Window.

Animated GIF showing how to add the Text Subsitutions.plist file to the Text Replacements window

Now you can type ^^1 and it will replace to ¹.

Use ^^ for superscript \`` for subscript

1

The way I do it (often) is select "Unicode Hex Input" as an input method.  All the keys by themselves work the same, but if I hold the option key, I can type any four hexadecimal digits to get the character having that code (not case-sensitive).

⁰ is 2070

¹ is 00B9

² is 00B2

³ is 00B3

For others, see Unicode: Superscripts and subscripts block

No need to create a custom layout or add third-party tools.  "Unicode Hex Input" has been in macOS for years.

0

KeyRemap4Macbook

can be used to remap keys in OSX and is compatible with Lion. I've used it to remap the volume buttons only. You should be able to figure out your solution using this tool.

enter image description here

0

You can use the Character maps on a Mac or install a 3th party software like PopChar.

0

Highlight the digit you wish to shrink and elevate. Press cmd+- to resize. In format under the 'font' heading, click the 'settings' icon on the row with bold, italic and underline to find advanced settings. Select the baseline shift option to elevate the digit. A bit clunky, but if you don't need it often it's a simple option.

1
  • Do these instructions still work with OS X El Capitan? I can't find the baseline shift option anywhere in the format bar above the e-mail message or in the window that comes up with Format -> Show Fonts. I've been composing the text in TextEdit (Format -> Font -> Baseline) and then copying and pasting to Mail, but that's not a great solution. Commented Oct 5, 2016 at 21:55
0

I do something similar with Typinator (card suit symbols), which is from the same company as PopChar. I think there are competitors that do the same thing. I don't treat the symbols as superscripts. I looked up the Unicode characters for them (superscript numbers are also separate Unicode code points). Every font I use has these glyphs; of course, your mileage may vary.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .