Take the 2-minute tour ×
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.

I've noticed that many (all?) style and class files have "documentation blocks" with a double comment character at the beginning of the line,

%% like so

instead of the usual style of comments,

% like so

Why is this done? Do some kinds of comments need the %% for some preprocessing/automatic documentation generation/etc. - or is it just customary? Should I mix %% and % in the same file for different uses?

(Specifically, an answer to Make your own .sty files suggests single-comment-char comments, which added to my confusion.)

share|improve this question
3  
For a reference specifically to .dtx files, see the UK TeX FAQ entry on Documented LaTeX sources (.dtx files). –  Werner Dec 28 '11 at 17:19
add comment

2 Answers

up vote 35 down vote accepted

Many classes and packages are written using docstrip which strips all normal comments from the file and can combine or split material to different files. Comments with two percent characters are called meta-characters and are not stripped but written directly to the class or package file itself. Therefore you won't find full-line single-% comments in these files. Besides this there is no difference between both comments. See the docstrip and dtxtut manuals for more information.

share|improve this answer
add comment

There's no built-in different behavior between %% and %; but as a consequence of how the docstrip works in extracting the code from a documented source .dtx file, usually the prolog and the final lines start with %%.

Of course one can use differently marked lines for preprocessing, but from a pure TeX point of view, those lines are perfectly equivalent.

I sometimes find it convenient to use multiple % character to mark particular spots of a document, as opposed to simple comments, to do searches more easily; for example, commands inserted in the final revision to adjust line or page breaks, or special reminders in general:

text where something special
%%% Inserted a page break, check the output!
\pagebreak
%%%
has been inserted to get a better page break

Thus it's possible to check all special things (which can be different from \pagebreak by searching for %%%. One can devise various marking schemes based on the fact that lines starting with % are ignored.

share|improve this answer
    
So there is no convention of where to use single or double % that compares to the conventions of comments in Lisp? –  N.N. Dec 28 '11 at 17:27
5  
@N.N. There is in the .dtx format, but not in TeX proper. Also in PostScript %% is different from %. –  egreg Dec 28 '11 at 17:32
add comment

Your Answer

 
discard

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.