automating latex functions which are usually tedious