Saturday, October 23, 2010

Typing mathematical characters in X

Unicode provides many useful characters for mathematics. If you've studied the traditional notation, an expression like « Γ ⊢ Λt.λ(x:t).x : ∀t. t → t » is much more readable than an ASCII equivalent. However, most systems don't provide an easy way to enter these characters.

The compose key feature of X Windows provides a nice solution on Linux and other UNIX systems. Compose combinations are easy-to-remember mnemonics, like -> for →, and an enormous number of characters are available with just a few keystrokes.

Setting it up

I cooked up a config file with my most-used mathematical symbols. With recent Xorg, you can drop this file in ~/.XCompose, restart X, and you should be good to go.

The include line will pull in your system-wide configuration, e.g. /usr/share/X11/locale/en_US.UTF-8/Compose. This already contains many useful characters. I was going to add <3 for ♥ and CCCP for ☭, but I found that Debian already provides these.

GTK has its own input handling. To make it defer to X, I had to add an environment variable in ~/.xsession:

export GTK_IM_MODULE="xim"

The "Fn" key on recent ThinkPads makes a good compose key. It normally acts as a modifier key in hardware, but will send a keycode to X when pressed and released by itself. I used this xmodmap setting:

keycode 151=Multi_key

Tweaking the codes

Being boilerplate-averse, I specified the key combinations in a compact format which is processed by this Haskell script.

Obviously, not everyone will like my choice of key combinations. If you tweak the file and come up with something particularly nice, I'd like to see it. If you can't run Haskell code for whatever reason, it's not too hard to edit the generated XCompose file.

Though my use of Haskell here may seem gratuitous, I actually started writing this script in Python, but ran into trouble with Python 2's inconsistent treatment of Unicode text. Using Haskell's String type with GHC ≥ 6.12 will Just Work, at least until you care about performance.


