The ltxdoc class, designed for documenting LaTeX source files, is based on the article class. Beyond a certain threshold, the documentation may need to be divided in chapters and another class, e.g. the report one, would be more appropriate.

Hence my question: is there a way to document LaTeX source files using the ltxdoc class but with report as underlying class? Or is the best way to build the documentation in a separate document where the class can be chosen?

  • 1
    You could just save ltxdoc under a new name and change the LoadClass command accordingly, if you are interested in a simple hack. – Johannes_B Dec 17 '13 at 15:25
  • 1
    Or using package scrlfile you could use \ReplaceClass{article}{report} – Johannes_B Dec 17 '13 at 15:27

You can use scrlfile from KOMA-script.


That gives me the following

*File List*
scrlfile.sty    2012/06/15 v3.12 KOMA-Script package (loading files)
  ltxdoc.cls    2007/11/11 v2.0u Standard LaTeX documentation class
  report.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
     doc.sty    2010/02/04 v2.1e Standard LaTeX documentation package (FMi)
multicol.sty    2011/06/27 v1.7a multicolumn formatting (FMi)

Unfortunately, as soon as a \maketile command is run, everything breaks. There is a pretty simple reason for that. ltxdoc loads the package doc as well, which is redefining maketitle. This way, you can use multiple titles in one document (according to the documentation of doc). Loading package titlepage lets the error dissappear. But there is one drawback: The command \maketitle isn't doing anything now.
But: You can save the original definition of maketitle (by the report class) and later (after doc is processed) you can restore it.

\author{Some one}
\title{some thing}

If you want to do this is for you to decide.
By the way: \BeforePackage is also provided by scrlfile.

  • I wasn't aware of \ReplaceClass from scrlfile and it could help me in another contexts but, unfortunately, it is clashing as soon as \maketitle command is used. – Denis Bitouzé Dec 17 '13 at 15:48
  • The hack proposed by me doesn't work as well. I'll have a look at it. Hopefully, i can figure out what's going on. – Johannes_B Dec 17 '13 at 16:16
  • @DenisBitouzé I updated my answer, i hope it is helpful. – Johannes_B Dec 17 '13 at 17:06
  • Your edit was indeed helpful. I am nevertheless surprised that anything simpler doesn't exist since years ltxdoc class is used. – Denis Bitouzé Dec 17 '13 at 17:24
  • @DenisBitouzé Maybe there is something simpler, and we just don't know it? ;-) – Johannes_B Dec 17 '13 at 17:25

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.