With macOS fully supporting unicode throughout the system (including the terminal), extended keyboard layouts (like “U.S. International - PC”) go a long way for easily typing unicode symbols. However, I find the existing layouts to have many shortcomings for my needs, which involve typing German and using a lot of scientific/Greek symbols. Some simple unicode math can come in very handy for IM/emails, and it also makes it much easier to work with unicode identifiers in Jupyter notebooks (especially when editing them in vim).

Using Ukelele, I created a keyboard layout “U.S. International - Scientific” for my use case. The default keys are the standard US layout; unicode symbols are accessed through the right-alt (“option”) key ⌥:

Keyboard layout "Alt"

The combination with shift (⌥⇧) gives the “upper case”:

Keyboard layout "Alt-Shift"

Dead-keys” are orange in the above diagrams. These wait for another key to be pressed before returning anything. The layout provides the following features:

  • Easy umlauts (e.g. ⌥O for Ö) and ⌥s for ß – I’m German.

  • Support for other Western European languages (e.g. French, Spanish)

    • Accent aigu (é) through dead-key ⌥` (type ⌥`, then e)
    • Accent grave (è) through dead-key ⌥' (type ⌥', then e)
    • Accent circonflexe (â) through dead-key ⌥^ (type ⌥⇧6, then a)
    • Tilde accent (ã) through ⌥~ dead-key (type ⌥⇧`, then a)
    • Strikethrough letter (ø) through ⌥/ dead key (type ⌥/, then o). This works only for a small handful of letters.
    • typographic quotes for English (“”, ‘’), French («»), and German („”, ‚’)
    • Spanish punctuation marks (¡¿)
  • Lots of useful typographic (©, ¶, §, …) and scientific (𝟙, Å, ∞, ×, ⊗, …) symbols.

    • ⌥- and ⌥⇧- produce an en-dash and em-dash, respectively.
    • ∑ and ∏ are symbols for sum and product respectively (not upper case sigma and pi, see below).
  • Support for overbar (a̅) through combining macron diacritical mark (type a then ⌥5). Useful for indicating e.g. a complex conjugate.

  • Support for hat (Ô) through combining circumflex diacritical mark (type O, then ⌥⇧6, then ⇧6 or .). Note that this is a different unicode character from the Ô that is obtained directly through ⌥⇧6, then O. The combining diacritical mark can be used in combination with any letter, while there are only a fixed number of direct accented characters. I use the combining circumflex diacritical mark only for hats in math notation.

  • Support for sub-scripts and superscripts through the dead-keys ⌥z and ⌥Z, respectively. E.g., type ⌥z, then 0 for ₀ and ⌥⇧z, then 0 for ⁰. Only digits, parentheses, and a small number of letters are available as sub-/super-scripts.

  • Full Greek alphabet through dead-key ⌥f. E.g. type ⌥f, then x for χ; or ⌥f, then W for Ω. There’s no special mnemonic for ⌥f – it’s just easy to type. The full layout looks like this:

    Keyboard layout greek

    with equivalent upper case. Note that e.g. upper case alpha (Α) is not the same unicode letter as (Latin) upper case A. Some of the more frequently used Greek letters are also available directly, e.g. π as ⌥p.

  • Full double-strike math alphabet (ℂ) through dead-key ⌥M (type ⌥⇧m, then C). This works for all digits, lower case and upper case letters (even though most of these probably aren’t very useful).

You can install the keyboard layout by downloading

USScience.bundle.zip

and placing the resulting bundle file either in /Library/Keyboard Layouts (system-wide installation) or ~/Library/Keyboard Layouts (user installation). You can also open the bundle in Ukelele and use the “Install” option from the “File” menu (and of course adapt the layout for your needs).

After installation, the layout should be available in the Keyboard System Preferences, in “Input Sources”, as “U.S. International - Scientific”.

Bonus tip: for figuring out what exactly a given unicode character is in the keyboard layout, type it out in Vim with the characterize vim plugin installed, put the cursor on top of it, and us the ga command.



Comments

No comments

You may format you comment with Markdown. If your comment is a valid contribution, it may be posted on this page. Your email address will not be made public.