The stdclsdv package^{∗}

Peter Wilson Catholic University of America^{†}

             Now at peter.r.wilson@boeing.com

2000/07/16

Abstract

The stdclsdv package is intended to be used by the authors of L^{A}TEX packages that need to know about the sectional divisions provided by the document class.

Contents

1 Introduction 1

2 The stdclsdv package 2

3 The package code 3

1 Introduction

Several packages need to know the kind of sectional divisions provided by the document class.

The stdclsdv package provides a solution for for the case when the document class is one of the L^{A}TEX standard classes (i.e., book, report, article, letter, slides, and classes derived from the article class, namely ltxdoc and proc). It also handles the koma classes.^{1}

This manual is typeset according to the conventions of the L^{A}TEX docstrip utility which enables the automatic extraction of the L^{A}TEX macro source files [GMS94].

Section 2 describes the usage of the package. Commented source code for the package is in Section 3.

∗This file has version number v1.1, last revised 2000/07/16.

†This work was originally performed as a Guest Researcher at the National Institute of Standards and Technology.

1Courtesy of Joerg Jaspert Joerg.Jaspert@informatik.fh-fulda.de.

2 The stdclsdv package

The stdclsdv package provides several \if... macros which can be used to determine the kinds of sectional divisions supported by the current (standard)

\documentclass.

The package is designed to work with the standard L^{A}TEX document classes book, report, article, proc and ltxdoc class (which is based to a large extent on the article class).

\ifSCDknownclass \ifSCDknownclass is TRUE iff the document class is one of: book, report, article, letter, slides, proc, ltxdoc, scrbook, scrreprt, scrartcl or scrlettr. Otherwise it is FALSE.

\ifSCDchapter \ifSCDchapter is TRUE iff the document class defines a \chapter sectional

division, otherwise it is FALSE.

\ifSCDpart \ifSCDpart is TRUE iff the document class defines a \part sectional division,

otherwise it is FALSE.

\ifSCDsection \ifSCDsection is TRUE iff the document class defines a \section sectional

division, otherwise it is FALSE.

\ifSCDnodivs      \ifSCDnodivs is TRUE iff the document class has neither \part nor \chapter

nor \section divisions, otherwise it is FALSE.

\SCDquit If the document class or divisioning is not handled by a package, it can be useful to skip all futher package code. This could be done using:

 ...
 \ifSCDknownclass
   % normal processing
 \else % just before end of package file
   % error/warning message about unknown class
 \fi
 \endinput

Alternatively, using the \SCDQuit command provides a clearer means of accomplishing this. The \SCDquit macro is defined to do nothing. It is intended to be used for prematurely ending a package file in the following manner:

 \ifSCDknownclass\else
   \renewcommand{\SCDquit}{\endinput}
   % error/warning message about unknown class
 \fi
 \SCDquit % ends the file iff the class is unknown
 % normal processing
 ...
 \endinput

\SCDCheckCommand      \SCDCheckCommand takes the same arguments as \newcommand, that is:
\ifSCDSameDefinition  \SCDCheckCommand{⟨command⟩}[⟨nargs⟩][⟨defarg⟩]{⟨definition⟩}
\SCDCheckCommand is identical to the kernel \CheckCommand (see ltdefns.dtx)

except that it sets \ifSCDSameDefinition to TRUE iff the definition given in \SCDCheckCommand is the same as the current definition, otherwise \ifSCDSameDefinition is set to FALSE. (\CheckCommand issues a warning if the definitions are different).

3 The package code

Announce the name and version of the package, which requires L^{A}TEX 2ε.

1 ⟨∗usc⟩

 2 \NeedsTeXFormat{LaTeX2e}
 3 \ProvidesPackage{stdclsdv}[2000/07/16 v1.1 Sectional divisions]

In order to try and avoid name clashes with other packages, each macro name includes the character string SCD (Standard Class Division).

