Correctly convert elements with trailing whitespace to LaTeX