TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With the goal of making the latex source easier to parse, I was wondering if one could (locally or globally) disable the latex default behaviour of creating a new paragraph when it encounters an empty line.

Obviously, I can always just put a % on empty lines when I don't want a paragraph. Nevertheless, I was wondering if there is a different solution.

Finally, I would also like to know if such an alternative solution would be considered good form or not.

share|improve this question
up vote 10 down vote accepted

The blank-line-gives-new-paragraph mechanism works on a lower level than LaTeX; it is TeX. You may want to read sections 2.5 and 2.9 of TeX by Topic. There are basically two possibilities, both of which should certainly be confined to a group.

  1. Redefine \par, for example \let\par\relax
  2. Redefine \endlinechar to be 32, so that the actual (platform-dependent) end-of-line-marker(s) are replaced by a space token. You can also set it to some value outside the range 0-255, meaning that nothing will be inserted in the input stream.

In both cases, note that if a line ends with a control sequence, one has to take care of spaces in the output. You can also mess around with catcodes, but I'm not sure what would be gained by this compared to 1. and 2 (except perhaps that the space-issue would be easier to solve).

This said, to answer your final question: No, I certainly don't think it's a good idea. In code that no one but you will see you can of course do anything, but as soon as you need to collaborate on some projects, tricks such as these can cause quite a lot of confusion. The standard way of increasing readability while preventing insertion of \par tokens is the one you describe. The % doesn't actually have to appear as the very first character; spaces before it are automatically ignored. This can be useful if you use indentation inside environments:

  something &= some complicated expression \\
  other &= more complicated stuff
share|improve this answer
And to add to the advice part, with decent syntax highlighting, a line with just a % on it can be rendered almost blank so the readability is not affected. After reading a lot of source code, a line with just a % on it will seem like a blank line in any other language. – Loop Space Apr 23 '11 at 20:12
Regarding your comment about catcodes: A third way is to set the catcode of ^^M to 9 (ignore). See this answer – Lev Bishop May 2 '11 at 6:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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