[texhax] need name of variable containing value of documentclass

Heiko Oberdiek heiko.oberdiek at googlemail.com
Mon Oct 17 23:36:51 CEST 2011


On Mon, Oct 17, 2011 at 11:14:39PM +0200, Uwe Lueck wrote:

> "Heiko Oberdiek" <heiko.oberdiek at googlemail.com> wrote 04.10.2011 16:33:48:
> > A document class can load another document class
> > that can load another documentclass
> 
> I disagree already here, let alone ...

\RequirePackage{filecontents}
\begin{filecontents*}{ClassA.cls}
\ProvidesClass{ClassA}[2011/10/17]
\typeout{I am class `ClassA'}
\LoadClass{ClassB}
\end{filecontents*}
\begin{filecontents*}{ClassB.cls}
\ProvidesClass{ClassB}[2011/10/17]
\typeout{I am class `ClassB'}
\LoadClass{article}
\end{filecontents*}

\RequirePackage{classlist}
\documentclass{ClassA}
\begin{document}
\noindent
This document uses the following classes:
\begin{itemize}
\newcommand*{\ClassListEntry}[3]{\item \texttt{#1}}
\ClassList
\end{itemize}
The main (first) class is \texttt{\MainClassName}.
\end{document}

> > that can load another document class that can load ...
> 
> ... once I thought this too, but then I experienced \@twoloadclasserror,
> see \let\LoadClass\@twoloadclasserror in \@onefilewithoptions of latex.ltx.

It's set *after* the class file is read, thus it allows nested
\LoadClass calls, see the example above.

> > There is a package `classlist' that records the main (first) class
> > and the class list. The package needs to be loaded before \documentclass:
> 
> I saw "classlist" earlier and already then wondered how long the "list" can be, 
> now looked up its documentation for examples ...
> 
> I.e., e.g., when some class `modbook.cls' builds on the standard LaTeX
> `book.cls' by \LoadClass{book}, you cannot create a class `mmodbook.cls'
> building on `modbook.cls' by \LoadClass{modclass}, rather
> 
>     \documentclass{mmodclass}
> 
> will produce the \@twoloadclasserror then.

No, see example above (article:=book, ClassB:=modbook, ClassA:=mmodbook).

Yours sincerely
  Heiko Oberdiek

PS: there is a typo in the documentation of classlist:
    "\MainClass" should read "\MainClassName".


More information about the texhax mailing list