Possible Duplicate:
Which documentclass is being used?

Is it possible to get the name of the current document class name from a package being used by that document? An example of what I mean:

In the document:

Foo claims \bar! What does he know?

In the package foo used above:

\newcommand{\bar}{the current document class is \DocumentClassName}

I'm actually interested in using this to modify the behavior of some of my own macros slightly, based on the document class. I've currently worked around this issue, by defining options based on class names. I thought I could keep these options to force certain behaviors, but it would be nice if the default could be chosen based on the document class name.

It suffices for my purposes to differentiate between books, reports, articles, and "other" (anything else). Testing for the existence of a chapter counter almost works, except that it can't differentiate between books and reports.


if you do not need the second optional argument for a specifix class date, this should work:



\newcommand\baz{the current document class is \CName}


Foo claims \baz! What does he know?


The problem is that we have to redefine the \ProvidesClass before the class itself is loaded.

Not the answer you're looking for? Browse other questions tagged or ask your own question.