sort latex commands and environments