\ifSCDknownclass \ifSCDpart \ifSCDchapter \ifSCDsection \ifSCDnodivs These are used when we need to decide what sectional divisions are supported by the document’s class. We will assume assume an unknown class that has \part and \section but not \chapter divisions.

 4 \newif\ifSCDknownclass\SCDknownclassfalse
 5 \newif\ifSCDpart\SCDparttrue
 6 \newif\ifSCDchapter\SCDchapterfalse
 7 \newif\ifSCDsection\SCDsectiontrue
 8 \newif\ifSCDnodivs\SCDnodivsfalse

Check the actual class.^{2}

 9 \@ifclassloaded{book}{\SCDknownclasstrue\SCDchaptertrue}{}
10 \@ifclassloaded{report}{\SCDknownclasstrue\SCDchaptertrue}{}
11 \@ifclassloaded{article}{\SCDknownclasstrue}{}
12 \@ifclassloaded{proc}{\SCDknownclasstrue}{}
13 \@ifclassloaded{ltxdoc}{\SCDknownclasstrue}{}
14 \@ifclassloaded{slides}{\SCDknownclasstrue
15  \SCDnodivstrue\SCDpartfalse\SCDsectionfalse}{}
16 \@ifclassloaded{letter}{\SCDknownclasstrue
17  \SCDnodivstrue\SCDpartfalse\SCDsectionfalse}{}

Joerg Jaspert supplied, via Email on 2000/07/16, the following code for the koma classes.

18 \@ifclassloaded{scrbook}{\SCDknownclasstrue\SCDchaptertrue}{}
19 \@ifclassloaded{scrreprt}{\SCDknownclasstrue\SCDchaptertrue}{}
20 \@ifclassloaded{scrartcl}{\SCDknownclasstrue}{}
21 \@ifclassloaded{scrlettr}{\SCDknownclasstrue
22  \SCDnodivstrue\SCDpartfalse\SCDsectionfalse}{}

If the class is not one of the standard classes, check if \part or \chapter or \section headings are provided.

23 \ifSCDknownclass\else
24 \SCDnodivstrue
25 \ifx\part\undefined
26  \SCDpartfalse
27 \else

2Thanks to David Carlisle for information on how to check on the class.

28  \SCDnodivsfalse
29 \fi
30 \ifx\chapter\undefined\else
31  \SCDchaptertrue \SCDnodivsfalse
32 \fi
33 \ifx\section\undefined
34  \SCDsectionfalse
35 \else
36  \SCDnodivsfalse
37 \fi
38 \fi

\SCDquit A macro that does nothing (see §2 for its intended usage).

39 \newcommand{\SCDquit}{}

\ifSCDSameDefinition Used to store the result of \SCDCheckCommand. TRUE iff the command has the given definition.

40 \newif\ifSCDSameDefinition
\SCDCheckCommand This is identical to the kernal \CheckCommand except that it sets the \ifSCDSameCommand

flag rather than issuing a warning. See ltdefns.dtx for the coding for

\CheckCommand.
41 \def\SCDCheckCommand{\@star@or@long%
42 \SCDSameDefinitiontrue%             changed from CheckCommand
43 \@SCD@check@command}
44 \@onlypreamble\SCDCheckCommand
\@SCD@check@command
45 \def\@SCD@check@command#1#2#{\@SCD@check@c#1{#2}}
46 \@onlypreamble\@SCD@check@command
\@SCD@check@c
47 \long\def\@SCD@check@c#1#2#3{%
48 \expandafter\let\csname\string\reserved@a\endcsname\relax
49 \renew@command\reserved@a#2{#3}%
50 \@ifundefined{\string\reserved@a}%
51 {\@SCD@check@eq#1\reserved@a}%
52 {\expandafter\@SCD@check@eq
53  \csname\string#1\expandafter\endcsname
54  \csname\string\reserved@a\endcsname}}
55 \@onlypreamble\@SCD@check@c
\@SCD@check@eq
56 \def\@SCD@check@eq#1#2{%
57 \ifx#1#2\else
58  \SCDSameDefinitionfalse  % changed from CheckCommand
59 \fi}
60 \@onlypreamble\@SCD@check@eq

The end of this package.

61 ⟨/usc⟩

References

[GMS94] Michel Goossens, Frank Mittelbach, and Alexander Samarin. The LaTeX Companion. Addison-Wesley Publishing Company, 1994.