I am very new to LaTeX.

A newline in the input file does not mean anything to LaTeX. An empty line in the input file means a new paragraph.

Trouble is, when I view my sources with different text editors on different displays, they look very different (and always bad). So I find myself chopping lines to the about 80-th character or so.

This brings the MS Word problem - introduce a line, or even a single word, and you need to edit the whole following paragraph in order that it is nicely positioned on the display (talking about the .tex file).

Using --soft-wrap wraps lines around, but is not pleasing to the eye, plus a single move of the cursor could scroll a whole screen - hardly intuative.

How do I write .tex source file, so that anyone - using an IDE or just any editor, can view and edit them comfortable?

  • 4
    basically you shouldn't worry about it. I usually set my editor to insert a (hard) newline somewhere around column 75 but if I edit text and the lines get longer or shorter it doesn't matter (although fill-paragraphs command would re-wrap the file if I wanted to tidy it up before sending to someone. – David Carlisle Feb 18 '14 at 21:41
  • 1
    not a definitive answer, but on this web page are the recommendations we give to tugboat authors to make our life as editors as painless as possible. (note that some of these recommendations are very tugboat-centric, and not necessarily applicable to other publications.) – barbara beeton Feb 18 '14 at 21:41
  • When they deserve it!! Bwaha – percusse Feb 18 '14 at 22:29
  • 1

Third way is my personal preference. It is helpful for diffs and if you use a repository to keep track of your code. Then let your editor soft wrap long sentences.

  • This sounds like a very logical and clean solution. I'll try it out! – Vorac Feb 19 '14 at 9:12
  • +1 One sentence, one line! This is semantically correct and can be valuable if you put your source code under versioning control! – Dror Feb 19 '14 at 11:42

I use an editor with word wrap on. If you're using Windows, Notepad++ is great. In Linux there are many great editors, but even gedit automatically wraps lines. If you're using Eclipse, its soft-wrap feature is kinda buggy and I never really found it very well suited to Latex editing, but it's still better than hard-wrapping, because as you said, you have to redo it any time you change to a different screen size (and doing so wreaks havoc on the diff of any version control you might be using), which is tedious.

TLDR: best practice in this is, imho, to let your text editor soft-wrap the lines for you.

  • I am tempted to accept your answer as least evil alternative. Two problems remain. 1) on a non-configured editor, lines will be very ugly. 2) Navigating with the arrow keys becomes significantly more difficult - pressing down can scroll 10 lines or only 1. Moving to the middle of the paragraph is far worse - here the End key is no rescue to us. – Vorac Feb 19 '14 at 8:34

Use something like emacs+auxtex. It's got a keyboard shortcut for formatting paragraphs, regions and sections, i.e., it does nice line breaks and indenting.

Not the answer you're looking for? Browse other questions tagged or ask your own question.