The stdclsdv package^{∗}

Peter Wilson Catholic University of America^{†}

             Now at peter.r.wilson@boeing.com

1999/01/17

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 1

3 The package code 2

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).

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.

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.

∗This file has version number v1.0, last revised 1999/01/17.

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

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, or ltxdoc. 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 can be done using:

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

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}[1999/01/18 v1.0 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.^{1}

 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}{}

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

18 \ifSCDknownclass\else
19 \SCDnodivstrue
20 \ifx\part\undefined
21  \SCDpartfalse
22 \else
23  \SCDnodivsfalse
24 \fi
25 \ifx\chapter\undefined\else
26  \SCDchaptertrue \SCDnodivsfalse
27 \fi
28 \ifx\section\undefined
29  \SCDsectionfalse
30 \else
31  \SCDnodivsfalse
32 \fi
33 \fi

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

34 \newcommand{\SCDquit}{}

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

35 \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.

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

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

The end of this package.

56 ⟨/usc⟩

References

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

Index

Numbers written in italic refer to the page where the corresponding entry is described, the ones underlined to the code line of the definition, the rest to the code lines where the entry is used.

Symbols

\@SCD@check@c 40, 42, 50
\@SCD@check@command

. . . . . . . 38, 40, 41

\@SCD@check@eq . . . .

…. 46, 47, 51, 55

\@ifclassloaded 9–14, 16
\@ifundefined . . . . . 45
\@onlypreamble . . . .

…. 39, 41, 50, 55

\@star@or@long . . . . 36

C

\chapter . . . . . . . . . 25 \csname . . . . . 43, 48, 49

E

                          \endcsname . . 43, 48, 49

I

                          \ifSCDchapter . . . . 1, \underline{4}
                          \ifSCDknownclass . 1, \underline{4}
                          \ifSCDnodivs . . . . . 2, \underline{4}
                          \ifSCDpart . . . . . . 1, \underline{4}
                          \ifSCDSameDefinition

. . . . . . . . . . 2, \underline{35}

                          \ifSCDsection . . . . 2, \underline{4}

N \newif . . . . . . . . 4–8, 35

P \part . . . . . . . . . . . . 20

                                                   \ProvidesPackage . . . 3

R

                                                   \renew@command . . . . 44
                                                   \reserved@a . . 43–46, 49

S

                                                   \SCDchapterfalse . . . 6
                                                   \SCDchaptertrue 9, 10, 26
                                                   \SCDCheckCommand . 2, \underline{36}
                                                   \SCDknownclassfalse . 4
                                                   \SCDknownclasstrue .

. . . . . . . . 9–14, 16

                                                   \SCDnodivsfalse . . .

. . . . . 8, 23, 26, 31

                                                   \SCDnodivstrue 15, 17, 19
                                                   \SCDpartfalse 15, 17, 21

\SCDparttrue . . . . . . . 5

\SCDquit . . . . . . . . 2, \underline{34}

\SCDSameDefinitionfalse

. . . . . . . . . . . . 53

                          \SCDSameDefinitiontrue

. . . . . . . . . . . . 37

                          \SCDsectionfalse . .

. . . . . . . 15, 17, 29

                                                   \SCDsectiontrue . . . . 7

\section . . . . . . . . . 28

\string . . 43, 45, 48, 49