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.)


2 Answers 2


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.


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!
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.

  • 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, 2011 at 17:27
  • 7
    @N.N. There is in the .dtx format, but not in TeX proper. Also in PostScript %% is different from %.
    – egreg
    Dec 28, 2011 at 17:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .