For the sake of readability I like to put a blank line before a new environment starts. In the particular case I'm considering, the blank line adds some vertical space between the item from the first level enumerate and the first item from the second level enumerate.

So my question is: is there a best practice to format code related to blank lines before environments start? Should I avoid it? Should I comment out the blank line?

Clarification:

I'm talking about the vertical space between "test text" and "1". But, I'm not asking for a way to remove the extra space added by the blank like, I already know how to do that. My reasoning is the following:

Since adding a blank like before a new enumerate adds vertical space, it means that that blank line is meaningful for TeX. Since it is meaningful for TeX, is it OK to use it for the mere purpose of formatting code or should I avoid it?

A blank line signals a paragraph break, which makes sense before and after enumerations as well. To set off your enumeration for visibility, you can use a line containing just a comment character (% at the start of an empty line).
–
alexisDec 16 '13 at 22:30

3 Answers
3

A blank line in TeX input is a command it is equivalent to \par so you should not put it in places where you don't want to start a new paragraph. Like any command, if you want to put it in the source file for some reason, but don't want it to be executed, then you need to comment it out, but generally it's simpler not to put it there in the first place:-)

So the general rule should be: insert a blank line only if you want a \par, right? Forgive the personal question, but do you write your code this way?
–
MasonDec 16 '13 at 22:29

@Mason a blank line is\par it is reported as the \par token by TeX's input scanner before macros see the input. Try putting \show followed by a blank line. TeX will stop and show the token as \par not as an end of line character.
–
David CarlisleDec 16 '13 at 22:34

@Werner yes or simpler without the blank line at all.
–
David CarlisleDec 16 '13 at 22:35

1

@Mason I can't speak on behalf of David, but I do. There are many places where blank line never appears: before any displayed equation (to prevent pagebreak there); in your situation (I always format the code such that one item of the outer list is one block of code, and I never go deeper than 2 lists, it's a nonsense to do it); inside a macro definition (I use explicit \par if I really need it, to avoid later confusion whether it was an intention), ...
–
yo'Dec 16 '13 at 22:36

My opinion is that a blank line shouldn't be there, unless you want a new paragraph to start. In the generality of cases (tabular and array are exceptions) a blank line in LaTeX is significant and should not be used just to enhance readability of the source.