Refactor LaTeX template