Encode characters for LaTeX formatting
