9

After fleshing out (with my own project) Joseph Wright's lovely model, I've noticed that the explicit control character ^^A is used at the end of some lines. Its use appears similar to that of % to ignore trailing spaces, but I don't know why ^^A would be used instead (if this is indeed its purpose) or why % wouldn't work anyway.

  • 2
    It's the way to refer to invisible ASCII characters. Read dangerous bends (and double-dangerous bend) on page 45 of the TeXbook. – Gonzalo Medina Jun 20 '13 at 2:58
  • Is that file really mine? I don't recognise it (that doesn't mean it isn't mine:-) – David Carlisle Jun 20 '13 at 8:26
  • @DavidCarlisle - mis-attribution -- It would appear to be Joseph Wright's demo DTX (I'll edit.) – Sean Allred Jun 20 '13 at 12:13
  • @DavidCarlisle David is not the author of that file, but he's the author of the ltxdoc.cls document class which is widely used for making documentation of LaTeX source files. – karlkoeller Jun 20 '13 at 15:05
  • @karlkoeller Probably where I made the correlation. (Am I the only one who thinks it's awesome that SE networks make it possible to have this kind of interaction?) – Sean Allred Jun 20 '13 at 16:26
8

If ^ has its usual superscript meaning then ^^A is built-in primitive TeX syntax for the non-printing character control A (that is U+0001) 64 less than A. This is just an arbitrary character that Frank chose as being unlikely to be used elsewhere. The important thing about it in this context is that doc.sty does

\catcode`\^^A=14
\AtBeginDocument{\catcode`\^^A=14\relax}

Catcode 14 is comment (the usual catcode of %) This allows you to put comments in the documentation section of a dtx file, where % is set to catcode 9 so that it is ignored by TeX and does not make a token at all.

6

In .dtx files the sequence ^^A replaces the standard % to introduce comments.

.dtx files are usually processed through doc and docstrip which don't consider % a comment.

In fact, when you run latex (or pdflatex) on a such structured .dtx file, it is actually evaluated twice. The first time, only a small piece of driver code is evaluated. The second time, comments in the .dtx file are evaluated, as if there were no % preceding them.

I suggest you to read this very interesting dtx tutorial for more information.

Moreover, don't forget to take a look at the original documentation on ltxdoc, doc and docstrip.

  • 4
    Exactly how a .dtx is read when you send it to latex depends on how it's set up. It's likely that the .dtx includes a driver, but that is not required (the design of the .dtx format means it's possible to have a very simple file which can be used directly, although this is not so common). – Joseph Wright Jun 20 '13 at 6:19
  • @JosephWright What you say is right, I was trying to explain how they are designed usually. – karlkoeller Jun 20 '13 at 8:05
  • I figured that ^^A was acting as a comment flag, I just didn't really know how or why. Thanks for the links, though! Further reading is always useful and appreciated :-) – Sean Allred Jun 20 '13 at 16:27

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.