This is from http://tex.stackexchange.com/a/53754/5645 - an answer from [anton](http://tex.stackexchange.com/users/14063/anton) and [Jake](http://tex.stackexchange.com/users/2552/jake) The Python script got improved by Martin Thoma