TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

marked as duplicate by Seamus, lockstep, Caramdir, Loop Space, Martin Scharrer Jul 27 '11 at 21:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Have a look at Which documentclass is being used? – lockstep Jul 27 '11 at 17:54
Ah, seems perfect! If only my search-fu had been better. – cljacobs Jul 27 '11 at 18:17

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.

share|improve this answer

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