4

This is a follow-up to this question on commenting out empty lines vs. \noindent. Given that I have now begun commenting out lines surrounding environments like this:

\documentclass{article}

\begin{document}

Some body text. Let's introduce a quote:%
%
\begin{quote}
Some quote text.
\end{quote}
%
Some text following the quote.

\end{document}

I wonder whether there is any harm in commenting out all empty lines not serving a TeXnical purpose in my source, like so:

\documentclass{article}

\begin{document}
%
Some body text. Let's introduce a quote:%
%
\begin{quote}
Some quote text.
\end{quote}
%
Some text following the quote.
%
\end{document}

I vaguely remember reading a question a while back where it was noted that you might hit something like a character limit on comments (maybe someone can point me to that again?) in longer documents, which might be something to worry about.

Are there any downsides to commenting out TeXnically unnecessary empty lines in my source?

  • 3
    The second biggest downside is -- that is, aside from accidentally 'commenting out' a line that should be empty -- is that it is a waste of time that scales with the size of the document. – jon Mar 19 '14 at 19:52
4

Comments on empty lines technically join paragraphs if there are no explicit paragraph breaks inserted manually. So, if there are no explicit paragraph breaks inserted (for example, in some environment definition), then you run the risk of exhausting TeX's memory (as mentioned in Components of (La)TeX's memory usage). That is, TeX would just gobble the input stream in order to gather content for a paragraph (with the ultimate goal of optimizing it for presentation)... but if this paragraph "never" ends, then also will your patience. However, this is surely unlikely in most cases and therefore very extreme.

Note though that while comments of seemingly unnecessary empty lines may be what you're after, the output may differ:

enter image description here

\documentclass{article}

\begin{document}
%
Some body text. Let's introduce a quote:%
%
\begin{quote}
Some quote text.
\end{quote}
%
Some text following the quote.

\noindent\hrulefill

Some body text. Let's introduce a quote:%
%
\begin{quote}
Some quote text.
\end{quote}

Some text following the quote.
%
\end{document}

In the above example, Some text following the quote is considered to be in the same paragraph that started before the quote started due to the %, hence no paragraph indent. In the second, the empty line represented a paragraph break, causing the expected paragraph indent.

  • Yes, not commenting out empty lines where I want a paragraph break is exactly the sort of thing I was considering "TeXnically necessary". So is the take-away here that if I'm doing this in a way that turns my documents into one very long paragraph then I might run into issues, but no other worries seem to be pressing? – Dennis Mar 19 '14 at 20:08
  • 2
    @Dennis: Yes, but it may also be that you're not going to be consistent, since this is a human-based "intervention" that uses something already seemingly ambiguous to the lay-user of TeX. As in, "why do you put % here, but not there?" If one does it in the code in a specific area to separate concepts visually in the code, yet have them amalgamated in the output (like making a local redefinition of a macro, say), then it's completely fine in my opinion. But lengthy use of it is prone to error. – Werner Mar 19 '14 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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