| 1 |
% \iffalse |
| 2 |
%% |
| 3 |
%% File: topsection.dtx Copyright (C) 2005 by Alexander I. Rozhenko |
| 4 |
%% |
| 5 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 6 |
%<package>\ProvidesPackage{topsection} |
| 7 |
%<package> [2005/12/24 v1.0 Top section definition (NCC)] |
| 8 |
% |
| 9 |
% \changes{v1.0}{2005/12/24}{Initial version} |
| 10 |
% |
| 11 |
%<*driver> |
| 12 |
\let\makeindex\relax |
| 13 |
\documentclass{ltxdoc} |
| 14 |
\usepackage{topsection} |
| 15 |
\GetFileInfo{topsection.sty} |
| 16 |
\begin{document} |
| 17 |
\title{The \textsf{topsection} package\thanks{This file |
| 18 |
has version number \fileversion, last |
| 19 |
revised \filedate.}} |
| 20 |
\author{Alexander I. Rozhenko\\[email protected]} |
| 21 |
\date{\filedate} |
| 22 |
\maketitle |
| 23 |
\DocInput{topsection.dtx} |
| 24 |
\end{document} |
| 25 |
%</driver> |
| 26 |
% \fi |
| 27 |
% \DescribeMacro\topsection |
| 28 |
% This package implements an unnumbered top-level section |
| 29 |
% (chapter in books and reports or section in articles): |
| 30 |
% \begin{quote} |
| 31 |
% |\topsection|\marg{title} |
| 32 |
% \end{quote} |
| 33 |
% Such a section is used when table of contents, index, or |
| 34 |
% bibliography are prepared. So, the |\topsection| command can |
| 35 |
% be used to make such definitions or redefinitions to be independent |
| 36 |
% on class in use. The command definition is compatible with standard |
| 37 |
% \textbf{article}, \textbf{book}, and \textbf{report} classes |
| 38 |
% and also with the \textbf{ncc} class. |
| 39 |
% |
| 40 |
% \DescribeMacro\@iftopchapter |
| 41 |
% To distinguish what type of top section is used, the following |
| 42 |
% conditional command is also specified: |
| 43 |
% \begin{quote} |
| 44 |
% |\@iftopchapter|\marg{chapter-clause}\marg{section-clause} |
| 45 |
% \end{quote} |
| 46 |
% The \meta{chapter-clause} is executed if top section is the |\chapter|. |
| 47 |
% Otherwise, the \meta{section-clause} is executed. |
| 48 |
% |
| 49 |
% If the \textbf{nccsect} |
| 50 |
% package is used together with this package, the top-section title |
| 51 |
% is also written to the aux-file. To avoid this, |
| 52 |
% use |\skipwritingtoaux| modifier just before the top section. |
| 53 |
% |
| 54 |
% \StopEventually{} |
| 55 |
% |
| 56 |
% \section{The Implementation} |
| 57 |
% |
| 58 |
% At first, we provide |\@mkboth| command to be sure that |
| 59 |
% it is defined (in \textbf{ncc} class |\@mkboth| useless and |
| 60 |
% so it does not defined here). If it does not exist yet, its |
| 61 |
% default value will be equal to \LaTeX's |\@gobbletwo| command. |
| 62 |
% \begin{macrocode} |
| 63 |
%<*package> |
| 64 |
\providecommand\@mkboth[2]{} |
| 65 |
% \end{macrocode} |
| 66 |
% |
| 67 |
% \begin{macro}{\NCC@topsection} |
| 68 |
% \begin{macro}{\@iftopchapter} |
| 69 |
% The |\NCC@topsection| macro contains a command to be used as a |
| 70 |
% top section. To select an appropriate command, we test the |
| 71 |
% |\chapter| command to be defined. The |\@iftopchapter| macro is |
| 72 |
% also specified here. |
| 73 |
% \begin{macrocode} |
| 74 |
\newcommand\@iftopchapter[2]{} |
| 75 |
\@ifundefined{chapter}{% |
| 76 |
\def\NCC@topsection{\section}% |
| 77 |
\let\@iftopchapter\@secondoftwo |
| 78 |
}{% |
| 79 |
\def\NCC@topsection{\chapter}% |
| 80 |
\let\@iftopchapter\@firstoftwo |
| 81 |
} |
| 82 |
% \end{macrocode} |
| 83 |
% \end{macro} |
| 84 |
% \end{macro} |
| 85 |
% |
| 86 |
% \begin{macro}{\topsection} |
| 87 |
% Now we define the |\topsection| command. When the package is loaded, |
| 88 |
% we specify the command to be a new one. Its real definition |
| 89 |
% is done at the beginning of document when all packages are |
| 90 |
% already loaded and an appropriate decision can be selected. |
| 91 |
% \begin{macrocode} |
| 92 |
\newcommand*\topsection[1]{} |
| 93 |
\AtBeginDocument{% |
| 94 |
% \end{macrocode} |
| 95 |
% If the \textbf{nccsect} package is in use, we define the |\topsection| |
| 96 |
% command using the basic form of the corresponding sectioning command. |
| 97 |
% The |\noheadingtag| modifier turns off the top-section numbering. |
| 98 |
% In the definition, we test the |\@mkboth| command to be equal to |
| 99 |
% |\@gobbletwo|. This situation appears in two cases: when the page |
| 100 |
% style other than |headings| is used or when the \textbf{ncc} class |
| 101 |
% is loaded. In the last case, the appropriate page header is already |
| 102 |
% specified in sectioning command with corresponding mark-command |
| 103 |
% (|\chaptermark| or |\sectionmark| updates both headers by the same |
| 104 |
% manner). So, in both these cases we need not use the |\@mkboth|. |
| 105 |
% But in other cases we specify the header mark in standard way |
| 106 |
% and use the |\norunninghead| modifier to skip updating headers |
| 107 |
% inside the sectioning command. |
| 108 |
% \begin{macrocode} |
| 109 |
\@ifpackageloaded{nccsect}{% |
| 110 |
\renewcommand*\topsection[1]{% |
| 111 |
\ifx\@mkboth\@gobbletwo |
| 112 |
\noheadingtag \NCC@topsection{#1}% |
| 113 |
\else |
| 114 |
\norunninghead |
| 115 |
\noheadingtag \NCC@topsection{#1}% |
| 116 |
\@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}% |
| 117 |
\fi |
| 118 |
}% |
| 119 |
% \end{macrocode} |
| 120 |
% When the \textbf{nccsect} package does not loaded, the top-section |
| 121 |
% definition uses just the same technique as in standard classes. |
| 122 |
% \begin{macrocode} |
| 123 |
}{% |
| 124 |
\renewcommand*\topsection[1]{% |
| 125 |
\NCC@topsection*{#1}% |
| 126 |
\@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}% |
| 127 |
}% |
| 128 |
}% |
| 129 |
} |
| 130 |
%</package> |
| 131 |
% \end{macrocode} |
| 132 |
% \end{macro} |
| 133 |
\endinput |