TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

Is the following expected:

% why is my percent sign gone?
\relax % not here

missing percent

share|improve this question
ltxdoc is designed for dtx files where all the document is prefixed by % (including verbatim sections). – David Carlisle Dec 19 '12 at 17:38
sigh... I recently started writing my dtx files in a manner which avoids to have to prefix all the lines with a % and this is why I only now realized the gobbling up of % signs at the beginning of lines. Doubling it %% leaves a survivor, which is fine for me. – jfbu Dec 19 '12 at 18:07
up vote 8 down vote accepted

Class ltxdoc is a LaTeX class for typesetting the documentation in .dtx files. The class loads package doc that does most of the work including the definition of environment verbatim. In .dtx files the documentation lines usually starts with % to get ignored, when docstrip extracts the code. Instead of

% why is my percent sign gone?
\relax % not here

the common use case is rather:

%verbatim stuff that should be set without the
%percent signs at the start of the lines.

Therefore package doc modifies verbatim to ignore the percent sign at the start of a line. This is done by macro \check@percent that can be redefined locally:

% percent sign
\relax % and here
share|improve this answer
Thanks, I had not paid attention to that redefinition of verbatim by doc until today when I converted an old dtx of mine to a new manner of setting up things where I still use ltxdoc (or scrdoc) but do not have to comment out the user-manual part, only the source code comments. Replacing % by %% gives me an acceptable work-around in the verbatim blocks and doing \let\check@percent\relax is still better, thanks. – jfbu Dec 19 '12 at 18:12

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.