# [texhax] need name of variable containing value of documentclass

Heiko Oberdiek heiko.oberdiek at googlemail.com
Sat Oct 1 00:34:18 CEST 2011

On Fri, Sep 30, 2011 at 08:36:09PM +0000, Fehd, Ronald J. (CDC/OCOO/ITSO) wrote:

> I am using a file in two different documents:
> the first is a stand-alone doc which is a documentclass=article
> and, after editing, proofreading, and reviewing,
> I will input that file in a larger doc with documentclass=book.
>
> Q: which macro variable contains the value of documentclass?

The documentclass is not stored in a variable.

> I would like to add the chapter command to the beginning of the file
> when the doc is being input in the documentclass=book
>
> i.e.:
> if documentclass=book {chapter[\docTitleShort]{\docTitle}}

In the preamble you can use \@ifclassloaded{book}{...yes...}{...no...}.
But that's forbidden after \begin{document}.

Package ltxcmds' therefore provides \ltx at ifclassloaded
with the same function as \@ifclassloaded and that also works
after \begin{document}.
However a package cannot be loaded after \begin{document} either,
thus low level stuff remains:

\makeatletter
\@ifundefined{ver at book.cls}{}{%
\chapter[\docTitleShort]{\docTitle}%
}
\makeatother

Yours sincerely
Heiko Oberdiek
`