29

What approach is recommended regarding line breaks when writing paragraphs of LaTeX?

  • Should a new line be started at the end of each sentence?
  • Is it better to manually start new lines or to let the editor wrap the line?

No doubt such decisions have implications for version control, debugging, collaboration, automaticity of writing, and so on.

What is considered good practice? Or is it a completely personal decision?

Let me know if this should be community wiki.

3

3 Answers 3

22

It is pretty much a personal decision. For myself, being a heavy user of version control systems, I tend to start every sentence on a new line. More than that, I try not to split any phrase across a linebreak. This makes diff output vastly easier to read. From this viewpoint, just about the worst thing you can do is to edit a bit of text in the middle of a long paragraph, then make your editor reflow the whole paragraph (M-q in emacs).

Of course, once you have collaborators, it becomes a matter of fine diplomacy to have your collaborators adhere to the same discipline. If they are not using version control themselves, it may be hard to convince them that such policies have any value.

20

git supports word-by-word diff's as shown by http://idnotfound.wordpress.com/2009/05/09/word-by-word-diffs-in-git/. The article provides some useful insights in using it together with LaTeX. And of course there is wdiff, a GNU program for word-by-word diff, to be used in conjunction with other versioning software.

I don't feel the need for explicit diffs' when typing LaTeX, so I just use svn without any special line breaks per sentence. But I do feel the need to let this useful tool to be known :).

0
7

As a version-control junkie, I subscribe to the view that (single) line breaks are the way of telling diff what I want to see if something changes. Usually, this means one-sentence-to-one-line, since if something changes in a sentence then I want to see the whole sentence, but I don't want to see the whole paragraph. But sometimes it is a little finer than that: if I have a particularly complicated bit of inline maths then I'll separate that out using line breaks so that I can see if it's something in the maths or in the surrounding sentence that changed.

I use Emacs with longline-mode enabled so when editing a document, I get all the functionality of line-wraps (and paragraph reflows) with none of the grief from finding that I've messed up all my nice formatting.

When I converted to VCS, I had a lot of documents that were wrapped badly so I wrote a script (called fmtlatex) to convert them to one-sentence-to-one-line mode. It's also linked off this page (see Stage Two) which I wrote when making the switch.

5
  • You recommend in your page to use longlines-mode. For me it seems to break the TeX-Sync. Did you experience this? BTW: it doesn't happen with visual-line-mode.
    – Dror
    Mar 2, 2013 at 9:04
  • @Dror What is the "TeX-Sync"? Mar 2, 2013 at 18:43
  • My bad... SyncTeX - the LaTeX PDF synchronization tool.
    – Dror
    Mar 2, 2013 at 19:56
  • @Dror Don't use it so wouldn't know anything about it. Soory. Mar 2, 2013 at 23:46
  • @AndrewStacey Is there any chance your fmtlatex perl script would be converted to lua some day (sorry, no perl skills here...)? The reason is that lua is always present as soon as luatex is.
    – cjorssen
    Jun 9, 2014 at 22:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .