# Make ltxdoc class use report as underlying class

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?

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

You can use scrlfile from KOMA-script.

\listfiles
\RequirePackage{scrlfile}
\ReplaceClass{article}{report}
\documentclass{ltxdoc}
\begin{document}
\section{test}
\end{document}


That gives me the following

*File List*
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.

\listfiles
\RequirePackage{scrlfile}
\ReplaceClass{article}{report}
\BeforePackage{doc}{\let\oldmaketitle\maketitle}
\documentclass{ltxdoc}
\author{Some one}
\title{some thing}
\usepackage{blindtext}
\let\maketitle\oldmaketitle
\begin{document}
\maketitle
\blinddocument
\end{document}


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. 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. Dec 17 '13 at 16:16
• @DenisBitouzé I updated my answer, i hope it is helpful. 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. Dec 17 '13 at 17:24
• @DenisBitouzé Maybe there is something simpler, and we just don't know it? ;-) Dec 17 '13 at 17:25