Users of the X.Org Server have also the possibility to use
XCompose for multi-key input sequences and (among other things) entering Unicode characters e.g., "
Compose+'+e" for ‘é’ or "
Compose+*+a" for ‘α’.
This method has the advantage to be independent of the user's editors or terminals emulators. Furthermore, the sequence keys can easily be customized. Here is a possible configuration.
Specify your compose key in the default keyboard layout, by setting the
XKBOPTIONS variable (a semicolon-separated list of option components). E.g., On debian, add the following line to your
/etc/default/keyboard if you want the Left Windows Key to be your compose key:
If you do not have the superuser privileges or do not want to set the variable globally, you can also add the following line to your
setxkbmap -option "compose:lwin"
You can now set your own mappings in the
~/.XCompose file. If the pre-defined mappings (
include "%S/en_US.UTF-8/Compose") are not enough, here is
a comprehensive example. The syntax of these mappings is rather intuitive, and it is easy to extend your
~/.XCompose to your own needs e.g.,
<Multi_key> <b> <n> : "ℕ" U2115 # MATHBB N <Multi_key> <b> <z> : "ℤ" U2124 # MATHBB Z
Some GTK and Qt applications (e.g., Firefox or Konqueror) try to redefine their own multi-key input sequences. To make them use your
~/.XCompose instead, add the following lines to your initialization profile (
~/.profile,… depending on your shell and display manager):
export GTK_IM_MODULE=xim export QT_IM_MODULE=xim
Sample XCompose configuration file
It is actually possible to use XCompose without the compose key. Below is a setup which utilizes shortcuts similar to LaTeX, i.e. typing
∀. Note that to insert
\ you have to type
\\ (the author of the file below is unsure how exactly this works, see line 3). Note that it is problematic if you have a shortcut which is a prefix of another shortcut — in this case, you won't be able to insert the prefix shortcut. There is a workaround which involves appending
<space> to your prefix shortcut, e.g. you type
\top to insert
\to to insert
→ (note the spaces after).
include "%L" includes your default XCompose configuration file (on Arch Linux, this is
/usr/share/X11/locale/en_US.UTF-8/Compose when using the specified keyboard layout).
The Wiki does not like Unicode in preformatted texts, making me link to it instead: https://github.com/osense/dotfiles/blob/master/.XCompose (alternate link: http://lpaste.net/169816).
Some of the shortcuts deviate from LaTeX shortcuts. The reasoning behind them may be unclear; I will try to explain some of them.
\impl, short for implication, inserts
\impr inserts implication in the opposite direction, l in
\impl now standing for left and r in
\impr standing for right. Finally,
\impb inserts an implication in both directions:
⇔. There are also times when LaTeX shortcuts are too wordy, e.g.
⊛. I have elected to use Agda-like shortcuts in these situations,
\O* in this case.
This configuration file is also missing many more advanced Unicode characters.