Tons of improvements to TeX snippets

(rebased by Marc Weber), pull/182