It seems that hard-wrapping – i.e. inserting a newline when the line reaches a certain threshold – is extremely common in the LaTeX source when writing technical papers, either by manually inserting it or by letting the text editor take care of it.
After years of writing text in soft-wrapping environment (text is displayed wrapped, but no newline is actually inserted), I find it hard to understand why hard-wrapping is so commonly used. I think understanding the reason(s) behind it will make me less resentful about using it.
What are the disadvantages and advantages of using hard-wrap vs. soft-wrap, and why is hard-wrap so commonly used with LaTeX?
Best Answer
Many text-comparing tools like
diff
use line-by-line comparison. This can be explained by their origin as programmers' tools. When lines are short enough, these tools work well with TeX sources - especially when combined with version control systems. Of course, there are tools likelatexdiff
(highly recommended!), which do not take into account line lengths.Also, since TeX comments start from % and continue to the end of line, short lines make easier to comment the code.
Last but not least, many TeX authors use programmers' editors like
Emacs
orvi
, which use hard line wrapping. This makes the code more readable - and TeX source is primarily a code.Anyway, TeX itself, of course, does not care about your line length.