# Good keyboard layouts for typing (La)TeX

When typing (La)TeX some keys are used a lot more often then in plain text, especially \, {, }, [, ], $, ^ and _. On most keyboard layouts these keys are rather cumbersome to type. The English QWERTY keyboard is a lot better than the German QWERTZ, but is still far from optimal. Given that I mostly type mathematical texts in English, what keyboard layout would you recommend? Bonus points for the following: • Ability to type non-English Latin characters, especially German umlauts. • Some similarity to QWERTZ or QWERTY as I'm most used to these layouts (I currently use the US-International layout from Linux) • Ability to type math symbols directly (Greek letters, \times, etc.) - If you're a Mac user, you might be interested in this answer, which describes how I made a custom keyboard layout full of math symbols, greek letters, and so on. – John Wickerson Apr 22 '13 at 20:47 And if use Linux, you can be interested in this article in my blog... rlog.rgtti.com/2014/05/01/… --- HIH! – Rmano Sep 18 at 11:41 ## 13 Answers Since you're asking for german umlauts: There is the Neo layout which is for german language. The wiki sounds rather interesting! There are even pages for TeX. (I have not used it myself, though). http://wiki.neo-layout.org/wiki/ and http://wiki.neo-layout.org/wiki/Neo%20f%C3%BCr%20Latex - Looks interesting, though it might take some time to learn to use it efficiently. – Caramdir Aug 18 '10 at 19:22 Layouts like that ask for a keyboard that can alter their own appearance while you are learning te new layout, like this one: artlebedev.com/everything/optimus Horribly expensive, unfortunately – Taco Hoekwater Aug 18 '10 at 21:03 Horribly expensive and without Linux support :( – Caramdir Aug 18 '10 at 21:51 I seems I never accepted any answer here. Since I ended up using Neo, I'm accepting this answer. Together with unicode-math Neo makes typing LaTeX more fun and produces more easily readable code. – Caramdir Nov 14 '10 at 17:10 @Martin: Maybe US International can be of use to you. Except for swapping Y and Z and the umlauts, the letters are in the same place as in QWERTZ, but the special keys are somewhat easier to reach. – Caramdir Mar 18 '12 at 16:19 I now use a czech programmer keybord (custom made) which has the special symbols in the english number row accessible by using right alt and the rest of important symbols ({}[]\/=) are on the home row (ASDF...) again with right alt. Very convenient. - Long, long ago in a galaxy far, far away, I attempted starting a blog. It didn't last, but one of the things I posted was about this very subject. When I deleted the blog, I kept the articles. So here's that one. I apologise for the length. A few years back I started to get what I think was RSI in my hands. I never got it officially diagnosed so I can't be sure, but all the symptoms seemed clear. It was worse when I was typing, and worst in my little fingers. Think about typing. How much work do the little fingers do compared to the others? As well as having their own letters, they also work many of the punctuation characters and the shift (and control) keys. I found I was often having to stretch my hand to type characters and this was putting a lot of strain on my little fingers. It's even worse when typing LaTeX documents. A quick scan through a thirty-page paper reveals that the five most typed characters are: • space 15525 • e 7266 • \ 6834 • o 5476 • t 5470 There then follow a few more lowercase letters, in 14th and 15th place are the parentheses (worryingly not the same number of each - must have some half-open intervals in there). 22nd is the underscore, 24th and 25th are the curly braces (quick check: the same number this time) with just over a thousand occurrences. The first number, 1, is way down the list with only 362 appearances. By the way, if you want to generate this list, there are probably more elegant ways but here's my two-minute hack: ~% cat paper.tex| \ perl -lne 'while ($_) {
$_ =~ s/(.)//;$count{$1}++}; END { @chars = sort {$count{$b} <=>$count{$a}} keys %count; while (@chars) {$c = shift @chars;
print "$c$count{$c}"; } }'  The backslash key is often hard to stretch to, the curly braces usually require shift (or Alt-Gr on some international keyboards). That's a lot of work for what is, as far as catching mammoths is concerned, something pretty useless. My solution was to modify the keyboard. No, not with a hammer. With a nifty little program called xmodmap. This is a UNIX program which allows you to modify what the keys on the keyboard actually do. I use it to put the backslash where the semi-colon is (after all, who uses a semi-colon these days?), swap the curly braces and square brackets, and swap the numbers with their symbols (so pressing '3' produces '#' and 'Shift+3' produces '3'). Unfortunately, this method isn't very portable and I have to set it up for each machine. The problem is that it is a translation table from what the keyboard currently does to what you want it to do, so you first have to know what it currently does. However, it's fairly simple to explain how to set it up. Suppose you want to put the backslash where the semi-colon is. First you need to find the keycode for the semi-colon. There are two ways to do this. Firstly, from a terminal run a program called xev. When you press a key in its window, it tells you lots of information about it in the terminal - including the keycode. The other way to do it is to run xmodmap -pke. This produces a list of all the current assignments from which you can read off the keycode for the semi-colon. ~% xmodmap -pke | grep semicolon keycode 47 = semicolon colon oslash Oslash  (Yeah, I'm on a Norwegian keyboard.) Now you just need to remap that: ~% xmodmap -e 'keycode 47 = backslash colon oslash Ooslash'  Lo and behold! Keyboard modified. Three things to note. Save the initial output of xmodmap -pke since if everything goes wrong typing: ~% xmodmap original_list  will reset it (though that might be difficult if you've reset all the keys! In that case, log out and log back in again). Secondly, to save you typing in all those commands every time, you can put them all in a file called, say, .xmodmap and put a line xmodmap ~/.xmodmap in your startup file. Gnome actually goes looking for these files and asks if you want to load them so you don't need to put them in your startup file. The final point is that you might want to consider having different keyboards for different tasks. I have a keyboard for writing LaTeX documents and a "normal" one for everything else; switching between them is easy using "hot keys". Several years after figuring this out, I discovered that I was alone neither in the problem nor in the solution. Greg Kuperberg has also written about this, though his solution uses XKB rather than xmodmap. Your mileage may vary. Here's the actual layout:  1 2 3 4 5 6 7 8 9 0 _ + ~ ! @ #$ % ^ & * ( ) - =

TAB Q W E R T Y U I O P [ ]
q w e r t y u i o p { }

Ctrl A S D F G H J K L : " |
a s d f g h j k l \ ' /

Shift > Z X C V B N M < > ? Shift
< z x c v b n m , . ;


In addition, the "weird" keys along the bottom are mapped to various modifiers which give me access to other characters (most usually, øæå, as I'm in Norway). This is actually done with a two-stage xmodmaprc: the first stage changes my Scandinavian keyboard into something I'm a little more used to; the second stage does the TeX-related changes. I have one hotkey that starts Emacs and changes the keyboard all in one go!

-
Good post. Could you show the layout you use? (The Gnome keyboard applet has a "show current keyboard layout" command, but I don't know if it works with xmodmap.) –  Caramdir Aug 18 '10 at 19:25
Thank you. Switching shift and normal version of the numbers row is a qood idea. –  Caramdir Aug 18 '10 at 21:50

-