Monday, March 26, 2007

Ergonomic Keyboard Layout for LaTeX Authoring

Inspired by Lasse Kliemann, I am trying to build a new keyboard layout for LaTeX authoring. Lasse Kliemann has produced a very easy to use keyboard layout for LaTeX symbols.

If you have written some LaTeX code, you certainly know that LaTeX requires lots of symbols like {\}([]$. These characters are hard to type because firstly they reside in far places on the keyboard, secondly they usually require modifier keys in combination. Lasse's solution is to set space-bar as a modifier. The symbols are bound to usual alphabetic characters on the keyboard. So using a key combination like space-s produces {. Both keys "space" and "s" are very easy to type in combination.

I wondered whether Lasse's keyboard layout is the optimum layout for LaTeX authoring. He actually designed the layout for other programming tasks as well like HTML and C authoring. So I wrote a program in Groovy that measures the character statistics in a given tex file. Here is the code:

map = [:]
new File('poisson01.tex').getText('utf-8').each {
if(map[it] == null)
map[it] = 0
map[it] = map[it] + 1
def keys = map.keySet().findAll{ !(('a'..'z').contains(it) || ('A'..'Z').contains(it)) }
def frequencies = map.subMap(keys)
def characterList = frequencies.keySet().toList()
characterList.sort { frequencies[it] }

characterList.reverse().each {
println it + ' ' + frequencies[it]

Here is the output of a run:

\ 893

{ 388
} 387
( 222
) 220
= 207
$ 155
_ 112
[ 110
] 110
. 99
1 90
ı 81
^ 80

So the various parentheses are the mostly used characters. But this is just one latex file. For better design optimization, one should use a randomly selected set of LaTeX files.

No comments: