Add --tex option, refactoring, documentation