Improve wrapping for tex and markdown