If you don't like this solution, SCIM provides an input mode which uses LaTeX codes.


  1. When I want to write Unicode characters in text files, I'm very fond of emacs Tex input-method. It can be activated with `M-x set-input-method` or `C-x Enter C-\`, and then by selecting `TeX`.

    It allows to write UTF8 characters by using their TeX name : for example typing `\lambda` in an emacs buffer with the TeX input method will produce the `λ` character. Not all character are accessible (all UTF8 characters can be inserted by their unicode name with `M-x ucs-inert`), but the coherent TeX naming is very nice.

    I have used it to write simple text files about type systems that have near-LaTeX readability.

  2. Another satisfied Compose-C-C-C-P customer. :D

    Great post. I've been meaning to write something like this up. I've also been meaning to look into better synchronizing Gtk+ and X's ideas of the compose table, but it's hairy and fraught with backwards-compatibility woes. I think it would also be neat to have a graphical compose sequence viewer, maybe integrated into the Gnome character map. (So, you hunt for a symbol, find it, and there's a hint saying “to type this character, press …” or an “add a shortcut for this character…” as appropriate.)

  3. I suppose this isn't very useful to non-CJK speakers, but... on Windows, you can achieve the same thing using the IMEs (eg. the Japanese IME). FYI.

  4. Jio Giga Tv
    ohh really your post is Amazing...
    I enjoyed your content

  5. food ordering app india
    hello today i Reached ypur site and I find your site speed is so Amazing and posts are wow

  6. Hey,
    Thanks for sharing this helpful & wonderful post. i really appreciate your hard work. this is very useful & informative for me.
    thanks for sharing with us. thanks a lot.

    vMix Crack is the vision mixer software that available in the window operating system. This software produced by StudioCoast PTY LTD. stable release of this software is Witten by VB.Net language. The operating system required by this software is window 7 and another later window. software launch in IA-32 and x86-64.vMix an available at least 9 languages German, English, Spanish, French, Japanese, Korean, Portuguese, is like live streaming software. License use trialware. The website used to publish this software is vMix.

    Cinema 4D Crack is a useful place where you can easily find Activators, Patch, Full version software Free Download, License key, serial key, keygen, Activation Key and Torrents. Get all of these by easily just on a single click.

    Virtual DJ Pro 2020 Crack is all good, for anybody to place a flaw. It has tabbed playback, which enables you to make and save samples special buttons and has several different sound editing purposes and permits one to edit just two monitors in real-time to earn a stay mixture. Virtual DJ Serial Number includes a lot of sound instruments, builtin effects on that I’ve written previously may produce your paths of these MP3 songs records from the player that is built-in.

    Adobe Acrobat Pro Dc Serial Key, comprises a completely free app that allows you to combine and ship PDF files.

  11. gta 2 free downloads
    Grand Theft Auto II Pc Download: an famous action, adventure game. DMA Design developed Grand Theft Auto 2 Torrent. Rockstar Games published GTA 2 Torrent. It is the sequel to the earlier released game Grand Theft Auto 1997 in the GTA Games Series. GTA 2 Free Download Full Version Pc Game Highly Compressed features both single player as well as the multiplayer gameplay modes. The players can explore the game world by foot or by the use of vehicle.


  12. bhai content tgda likhe ho …sabse acha apka yeh article lga mujhe ..i really like ur content bro
    The tech tushar


  13. post bahut acha hai ..i really like ur post bro
    The tech tushar

  14. People daily search for many Pc Games on web form different ages and from different parts of the world. Do they find the games of their interest?

    Many famous websites are available to download many games the old ones and the new games too. Pc Games Here is a place where you can find and Download Pc Games Full Version.

    On this site you can find all the games in different catogeries like GTA Games, NFS Games, Car Racing Games, Fighting Games, Cricket Games and Football Games. Some Of The Pc Games are described below.

    I love to play football and this is my favorite game which i play most. You can also visit here for
    The Crew Wild Run Download

    God Of War 3 Pc Game Highly Compressed Free Download

  15. After watching so much tv and eating fast food as well as laying all the day also effect our health so much. So that make us feel tired as well as feeling not good. So you must use several medicines for the eradication of all these type of symptoms. You would love to have this if you want to know about

  16. Before knowing about the process to connect the printer to the computer or other devices, we can see about the ij start canon. Technology Info

  17. Mailbird Pro Crack
    Cracked Here is a useful place where you can easily find Activators, Patch, Full version software Free Download, License key, serial key, keygen, Activation Key and Torrents.

  18. Working with this program is very simple and you just need to select which folder or video file you want to download and after separating it from the area to be edited, review the output results before final storage. This Site

  19. Download the latest Cracks with CracCOol website patch, Serial Key, License Key and Keygen Full Free

  20. Draw your own models with Easy Cut Studio keygen – drawing and design couldn’t be easier! This powerful vinyl cutting software comes with a set of various look and feels tools you need. Easily draw unique shapes, edit signs, edit vector images, create logos, customize the text with all fonts on your computer, plus special effects. Easy Cut Studio will make your design and cut your marks easier than any other cutting plotter Easy Cut Studio serial number on the market today. It is a small design unit for cutting vinyl.

  21. I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. I hope to have many more entries or so from you.
    Very interesting blog.
    Babylon Pro NG Key Crack

  22. PC Software Download
    You make it look very easy with your presentation, but I think this is important to Be something that I think I would never understand
    It seems very complex and extremely broad to me. I look forward to your next post,
    ACDSee Photo Studio Crack
    Easypano Tourweaver Pro Crack
    Easy Cut Studio Crack
    Facebook Video Downloader Crack
    PostgreSQL Maestro Crack
    MediaMonkey Gold Crack
    SuperAntiSpyware Professional Crack

  23. Nice information. I’ve bookmarked your site, and I’m adding your RSS feeds to my Google account to get updates instantly. WM Capture Crack

  24. รวมไอเดียตกเเต่งบ้าน ไอเดีย DIY ตกเเต่งสวนหลังบ้านให้สวยงามได้ง่ายๆ เชิญทางนี้ shanalya เว็บไซต์ที่ใจใครหลายๆคนอย่างเเน่นอน รวมเทคนิคในการตกเเต่งบ้าน รวมบ้านหลากลหายสไตล์ ไอสวนหลังบ้านหลากหลายเเบบ รวมไว่ที่นี่เเล้ว เว็บเดียวจบบครบเรื่องบ้าน.

  25. Thanks For Allowing us to Share Our Views In This Blog. Share PcsCrack With others.
    free email extractor registration key

  26. Thanks For Allowing us to Share Our Views In This Blog. Share With others.
    clave avast driver updater

  27. You make it so easy to do with your presentation, yet I think that this issue is something I can't fully understand.
    It appears to me too intricate and too broad. I'm looking ahead to your next position, I'll attempt to hold it!
    corel draw x7 serial number
    synthesia key crack
    bandicam serial number
    plagiarism checker x 6 free download with crack

  28. Gutt Websäit : Zonahobisaya
    Gutt Websäit : Zonahobisaya
    Gutt Websäit : Zonahobisaya
    Gutt Websäit : One Piece
    Gutt Websäit : Zonahobisaya
    Gutt Websäit : Zonahobisaya
    Gutt Websäit : Biodata
    Gutt Websäit : Zonahobisaya

  29. Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work. kutools for excel crack free download

  30. wow99 slot พร้อมให้บริการเกมสล็อตที่เต็มกำลัง แหล่งพนันสล็อต wow99 จัดมาทุกชนิดทุกสไตล์ที่พร้อมทำให้นักเล่นการพนันทั้งหลายแหล่ในแวดวงพนัน pgslot ปั่นสล็อตแบบมือโปรง่ายมาก

  31. ทดลอง เล่น สล็อต pg ฟรี เริ่มต้นการเดินทางที่น่าตื่นเต้นด้วย และค้นพบโลกของเกมสล็อตฟรี PG SLOT เรียนรู้เกี่ยวกับเชือก สำรวจเคล็ดลับ และค้นหาคำตอบของคำถามที่พบบ่อยในคู่มือฉบับสมบูรณ์นี้คุณพร้อม