Debian Codegraph @

texmf-dist/source/latex/ncctools/nccsect.dtx

raw
1 % \iffalse
2 %%
3 %% File: nccsect.dtx Copyright (C) 2002--2006 by Alexander I. Rozhenko
4 %%
5 %<package>\NeedsTeXFormat{LaTeX2e}
6 %<package>\ProvidesPackage{nccsect}
7 %<package> [2006/01/20 v1.6 Extended Section, Caption, and TOC Handling (NCC)]
8 %
9 % \changes{v1.00}{2002/02/01}{This version is uploaded to CTAN}
10 % \changes{v1.01}{2002/02/08}{\NCC@thetocchapter hook added}
11 % \changes{v1.02}{2002/02/13}{Bug in using the \nosectiontag fixed}
12 % \changes{v1.02}{2002/03/19}{Test for caption with empty text added}
13 % \changes{v1.03}{2002/05/19}{Vskips in captions after style changes now}
14 % \changes{v1.04}{2002/05/22}{Centering in captions now works}
15 % \changes{v1.1}{2004/12/12}{Introduce |\NCC@sec@reset@controls|}
16 % \changes{v1.1}{2004/12/12}{Simplify making sections. The |\NCC@makesection| now
17 % incompatible with previous version!!!}
18 % \changes{v1.1}{2004/12/12}{Revised version: many internal changes}
19 % \changes{v1.1}{2004/12/12}{Documentation was prepared}
20 % \changes{v1.2}{2005/04/15}{Emulate |\@makecaption| for compatibility}
21 % \changes{v1.2}{2005/04/15}{Compatibility with the supertabular package added}
22 % \changes{v1.2}{2005/04/15}{Compatibility with the longtable package added}
23 % \changes{v1.2}{2005/05/20}{Introduce |\beforechapter| hook}
24 % \changes{v1.2}{2005/05/20}{Add |\StartFromTextArea| and |\StartFromHeaderArea|}
25 % \changes{v1.2}{2005/05/21}{Add |\epigraph| and |\epigraphparameters|}
26 % \changes{v1.2}{2005/05/22}{Add |\captionstyle| and related staff}
27 % \changes{v1.2}{2005/05/22}{Add |\TOCMarginDrift|}
28 % \changes{v1.2}{2005/05/22}{Add |\applystyle| command to TOC Entry style}
29 % \changes{v1.2}{2005/06/08}{Set |\@twocolumnfalse| in before-chapter hook}
30 % \changes{v1.2}{2005/06/08}{Allow sectioning in |\beforechapter| hook}
31 % \changes{v1.3}{2005/06/15}{Fixed bug with using |\applystyle| command}
32 % \changes{v1.4}{2005/12/26}{Conditionally define |\StartFromTextArea| and |\StartFromHeaderArea|}
33 % \changes{v1.4}{2005/12/28}{|\sectionstyle| now has a |type| parameter}
34 % \changes{v1.4}{2005/12/28}{New section styles: hangparindent, hangparindent*}
35 % \changes{v1.4}{2005/12/28}{|\NCC@makechapfinal| hook introduced}
36 % \changes{v1.4}{2005/12/28}{|\NCC@makeparttitle|, |\NCC@makechaptitle| hooks}
37 % \changes{v1.4}{2005/12/28}{The scope of declarations in |\@svsec| is localized}
38 % \changes{v1.4}{2005/12/28}{|\aftersectionvspace| introduced}
39 % \changes{v1.4}{2005/12/29}{Add |\DeclarePart| and |\DeclareTOCPart| commands}
40 % \changes{v1.4}{2005/12/30}{Make the package completely independent on standard commands}
41 % \changes{v1.4}{2005/12/31}{Add more hooks and fix |\MakeUppercase| related bugs}
42 % \changes{v1.4}{2006/01/01}{Introduce |\RunningSectionSuffux| command}
43 % \changes{v1.4}{2006/01/01}{Introduce |\NCC@preparesectag| hook}
44 % \changes{v1.4}{2006/01/01}{Remove |\NCC@defaultsectag| hook}
45 % \changes{v1.4}{2006/01/01}{|\NCC@nexttocnum|, |\NCC@preparetocnum| hooks}
46 % \changes{v1.4}{2006/01/03}{The |\norunningsuffix| modifier introduced}
47 % \changes{v1.5}{2006/01/06}{Introduce |\SetTOCStyle| and |\ChapterPrefixStyle|}
48 % \changes{v1.5}{2006/01/17}{Replace addtopackage to afterpackage}
49 % \changes{v1.5}{2006/01/17}{Remove \protect before \numberline, because it is robust now}
50 % \changes{v1.5}{2006/01/19}{Allow caption width be greater than a line width}
51 % \changes{v1.5}{2006/01/19}{Compatibility with the xtab package added}
52 % \changes{v1.5}{2006/01/19}{Add |\newplainsectionstyle|, |\newhangsectionstyle|}
53 % \changes{v1.5}{2006/01/19}{Add |\adjustsectionmargins|}
54 % \changes{v1.5}{2006/01/19}{Introduce |centerlast| section style}
55 % \changes{v1.5}{2006/01/19}{Introduce |\sectiontagsuffix| command}
56 % \changes{v1.5}{2006/01/19}{Introduce |\captiontagsuffix| command}
57 % \changes{v1.6}{2006/01/20}{Improve |\NCC@secflush| to work in |rightlast| style}
58 %
59 %<*driver>
60 \let\makeindex\relax
61 \documentclass{ltxdoc}
62 \usepackage{nccsect,nccboxes,desclist}
63 \GetFileInfo{nccsect.sty}
64 \newhangsectionstyle{margin}{2in}[r]{-2in}{0pt plus 1fil}
65 \newhangsectionstyle{list}{1in}{0pt}{1in plus 1fil}
66 \newplainsectionstyle{flushright}{0pt}[r]{1in plus 1fil}{0pt}
67 \begin{document}
68 \title{The \textsf{nccsect} package\thanks{This file
69 has version number \fileversion, last
70 revised \filedate.}\ \thanks{Great thanks to Denis G. Samsonenko
71 \texttt{<[email protected]>} who proposed many significant
72 improvements to the package.}}
73 \author{Alexander I. Rozhenko\\[email protected]}
74 \date{\filedate}
75 \maketitle
76 \DocInput{nccsect.dtx}
77 \end{document}
78 %</driver>
79 % \fi
80 %
81 % \tableofcontents
82 %
83 % \section{The Scope and Objectives}
84 %
85 % The package provides a new implementation of sections, captions,
86 % and toc-entries independent on the \LaTeX\ kernel. The reasons for this
87 % are concerned with the following disadvantages of the
88 % standard \LaTeX\ implementation:
89 %
90 % \paragraph{1} Standard \LaTeX\ sectioning commands can prepare
91 % display sections in the single style: justified paragraph
92 % with hang indented number. To change this style to another
93 % one (centered, par-indented, or else), you need
94 % to re-implement the internal |\@sect| command. It is no
95 % control for this style on user's level.
96 %
97 % \paragraph{2} If you want to customize the presentation a number in
98 % a section (for example, put a paragraph mark \S\ before a number
99 % or put a point after a number), you at least need to
100 % re-implement the |\@sect| command.
101 %
102 % \paragraph{3} The sectioning commands provide no straightforward
103 % control for running headings. The marking commands
104 % like the |\sectionmark| solve this problem partially.
105 % Using them within parameter of sectioning command,
106 % you can change the mark properly, but this solution does not work in
107 % complicated documents which use first and last marks
108 % appearing on a page. The safe solution consists in direct
109 % replacement a mark prepared within the |\@sect| command
110 % to a custom mark.
111 %
112 % \paragraph{4} Special efforts are required to pass a section
113 % without number to the header and to the toc-list. There is no simple
114 % solution providing this action.
115 %
116 % \paragraph{5} Captions for tables and figures are prepared in
117 % just the same way, although, they are usually used in different
118 % places of floating environments: table captions start
119 % \textit{before\/} a table, but figure captions go \textit{after\/}
120 % a figure. So, the vertical skip inserted before a caption is
121 % unnecessary for table captions. The right solution is to design
122 % captions for different float types in different ways.
123 %
124 % \paragraph{6} The star-form of captions is absent. It is useful
125 % when a document contains an alone figure or table. Moreover,
126 % in fiction books, unnumbered captions useful.
127 %
128 % \paragraph{7} The design of toc-entries is hard for modifications.
129 % It is much better to calculate the skips in toc-entries on the
130 % base of prototyping technique instead of hard-coding them
131 % with absolute values. Moreover, the skips for nested sections
132 % must depend on higher level skips. For example, if we
133 % change skips for a section entry, the skips for subsection entries
134 % should be adjusted automatically.
135 %
136 % \bigskip
137 % The package eliminates above-mention disadvantages of the standard
138 % \LaTeX\ implementation. The commands implemented in it are divided
139 % into two levels: user level and design level. The user-level commands
140 % are intended for use within a document and the design-level commands
141 % are directed to class and package writers.
142 %
143 % \section{User Interface}
144 %
145 % The table below shows sectioning commands provided with standard
146 % \LaTeX\ classes. Every section has a \textit{level\/} (an integer
147 % number). Sections can be printed in one of two modes:
148 % \textit{display\/} or \textit{running\/} mode. Display section is
149 % prepared as a separate justified paragraph having a hang indent if a
150 % section has a number. Running section starts a paragraph.
151 % \begin{center}\catcode`|=12
152 % \small\tabcolsep=10pt
153 % \renewcommand\cboxstyle{\footnotesize}
154 % \begin{tabular}{|l|c|c|}\hline
155 % \hfill\cbox{Command}\hfill\mbox{} &
156 % \hfill\cbox{Level}\hfill\mbox{} &
157 % \hfill\cbox{Mode}\hfill\mbox{}\\\hline
158 % \Strut/.8/
159 % \cs{part} & $-$1 or 0\footnotemark & display \\
160 % \cs{chapter} & 0\footnotemark & display \\
161 % \cs{section} & 1 & display \\
162 % \cs{subsection} & 2 & display \\
163 % \cs{subsubsection} & 3 & display \\
164 % \cs{paragraph} & 4 & running \\
165 % \cs{subparagraph} & 5 & running \\
166 % \hline
167 % \end{tabular}\footnotetext[1]{The \cs{part} command has zero level
168 % in article-like classes and has the negative level in book-like
169 % classes. In book-like classes a part is prepared on
170 % a separate page.}\footnotetext{The \cs{chapter} command is defined
171 % in book-like classes only.}
172 % \end{center}
173 %
174 % \DescribeMacro\startsection
175 % The package redefines all standard sectioning commands. Along with the
176 % commands shown in the table above, you can use the following
177 % uniform notations:
178 % \begin{quote}
179 % |\startsection|\marg{level}\oarg{toc-entry}\marg{title}\quad or\\
180 % |\startsection|\marg{level}|*|\marg{title}
181 % \end{quote}
182 % The \meta{level} is a level of section. A negative level produces
183 % a part. The first command
184 % produces a numbered section (if~the numbering depth allows this)
185 % and the last one produces a section without number.
186 % As for the standard \LaTeX\ sectioning, the first variant of
187 % the |\startsection| command additionally passes their arguments
188 % to the section mark command (if the mark command exists)
189 % and to the aux-file.
190 % The last variant does no additional actions.
191 %
192 % \bigskip
193 % \textbf{NOTE}: The package allows declaring additional section
194 % levels. They, of course, have no predefined alias names as
195 % standard section levels.
196 %
197 % \bigskip
198 % \DescribeMacro\sectionstyle
199 % The |\sectionstyle|\oarg{type}\marg{style} command allows change
200 % a style of subsequent display sections of the given \meta{type}:
201 % \begin{desclist}{\tt}{\quad}[subsubsection]\itemsep=0mm
202 % \item[main] the section of zero level (|\part| or |\chapter|);
203 % \item[section] the |\section|;
204 % \item[subsection] the |\subsection|;
205 % \item[subsubsection] the |\subsubsection|;
206 % \item[paragraph] the |\paragraph|;
207 % \item[subparagraph] the |\subparagraph|;
208 % \item[section@vi] the section of 6th level, and so on.
209 % \end{desclist}
210 % If the \meta{type} parameter is omitted, the command acts on
211 % all subsequent display sections expect those having a specialized style.
212 % The following styles are predefined:
213 % \begin{desclist}{\tt}{\quad}[hangparindent*]\itemsep=0mm
214 % \item[hangindent] standard LaTeX style (default);
215 % \item[hangindent*] the same as |hangindent|, but ragged right;
216 % \item[parindent] title indented on |\parindent|;
217 % \item[parindent*] the same as |parindent|, but ragged right;
218 % \item[hangparindent] |\parindent| indented with hang number;
219 % \item[hangparindent*] the same as |hangparindent|, but ragged right;
220 % \item[center] centered title;
221 % \item[centerlast] justified title without indent whose last line is centered.
222 % \end{desclist}
223 % You can apply the |\sectionstyle| so many times in the document
224 % as you want. This command complies with standard \LaTeX\ scoping
225 % rules.
226 %
227 % \bigskip
228 % \textbf{NOTE}: The section style acts on display sections that were
229 % prepared with the dynamic alignment (see Section~\ref{s:decl}). By default,
230 % the sections of levels from 0 to 3 have the dynamic alignment. The
231 % section of zero level has no hang indentation.
232 %
233 % \bigskip
234 % \DescribeMacro\sectiontagsuffix
235 % The |\sectiontagsuffix|\oarg{type}\marg{style} command allows change
236 % a suffix inserted after number tag for sections of the given \meta{type}.
237 % If the \meta{type} parameter is omitted, the command acts on
238 % all subsequent sections expect those having a specialized tag suffix.
239 %
240 % \DescribeMacro\indentaftersection
241 % \DescribeMacro\noindentaftersection
242 % The paragraph indentation after a display section is controlled with
243 % the |\indentaftersection| and |\noindentaftersection| commands.
244 % The first one allows and the last one suppresses
245 % indentation after section. The commands act on the subsequent
246 % display sections in the scope of their use.
247 %
248 % \DescribeMacro\aftersectionvspace
249 % If a document contains two subsequent sectioning commands (for example,
250 % |\section| and |\subsection|) the distance between their titles is
251 % equal to the skip after the first sectioning command. Sometimes
252 % it is necessary to insert another vertical space here. To override
253 % the space inserted between sections, use the command
254 % \begin{quote}
255 % |\aftersectionvspace|\marg{distance}
256 % \end{quote}
257 % This command replaces the space inserted by a previous sectioning
258 % command with the |\vspace|\marg{distance}. It works in the only case when
259 % goes right after a command producing a display section. Otherwise, the
260 % specified \meta{distance}
261 % is ignored. The following example shows how to customize the
262 % |\subsection| command in such a way that the distance between it and
263 % a previous |\section| will be |3ex plus .5ex minus .2ex|:
264 % \begin{quote}
265 % |\renewcommand\subsection{%|\\
266 % | \aftersectionvspace{3ex plus .5ex minus .2ex}%|\\
267 % | \startsection{2}}|
268 % \end{quote}
269 %
270 % \DescribeMacro\adjustsectionmargins
271 % Margins of a display section can be adjusted using the command
272 % \begin{quote}
273 % |\adjustsectionmargins|\marg{left skip}\marg{right skip}
274 % \end{quote}
275 % The \meta{left skip} and \meta{right skip} are added to the left and
276 % right margins of the subsequent section if it is a display section.
277 % Otherwise, this command is ignored.
278 %
279 % \bigskip
280 % \textbf{Modifiers.} The customization of a number tag and running head of a particular
281 % section is provided with so-call \textit{modifiers}. A modifier
282 % is a command acting on the nearest sectioning command going after it.
283 % Usually, the modifiers are placed just before a sectioning command.
284 % All modifiers act on non-starred versions of sections.
285 % If the next sectioning command is starred, modifiers are ignored.
286 %
287 % \DescribeMacro\norunninghead
288 % The |\norunninghead| modifier suppresses generation of running head for the
289 % next non-starred section, i.e.\ it skips the call of section mark command
290 % in the next section.
291 %
292 % \DescribeMacro\runninghead
293 % The |\runninghead|\marg{running-title} modifier overrides a text going to the
294 % running head when a new non-starred section starts and an appropriate\linebreak
295 % |\pagestyle| is in use. This command has higher priority
296 % than the |\norunninghead|.
297 %
298 % \DescribeMacro\noheadingtag
299 % The |\noheadingtag| modifier suppresses a number tag in the next section,
300 % but all other attendant actions are executed (writing to the aux-file and
301 % updating the running head).
302 %
303 % \DescribeMacro\headingtag
304 % The |\headingtag|\marg{tag} modifier overrides a number tag in the next
305 % section. It has the higher priority than |\noheadingtag|. Overridden
306 % section tag can be referred with the |\label| command.
307 % All fragile commands in the overridden tag should be protected.
308 %
309 % \DescribeMacro{\headingtag*}
310 % The |\headingtag*|\marg{tag} modifier prepares a number tag as is, ignoring
311 % the tag style, prefix, and suffix. The aux-file and running head are not
312 % updated in this case.
313 %
314 % \DescribeMacro\skipwritingtoaux
315 % The |\skipwritingtoaux| suppresses writing to aux-file for the next section
316 % command.
317 %
318 % \bigskip
319 % \textbf{NOTE}: All modifiers use global settings.
320 %
321 % \bigskip
322 % \DescribeMacro\caption
323 % \DescribeMacro{\caption*}
324 % The captions are implemented in this package using the same technique as
325 % the sectioning commands. There are two versions of caption command
326 % allowed within floating environments:
327 % \begin{quote}
328 % |\caption|\oarg{toc-entry}\marg{title}\quad and\\
329 % |\caption*|\marg{title}
330 % \end{quote}
331 % The first one works in the same manner as the standard \LaTeX\ |\caption|
332 % command. Its starred version prepares a caption without number and preceding
333 % words `Figure' or `Table'.
334 %
335 % You can use line breaking commands in captions. But in this case,
336 % you need to set the optional \meta{toc-entry} parameter to avoid
337 % translation errors.
338 %
339 % Caption appearance can be customized. You can customize ether all caption
340 % types or only selected caption type. The following commands do this:
341 % \begin{quote}
342 % |\captionstyle|\oarg{type}\marg{style}\\
343 % |\captiontagstyle|\oarg{type}\marg{style}\\
344 % |\captiontagsuffix|\oarg{type}\marg{suffix}\\
345 % |\captionwidth|\oarg{type}\marg{length}
346 % \end{quote}
347 % If \meta{type} is omitted and these commands appear out of float
348 % environments, they are applied to all types.
349 % A command without \meta{type} applied within a float environment
350 % is considered as a command having the type of this environment. Typed
351 % version of a command has a precedence before a non-typed one.
352 %
353 % \medskip\noindent
354 % \DescribeMacro\captionstyle
355 % specifies a style
356 % the caption text will be formatted:
357 % \begin{desclist}{\tt}{\quad}[centerlast]\itemsep=0mm
358 % \item[default] standard \LaTeX's style,
359 % \item[para] simple paragraph without paragraph indent,
360 % \item[left] all lines are flushed left,
361 % \item[center] all lines are centered,
362 % \item[right] all lines are flushed right, or
363 % \item[centerlast] as |para|, but the last line is centered.
364 % \end{desclist}
365 %
366 % \medskip\noindent
367 % \DescribeMacro\captiontagstyle
368 % specifies a position of caption tag:
369 % \begin{desclist}{\tt}{\quad}[centerlast]\itemsep=0mm
370 % \item[para] tag is formatted together with text,
371 % \item[left] tag is adjusted to the left in a separate line,
372 % \item[center] tag is centered in a separate line, or
373 % \item[right] tag is adjusted to the right in a separate line.
374 % \end{desclist}
375 %
376 % \medskip\noindent
377 % \DescribeMacro\captiontagsuffix
378 % specifies a suffix after caption tag.
379 %
380 % \medskip\noindent
381 % \DescribeMacro\captionwidth
382 % specifies a width of caption.
383 %
384 % \medskip\noindent
385 % Defaults:
386 % \begin{quote}
387 % |\captionstyle{default}|\\
388 % |\captiontagstyle{para}|\\
389 % |\captiontagsuffix{:\hspace{0.7em plus 0.2em minus 0.1em}}|\\
390 % |\captionwidth{\linewidth}|
391 % \end{quote}
392 %
393 % \textbf{NOTE}: The above-described section modifiers can be used with non-starred
394 % captions. Although, the |\runninghead| and |\norunninghead| commands
395 % have no sense with captions, but you can do them working if define
396 % a |\figuremark{}| or |\tablemark{}| command.
397 %
398 % \bigskip
399 % \DescribeMacro\SetTOCStyle
400 % The |\SetTOCStyle|\marg{declarations} command allows customize
401 % the table of contents and other content lists. For example, the declaration
402 % \begin{quote}
403 % |\SetTOCStyle{\small}|
404 % \end{quote}
405 % specifies that content lists will be prepared with the |\small| font.
406 % This command is allowed in the preamble only.
407 %
408 % \DescribeMacro\ChapterPrefixStyle
409 % The appearance of Chapter/Appendix prefix in a table of contents and
410 % in a running head can be customized using the command
411 % \begin{quote}
412 % |\ChapterPrefixStyle|\marg{appearance list}
413 % \end{quote}
414 % The \meta{appearance list} can contain up to two words, namely
415 % |header| and/or |toc|, delimited with a comma. Using them, you can
416 % set a prefix-style for the header and/or the table of contents, respectively.
417 % By default, the prefix-style is specified for the header only. This command
418 % is allowed for book-like classes in which the |\chapter| command is
419 % defined. It can be used in the preamble only.
420 %
421 % \section{Create New Section Styles}
422 %
423 % Along with 8 predefined section styles, you can easy create more styles.
424 %
425 % \DescribeMacro\newplainsectionstyle
426 % The command
427 % \begin{quote}
428 % |\newplainsectionstyle|\marg{name}\marg{indent}\oarg{pos}\\
429 % | |\marg{left skip}\marg{right skip}
430 % \end{quote}
431 % creates a new paragraph-like section style with the given \meta{name}.
432 % It has the \meta{indent} paragraph indent
433 % and margins specified with \meta{left skip} and \meta{right skip} lengths.
434 % To prepare a centered style, the optional \meta{pos} parameter
435 % should be equal to |[c]|. In this case, left and right margins must
436 % have an additional |1fil| glue. If optional parameter is |[r]|, the
437 % left margin must have an additional |1fil| glue.
438 %
439 % Four of predefined section styles are created using this command as follows:
440 % \begin{quote}
441 % |\newplainsectionstyle{parindent}{0pt}{\parindent}{0pt}|\\
442 % |\newplainsectionstyle{parindent*}{0pt}{\parindent}{0pt plus 1fil}|\\
443 % |\newplainsectionstyle{center}{0pt}[c]{0pt plus 1fil}{0pt plus 1fil}|\\
444 % |\newplainsectionstyle{centerlast}{0pt}[c]{0pt plus 1fil}{0pt plus -1fil}|
445 % \end{quote}
446 % Analogously to the |centerlast| style, the |rightlast| style (last line is adjusted
447 % to the right) can be easy created:
448 % \begin{quote}
449 % |\newplainsectionstyle{rightlast}{0pt}[r]{0pt plus 1fil}{0pt plus -1fil}|
450 % \end{quote}
451 %
452 % \DescribeMacro\newhangsectionstyle
453 % The command
454 % \begin{quote}
455 % |\newhangsectionstyle|\marg{name}\marg{min tag width}\oarg{pos}\\
456 % | |\marg{left skip}\marg{right skip}
457 % \end{quote}
458 % creates a new hang-indented section style with the given \meta{name}.
459 % The \meta{min tag width} length specifies a minimum width of the section
460 % tag. If a width of section tag is less than this parameter value,
461 % a white space will be inserted surround the tag to have the required
462 % width. The method of inserting a white space is the same as in the
463 % |\makebox| command. It is controlled with the optional \meta{pos}
464 % parameter (|l|, |c|, or |r|; |l| default). Other parameters have
465 % the same meaning as in the previous command.
466 %
467 % Four of predefined section styles are created using this command as follows:
468 % \begin{quote}
469 % |\newhangsectionstyle{hangindent}{0pt}{0pt}{0pt}|\\
470 % |\newhangsectionstyle{hangindent*}{0pt}{0pt}{0pt plus 1fil}|\\
471 % |\newhangsectionstyle{hangparindent}{0pt}{\parindent}{0pt}|\\
472 % |\newhangsectionstyle{hangparindent*}{0pt}{\parindent}{0pt plus 1fil}|
473 % \end{quote}
474 %
475 % The following examples shows possibilities of these commands:
476 %
477 % \skipwritingtoaux
478 % \sectionstyle[subsection]{margin}
479 % \subsection{This subsection was prepared in the margin style}
480 %
481 % The definition of the |margin| style is the following:
482 % \begin{quote}
483 % |\newhangsectionstyle{margin}{2in}[r]{-2in}{0pt plus 1fil}|
484 % \end{quote}
485 %
486 % \skipwritingtoaux
487 % \sectionstyle[subsection]{list}
488 % \subsection{This subsection was prepared in the list style}
489 %
490 % The definition of the |list| style is the following:
491 % \begin{quote}
492 % |\newhangsectionstyle{list}{1in}{0pt}{1in plus 1fil}|
493 % \end{quote}
494 %
495 % \skipwritingtoaux
496 % \sectionstyle[subsection]{flushright}
497 % \subsection{This subsection was prepared in the flushright style}
498 %
499 % The definition of the |flushright| style is the following:
500 % \begin{quote}
501 % |\newplainsectionstyle{flushright}{0pt}[r]{1in plus 1fil}{0pt}|
502 % \end{quote}
503 % \sectionstyle[subsection]{hangindent}
504 %
505 % \section{Declare Sections and Captions\label{s:decl}}
506 %
507 % \DescribeMacro\DeclareSection
508 % To define or redefine a section or caption command, you can use
509 % in the preamble of your document the
510 % following command:
511 % \begin{quote}
512 % |\DeclareSection|\marg{level}\marg{type}\oarg{indent}\marg{prefix}\marg{beforeskip}\\
513 % | |\marg{afterskip}\marg{style}
514 % \end{quote}
515 % \begin{desclist}{}{}[\meta{beforeskip}]
516 % \item[\meta{level}] a section level number. Zero and negative values
517 % are interpreted as follows:
518 % 0 means declaring the |\chapter| or |\part| command depending on a
519 % class used; a negative value means declaring a caption.
520 %
521 % \item[\meta{type}] a section type. For zero level, this
522 % parameter is ignored. For negative level, it defines a float type
523 % (i.e., |figure| or |table|). For positive level, it defines
524 % a counter name. The name of marking command is composed from
525 % the type as |\|\meta{type}|mark|.
526 %
527 % \item[\meta{indent}] indentation of heading from the left margin
528 % (zero is default). Ignored for negative levels.
529 %
530 % \item[\meta{prefix}] a prefix inserted before a section-number tag
531 % (usually empty). In chapter, part, or caption declaration commands,
532 % it is inserted right before the tag name, e.g., before the |\@chapapp|,
533 % |\partname|, |\figurename|, or |\tablename| command.
534 %
535 % \item[\meta{beforeskip}] the skip to leave above the heading.
536 %
537 % \item[\meta{afterskip}] if positive, then the skip to leave below
538 % the heading, else negative of skip to leave to right of running
539 % heading. The negative value is allowed for positive section levels
540 % only.
541 %
542 % \item[\meta{style}] commands to set a style. The last command in
543 % this argument may be a command such as |\MakeUppercase| that
544 % takes an argument. The section heading will be supplied as the
545 % argument to this command. So setting it to, say,
546 % |\bfseries\MakeUppercase| would produce bold, uppercase headings.
547 % \end{desclist}
548 % Sections having nonnegative \meta{level} and positive \meta{afterskip}
549 % are display sections. They are declared with the |hangindent| style
550 % and do not obey the |\sectionstyle| command.
551 %
552 % \DescribeMacro{\DeclareSection*}
553 % To declare a display section having dynamic alignment controlled with the
554 % |\sectionstyle| command, use the star-version of the previous command:
555 % \begin{quote}
556 % |\DeclareSection*|\marg{level}\marg{type}\marg{prefix}\marg{beforeskip}\\
557 % | |\marg{afterskip}\marg{style}
558 % \end{quote}
559 % A negative \meta{afterskip} has no meaning in this case.
560 %
561 % \DescribeMacro\bff
562 % To prepare bold section headings,
563 % you can use the |\bff| command in the \meta{style} parameter.
564 % It tries to set everything bold. Its definition is the following:
565 % \begin{quote}
566 % |\newcommand{\bff}{\normalfont\bfseries\mathversion{bold}}|
567 % \end{quote}
568 %
569 % Examples of section and caption declarations:
570 % \begin{quote}
571 % |\DeclareSection{-2}{table}{}{0pt}{10pt}{}|\\
572 % |\DeclareSection{-1}{figure}{}{10pt}{0pt}{}|\\
573 % |\DeclareSection*{1}{section}{}%|\\
574 % | {3.5ex plus 1ex minus .2ex}%|\\
575 % | {2.3ex plus .2ex}{\Large\bff}|
576 % \end{quote}
577 % Here we declare the table caption command with zero skip
578 % before it and |10pt| skip after it. On contrary, the
579 % figure caption command produces |10pt| skip before it
580 % and zero skip after it. The |\section| command is declared with
581 % dynamic horizontal alignment. It is prepared in the |\Large|
582 % font with everything bold.
583 %
584 % \DescribeMacro\SectionTagSuffix
585 % The |\SectionTagSuffix|\marg{suffix} command specifies a default suffix
586 % inserted after a section number tag. For example, the command
587 % \begin{quote}
588 % |\SectionTagSuffix{.\quad}|
589 % \end{quote}
590 % sets the decimal point after every section number tag.
591 % Sections of 0th level ignore this suffix. The default tag is |\quad|.
592 % The command can be used in the preamble only.
593 %
594 % \DescribeMacro\RunningSectionSuffix
595 % The |\RunningSectionSuffix|\marg{suffix} command specifies a suffix
596 % inserted after a running section title right before the skip after
597 % section. It can be used in the preamble only.
598 % The default value is an empty suffix.
599 %
600 % \DescribeMacro\norunningsuffix
601 % To remove the suffix after a running section, put the
602 % |\norunningsuffix| modifier in the parameter of running section.
603 %
604 % \DescribeMacro\CaptionTagSuffix
605 % The |\CaptionTagSuffix|\marg{suffix} command specifies a default suffix
606 % inserted after a caption number tag. It can be used in the preamble only.
607 % The default caption tag is:
608 % \begin{quote}
609 % |\CaptionTagSuffix{:\hspace{0.7em plus 0.2em minus 0.1em}}|
610 % \end{quote}
611 %
612 % \section{Declare TOC-Entries}
613 %
614 % \DescribeMacro\DeclareTOCEntry
615 % To declare an entry of table of contents or other lists
616 % (list of figures or list of tables), use the following command
617 % (in the preamble only):
618 % \begin{quote}
619 % |\DeclareTOCEntry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\
620 % | |\marg{style}\oarg{next}
621 % \end{quote}
622 % \begin{desclist}{}{\hfill}[\meta{prototype}]
623 % \item[\meta{level}] a section level number.
624 % For zero and negative level the following commands are created:
625 % 0 means |\l@chapter| or |\l@part| depending on class used;
626 % $-1$ means |\l@figure|; $-2$ means |\l@table|. If level
627 % is greater than 5, the name of toc-entry command is
628 % generated as |\l@section@|\meta{level-in-roman},
629 % i.e., the toc-entry of 6th level is |\l@section@vi|.
630 %
631 % \item[\meta{action}] commands applied before entry is produced (usually empty).
632 %
633 % \item[\meta{prefix}] text inserted before the section number (usually empty).
634 %
635 % \item[\meta{prototype}] prototype of number for alignment the toc-entry body.
636 % The hang indent of this toc-entry will be equal to the width of
637 % \begin{quote}
638 % \meta{style}|{|\meta{prefix}\meta{prototype}\meta{numberline-suffix}|}|
639 % \end{quote}
640 %
641 % \item[\meta{style}] commands to set a style. The last command in this argument
642 % may be a command such as |\MakeUppercase| that takes an
643 % argument. The produced entry will be supplied as the
644 % argument to this command. So setting it to, say,
645 % |\bfseries\MakeUppercase| would produce bold,
646 % uppercase entry. This style is applied to the number also and to the
647 % page number.
648 % To apply different styles to the text of entry and to its page
649 % number, use in this parameter the command
650 % \begin{quote}
651 % |\applystyle|\marg{text-style}\marg{number-style}
652 % \end{quote}
653 %
654 % \item[\meta{next}] prototype for left margin adjustment for an entry of the
655 % next level. Default is the hang indent of the current toc-entry.
656 % \end{desclist}
657 % A toc-entry is produced within a group.
658 %
659 % \DescribeMacro\NumberlineSuffix
660 % The |\NumberlineSuffix|\marg{calc-suffix}\marg{actual-suffix}
661 % command allows customize a skip inserted after
662 % numbers in TOC-like entries. The \meta{calc-suffix} parameter
663 % is used in calculations of hang indent of toc-entries and the
664 % \meta{actual-suffix} is really inserted at the end of number.
665 % The \marg{calc-suffix} is usually wider than the \meta{actual-suffix}.
666 % The default is |\NumberlineSuffix{\quad}{\enskip}|.
667 % This command is available in the preamble only.
668 %
669 % \DescribeMacro\PnumPrototype
670 % The |\PnumPrototype|\marg{prototype} command is used for adjustment
671 % the right margin of the text of toc-entries in toc-lists.
672 % Default is |\PnumPrototype{99}|.
673 % If your document has more than 99 pages, use
674 % |\PnumPrototype{999}|.
675 % This command is available in the preamble only.
676 %
677 % \DescribeMacro\TOCMarginDrift
678 % The |\TOCMarginDrift|\marg{increment} command specifies a value of
679 % right-margin drift in TOCs. The increment is applied after the |\@plus|
680 % token in definition of right margin. Empty argument means no drift.
681 % Examples:
682 % \begin{quote}
683 % |\TOCMarginDrift{2em}|\\
684 % |\TOCMarginDrift{1fil}|
685 % \end{quote}
686 % The command can be use anywhere in the document.
687 %
688 % \DescribeMacro\runinsectionskip
689 % This command is useful in the \meta{action} parameter of the
690 % toc-entry declaration to produce the skip before a toc-entry
691 % equal to the skip before run-in sections.
692 %
693 % The following example shows how toc-entries are declared in books:
694 % \begin{quote}
695 % |\DeclareTOCEntry{-2}{}{}{9.9}{}% table|\\
696 % |\DeclareTOCEntry{-1}{}{}{9.9}{}% figure|\\
697 % |\DeclareTOCEntry{0}{\runinsectionskip\def\@dotsep{1000}%|\\
698 % | \aftergroup\penalty\aftergroup\@highpenalty}{}{9}{\bff}% chapter|\\
699 % |\DeclareTOCEntry{1}{}{}{9.9}{}[9.9]% section|\\
700 % |\DeclareTOCEntry{2}{}{}{9.9.9}{}[9.9.9]% subsection|\\
701 % |\DeclareTOCEntry{3}{}{}{}{}[\qquad]% subsubsection|
702 % \end{quote}
703 % The number prototype for figures and tables is `9.9' here.
704 % The |\l@chapter| entry applies the run-in section skip before it and
705 % redefines the |\@dotsep| command to remove dot leaders.
706 % Using the |\aftergroup| command, it inserts the |\@highpenalty|
707 % after this toc-entry to avoid a page break at this point.
708 % The left margin adjustment after section and nested toc-entries
709 % is calculated here using the prototype of widest section number.
710 % This produces the following nesting:
711 % \begin{flushleft}
712 % {\bf 1\quad Chapter}\\
713 % \jhbox{{\bf 1\quad}}{}1.1\quad Section\\
714 % \jhbox{{\bf 1\quad}1.1}{}1.1.1\quad Subsection\\
715 % \jhbox{{\bf 1\quad}1.11.1.1}{}Subsubsection
716 % \end{flushleft}
717 %
718 % \section{Declare New Float Types}
719 %
720 % The standard \LaTeX\ classes provide two types of floating environments:
721 % figures and tables. If you have prepared a new floating
722 % environment in some way (i.e., using the |float| package by Anselm
723 % Lingnau), you can declare a caption for the new float
724 % with the commands described in previous sections.
725 %
726 % \DescribeMacro\RegisterFloatType
727 % In books, when a new chapter starts, the |\chapter| command
728 % puts a special vertical skip to the contents of list of figures and
729 % of list of tables. This behaviour can be easy extended to new float types
730 % if you register them within this package. The registration is
731 % provided with the following command:
732 % \begin{quote}
733 % |\RegisterFloatType|\marg{float-type}
734 % \end{quote}
735 % After the float type is registered, you can declare a toc-entry
736 % for it using the negation of its registration number in the
737 % \meta{level} parameter. The
738 % first new float type is registered third (after the figure and table).
739 % So, you must
740 % use \meta{level} = $-3$ for it, $-4$ for the next registered float
741 % type and so on.
742 %
743 % In the following example, we define a new float type, |program|,
744 % and prepare the caption and toc-entry commands for it.
745 % The caption of programs
746 % is supposed to be used at the beginning of program.
747 % So, we make it in the same manner as the table caption.
748 % \begin{quote}
749 % |\documentclass{book}|\\
750 % |\usepackage{float,nccsect}|\\
751 % |\newfloat{program}{tp}{lop}[chapter]|\\
752 % |\floatname{program}{Program}|\\
753 % |\RegisterFloatType{program}|\\
754 % |\DeclareSection{-3}{program}{}{0pt}{10pt}{}|\\
755 % |\DeclareTOCEntry{-3}{}{}{9.9}{}|
756 % \end{quote}
757 %
758 % To produce a list of programs, you can then use the |\listof|
759 % command from the |float| package as follows:
760 % \begin{quote}
761 % |\listof{program}{List of Programs}|
762 % \end{quote}
763 % \StopEventually{}
764 %
765 % \section{Epigraphs and Related Staff}
766 %
767 % \DescribeMacro\beforechapter
768 % \DescribeMacro\epigraph
769 % To put epigraph before any chapter, you can use two methods:
770 % low-level |\beforechapter|\marg{anything} hook or
771 % user-level command
772 % \begin{quote}
773 % |\epigraph|\oarg{width}\marg{text}\marg{author}
774 % \end{quote}
775 % The last one applies a special formatting to epigraph and
776 % calls the first one. The |\beforechapter| hook inserts its
777 % contents at the beginning of page just before a chapter
778 % instead of spacing specified in the chapter declaration.
779 %
780 % \DescribeMacro\epigraphparameters
781 % Formatting of user-level epigraph is provided with the
782 % following command
783 % \begin{quote}
784 % |\epigraphparameters|\marg{style}\marg{width}\marg{height}\marg{author-style}\\
785 % | |\marg{after-action}
786 % \end{quote}
787 % Here \meta{style} is a style applied to the whole epigraph
788 % (font selection, spacing and positioning, etc.), the \meta{width}
789 % is the default epigraph width (can be changed in an epigraph),
790 % the \meta{author-style} is the style applied to the author's
791 % signature, and the \meta{after-action} is an action applied after
792 % the epigraph (usually a vertical spacing). All styles and actions
793 % are applied in the vertical mode. An \meta{author-style} can finish with
794 % one-argument macro getting the author of epigraph and formatting it.
795 %
796 % \DescribeMacro\epigraphwidth
797 % In |\epigraphparameters|, you can use the |\epigraphwidth| macro
798 % which contains a selected epigraph width.
799 %
800 % The default style is:
801 % \begin{quote}
802 % |\epigraphparameters{\StartFromHeaderArea\small\raggedleft}|\\
803 % | {.45\linewidth}{5\baselineskip}|\\
804 % | {\raggedleft\itshape}{\vspace{2ex}}|
805 % \end{quote}
806 %
807 % \DescribeMacro\StartFromTextArea
808 % The |\vspace*| command applied at the beginning of page has one serious
809 % disadvantage: it skips more space that specified in its parameter.
810 % To remove this disadvantage, we introduce the |\StartFromTextArea|
811 % command that
812 % inserts a zero-height strut and allows use the |\vspace| command after it
813 % without troubles.
814 %
815 % \DescribeMacro\StartFromHeaderArea
816 % You can also extend the text area on the header if apply the
817 % |\StartFromHeaderArea| command at the beginning of page.
818 % Such action is useful in epigraphs: the first chapter's page usually
819 % has an empty header and positioning an epigraph from the header
820 % is the good practice.{\sloppy\par}
821 %
822 % \section{Declare Part}
823 %
824 % The |\part| command in book-like classes is the only sectioning command
825 % that cannot be prepared with the |\DeclareSection| command. So, we add
826 % special declarations to provide parts in books with features of other
827 % sectioning commands.
828 %
829 % \DescribeMacro\DeclarePart
830 % To redefine the |\part| in books, use the following declaration:
831 % \begin{quote}
832 % |\DeclarePart|\marg{before}\marg{after}\marg{prefix}\marg{style}
833 % \end{quote}
834 % \begin{desclist}{}{}[\meta{before}]
835 % \item[\meta{before}] an action applied before a part at the beginning of
836 % page. It usually specifies a vertical skip |\vfil| and a
837 % paragraph style to be applied to the part number tag and title.
838 % \item[\meta{after}] an action applied after the part. It usually contains
839 % |\vfil| and page finishing commands.
840 % \item[\meta{prefix}] a prefix inserted before a part tag. It contains
841 % style commands to be applied to the tag and the |\vspace| command
842 % specifying a distance between the part tag and title.
843 % The |\partname| command goes right after the prefix.
844 % \item[\meta{style}] a style to be applied to the part title. It can end
845 % with |\MakeUppercase|.
846 % \end{desclist}
847 %
848 % The default declaration of the |\part| is the following:
849 % \begin{quote}
850 % |\DeclarePart{\StartFromTextArea\vfil\centering}%|\\
851 % | {\vfil\newpage \if@twoside\if@openright|\\
852 % | \mbox{}\thispagestyle{empty}\newpage\fi\fi}%|\\
853 % | {\vspace{4ex}\huge\bff}{\Huge\bff}|
854 % \end{quote}
855 % The |\StartFromTextArea| command prevents ignoring a vertical space
856 % at the beginning of page. All paragraphs of part title are centered
857 % horizontally using the |\centering| declaration, and the title
858 % is centered vertically using |\vfil| commands
859 % before and after it. A page after the part is made empty in two-side
860 % mode if it is even. The space after the part tag is set to |4ex|.
861 %
862 % In Russian typesetting tradition, the part can be prepared in the
863 % same manner as a chapter, i.e.\ a text going after a part is prepared
864 % on the same page with the part title. It is easy to re-declare
865 % the part in such style.
866 % Let us start a part from the header and delimit it from the text
867 % with a decorative line. The following declaration does this:
868 % \begin{quote}
869 % |\DeclarePart{\StartFromHeaderArea\centering}|\\
870 % | {\vspace{2mm}\noindent\hrulefill\par|\\
871 % | \addvspace{5mm}}|\\
872 % | {\vspace{.5em}\LARGE\bff}{\Huge\bff}|
873 % \end{quote}
874 % But when a chapter goes right after a part, we need to place the part and
875 % chapter titles together
876 % on the same page. This can be applied using the |\beforechapter| hook:
877 % \begin{quote}
878 % |\beforechapter{\part|\marg{part title}|}|\\
879 % |\chapter|\marg{chapter title}
880 % \end{quote}
881 % Modifiers stored in the parameter of |\beforechapter| hook will act on
882 % the |\part| command. Modifiers outside of |\beforechapter| will act on
883 % the |\chapter| command.
884 %
885 % \DescribeMacro\DeclareTOCPart
886 % To produce a toc-entry command for a part, the following declaration is
887 % specified for book-like classes:
888 % \begin{quote}
889 % |\DeclareTOCPart|\marg{action}\oarg{afterskip}\marg{prefix}\marg{prototype}\marg{style}
890 % \end{quote}%
891 % \begin{desclist}{}{}[\meta{afterskip}]
892 % \item[\meta{action}] an action applied before the part toc-entry. It usually
893 % a skip before part. It is recommended to prepare it with |\NCC@secskip|
894 % command.
895 % \item[\meta{afterskip}] a skip after this entry. If it is omitted,
896 % the default |\NCC@runskip| value is applied after this entry.
897 % \item[\meta{prefix}] a prefix inserted before a part tag (usually empty).
898 % \item[\meta{prototype}] a prototype of part tag used for calculation the
899 % hang indent in this entry.
900 % \item[\meta{style}] a style applied to the whole text of entry and to
901 % the page number. The |\MakeUppercase| is allowed to finish this
902 % parameter. The |\applystyle| command can be used inside it to
903 % apply different styles to the toc-entry and the page number.
904 % \end{desclist}
905 %
906 % The default declaration of the part toc-entry is the following:
907 % \begin{quote}
908 % |\DeclareTOCPart{\NCC@secskip{4ex \@plus .2ex}%|\\
909 % | \def\@dotsep{1000}}%|\\
910 % | {}{\partname\ II}{\large\bff}|\\
911 % \end{quote}
912 %
913 % \section{The Implementation}
914 %
915 % The \textbf{afterpackage} package is used to add compatibility
916 % commands.
917 % \begin{macrocode}
918 %<*package>
919 \RequirePackage{afterpackage}
920 % \end{macrocode}
921 %
922 % \begin{macro}{\NCC@secskip}
923 % \begin{macro}{\NCC@runskip}
924 % The package shares the following commands with the
925 % |nccthm| package:
926 % \begin{quote}
927 % |\NCC@secskip|\marg{skip} adds the \meta{skip} before a section,\\
928 % |\NCC@runskip| is a skip inserted before run-in sections.
929 % \end{quote}
930 % We protect the definitions of these commands with testing
931 % the |nccthm| package to be already loaded.
932 % \begin{macrocode}
933 \@ifpackageloaded{nccthm}{}{%
934 \def\NCC@secskip#1{%
935 \if@noskipsec \leavevmode \fi \par
936 \if@nobreak \everypar{}\else
937 \addpenalty\@secpenalty
938 \addvspace{#1}%
939 \fi
940 }
941 \def\NCC@runskip{2.75ex \@plus 1ex \@minus .2ex}
942 }
943 % \end{macrocode}
944 % \end{macro}
945 % \end{macro}
946 %
947 % \begin{macro}{\runinsectionskip}
948 % This command is useful in toc-entries:
949 % \begin{macrocode}
950 \newcommand{\runinsectionskip}{\NCC@secskip{\NCC@runskip}}
951 % \end{macrocode}
952 % \end{macro}
953 %
954 % \subsection{The Kernel}
955 %
956 % We start with declaring the section controls (modifiers):
957 % \begin{desclist}{\tt}{\hfill}[NCC@secstartag]\raggedright
958 % \item[NCC@nosectag] is true if |\noheadingtag| is applied;
959 % \item[NCC@secstartag] is true if |\headingtag*|\marg{tag} is applied;
960 % \item[\cs{NCC@sectag}] saves a value of the |\headingtag| parameter;
961 % \item[NCC@nosecmark] is true if |\norunninghead| is applied;
962 % \item[\cs{NCC@secmark}\rm\marg{mark-command}] executes the \meta{mark-command}
963 % with the parameter of |\runninghead| command;
964 % \item[NCC@noaux] is true if |\skipwritingtoaux| is applied.
965 % \end{desclist}
966 % \begin{macrocode}
967 \newif\ifNCC@nosectag
968 \newif\ifNCC@secstartag
969 \newif\ifNCC@nosecmark
970 \newif\ifNCC@noaux
971 % \end{macrocode}
972 %
973 % \begin{macro}{\NCC@global}
974 % We reset all controls globally, but in the |\beforechapter|
975 % hook we need to reset them locally. So, we reset all controls
976 % using the |\NCC@global| modifier which value is |\global| by default.
977 % \begin{macrocode}
978 \let\NCC@global\global
979 % \end{macrocode}
980 % \end{macro}
981 %
982 % \begin{macro}{\NCC@sec@reset@controls}
983 % This command resets all controls to default values.
984 % It must be applied at the end of every section command.
985 % \begin{macrocode}
986 \def\NCC@sec@reset@controls{%
987 \NCC@global\NCC@nosectagfalse
988 \NCC@global\NCC@secstartagfalse
989 \NCC@global\let\NCC@sectag\relax
990 \NCC@global\NCC@nosecmarkfalse
991 \NCC@global\let\NCC@secmark\relax
992 \NCC@global\NCC@noauxfalse
993 }
994 \NCC@sec@reset@controls
995 % \end{macrocode}
996 % \end{macro}
997 %
998 % \begin{macro}{\norunninghead}
999 % \begin{macro}{\runninghead}
1000 % \begin{macro}{\noheadingtag}
1001 % \begin{macro}{\headingtag}
1002 % \begin{macro}{\headingtag*}
1003 % \begin{macro}{\skipwritingtoaux}
1004 % User interface to section controls:
1005 % \begin{macrocode}
1006 \newcommand{\norunninghead}{\NCC@global\NCC@nosecmarktrue}
1007 \newcommand*{\runninghead}[1]{\NCC@global\def\NCC@secmark##1{##1{#1}}}
1008 \newcommand{\noheadingtag}{\NCC@global\NCC@nosectagtrue}
1009 \newcommand{\headingtag}{%
1010 \@ifstar{\NCC@global\NCC@secstartagtrue\NCC@setsectag}{\NCC@setsectag}%
1011 }
1012 \def\NCC@setsectag#1{\NCC@global\def\NCC@sectag{#1}}
1013 \newcommand{\skipwritingtoaux}{\NCC@global\NCC@noauxtrue}
1014 % \end{macrocode}
1015 % \end{macro}
1016 % \end{macro}
1017 % \end{macro}
1018 % \end{macro}
1019 % \end{macro}
1020 % \end{macro}
1021 %
1022 % \begin{macro}{\NCC@makesection}
1023 % The |\NCC@makesection|\marg{type}\marg{level}\marg{toc-entry}\marg{toc-action}
1024 % produces a section or caption. It analyzes the modifiers and customizes
1025 % sections or captions. The \meta{toc-action} parameter contains an
1026 % attendant action that must be applied at the end of macro.
1027 % It writes a toc-entry to aux-file.
1028 %
1029 % The command uses the following hooks that must be prepared
1030 % before its call:
1031 % \begin{desclist}{}{}[\cs{NCC@make}\marg{action}]
1032 % \item[\cs{NCC@makesectag}\marg{value}] produces a tag in |\@svsec|
1033 % using the given value;
1034 %
1035 % \item[\cs{NCC@make}\marg{action}] makes a section or caption heading
1036 % and applies the \meta{action} after heading. Before the call
1037 % of this command, the |\@svsec| macro is prepared (it contains a
1038 % prepared tag).
1039 % \end{desclist}
1040 % We start from the case when the |\headingtag*|\marg{tag} modifier was
1041 % applied and the section tag was saved in the |\NCC@sectag| macro.
1042 % We apply the |\NCC@make| procedure with the given section tag.
1043 % Attendant actions are ignored for this case.
1044 % \begin{macrocode}
1045 \def\NCC@makesection#1#2#3#4{%
1046 \ifNCC@secstartag
1047 \let\@svsec\NCC@sectag
1048 \NCC@make{}%
1049 \else
1050 % \end{macrocode}
1051 % Prepare a tag creation command in the |\the|\meta{type} macro.
1052 % We can do some temporary changes here that will be restored
1053 % at the end of macro. The restore hook is prepared in the
1054 % |\NCC@restsec| command.
1055 % \begin{macrocode}
1056 \ifx\NCC@sectag\relax
1057 % \end{macrocode}
1058 % The |\noheadingtag| case: we temporary set the |secnumdepth|
1059 % counter to very low negative value. This prevents numbering
1060 % this section:
1061 % \begin{macrocode}
1062 \ifNCC@nosectag
1063 \edef\NCC@restsec{%
1064 \noexpand\c@secnumdepth \the\c@secnumdepth\relax
1065 }%
1066 \c@secnumdepth -1000
1067 % \end{macrocode}
1068 % The ordinary case: No restore actions is necessary here.
1069 % \begin{macrocode}
1070 \else
1071 \let\NCC@restsec\relax
1072 \ifnum#2>\c@secnumdepth \else\refstepcounter{#1}\fi
1073 \fi
1074 % \end{macrocode}
1075 % The |\headingtag|\marg{tag} case: we temporary let the
1076 % |\the|\meta{type} macro to be equal to the |\NCC@sectag|
1077 % command produced by the |\headingtag|,
1078 % save the original value in the |\NCC@thesec| command,
1079 % and prepare the |\NCC@restsec| macro.
1080 % \begin{macrocode}
1081 \else
1082 \expandafter\let\expandafter\NCC@thesec\csname the#1\endcsname
1083 \def\NCC@restsec{%
1084 \expandafter\let\csname the#1\endcsname\NCC@thesec
1085 }%
1086 \expandafter\let\csname the#1\endcsname\NCC@sectag
1087 \protected@edef\@currentlabel{\NCC@sectag}%
1088 \fi
1089 % \end{macrocode}
1090 %
1091 % Prepare section tag in the |\@svsec| command:
1092 % \begin{macrocode}
1093 \ifnum #2>\c@secnumdepth
1094 \let\@svsec\@empty
1095 \else
1096 \protected@edef\@svsec{%
1097 \protect\NCC@makesectag{\csname the#1\endcsname}%
1098 }%
1099 \fi
1100 % \end{macrocode}
1101 %
1102 % We cannot do the marking right now because the producing of section
1103 % can be suspended to the beginning of the nearest paragraph
1104 % (in run-in sections). So, we need to prepare a mark action
1105 % in a command that will save its state as long as necessary.
1106 % This command is |\NCC@makemark|.
1107 % \begin{macrocode}
1108 \let\NCC@makemark\@empty
1109 \@ifundefined{#1mark}{}{%
1110 \ifx\NCC@secmark\relax
1111 % \end{macrocode}
1112 % Ordinary case: prepare the section mark with the
1113 % \meta{toc-entry} parameter.
1114 % \begin{macrocode}
1115 \ifNCC@nosecmark \else
1116 \def\NCC@makemark{\csname #1mark\endcsname{#3}}%
1117 \fi
1118 % \end{macrocode}
1119 % The |\runninghead|\marg{heading} case:
1120 % pass the mark command in the parameter of |\NCC@secmark|.
1121 % We need to save the |\NCC@secmark| value in some command
1122 % and pass this command within |\NCC@makemark| because
1123 % the |\NCC@secmark| could be removed before the use.
1124 % \begin{macrocode}
1125 \else
1126 \let\NCC@savesecmark\NCC@secmark
1127 \def\NCC@makemark{%
1128 \NCC@savesecmark{\csname #1mark\endcsname}%
1129 \let\NCC@savesecmark\relax
1130 }%
1131 \fi
1132 }%
1133 % \end{macrocode}
1134 %
1135 % Make the section. We must apply the restore action at
1136 % the end action of |\NCC@make| command by the same reason that
1137 % the section making may be suspended:
1138 % \begin{macrocode}
1139 \ifNCC@noaux
1140 \NCC@make{\NCC@makemark \NCC@restsec}%
1141 \else
1142 \NCC@make{\NCC@makemark #4\NCC@restsec}%
1143 \fi
1144 % \end{macrocode}
1145 %
1146 % Reset modifiers:
1147 % \begin{macrocode}
1148 \fi
1149 \NCC@sec@reset@controls
1150 }
1151 % \end{macrocode}
1152 % \end{macro}
1153 %
1154 % \subsection{Section Making Commands}
1155 %
1156 % \begin{macro}{\indentaftersection}
1157 % \begin{macro}{\noindentaftersection}
1158 % Introduce macros controlling indentation after display sections:
1159 % \begin{macrocode}
1160 \newcommand{\indentaftersection}{\@afterindenttrue}
1161 \newcommand{\noindentaftersection}{\@afterindentfalse}
1162 % \end{macrocode}
1163 % \end{macro}
1164 % \end{macro}
1165 %
1166 % \begin{macro}{\SectionTagSuffix}
1167 % The |\SectionTagSuffix|\marg{suffix} sets a default suffix after
1168 % a section tag.
1169 % \begin{macrocode}
1170 \newcommand*{\SectionTagSuffix}[1]{\def\NCC@asecnum{#1}}
1171 \@onlypreamble\SectionTagSuffix
1172 % \end{macrocode}
1173 % \end{macro}
1174 %
1175 % \begin{macro}{\sectiontagsuffix}
1176 % |\sectiontagsuffix|\oarg{type}\marg{suffix} changes a suffix after section
1177 % tag that will be used for sections of the given
1178 % \meta{type}. If \meta{type} is omitted, the specified suffix will be used
1179 % in text flow for all sections having no special suffix.
1180 % \begin{macrocode}
1181 \newcommand*\sectiontagsuffix[2][]{%
1182 \expandafter\def\csname NCC@asecnum@#1\endcsname{\def\NCC@asecnum{#2}}%
1183 }
1184 \let\NCC@asecnum@\@empty
1185 \def\NCC@setsectionsuffix#1{%
1186 \edef\@tempa{NCC@asecnum@\NCC@secname{#1}}%
1187 \@ifundefined{\@tempa}{%
1188 \let\NCC@asecnumset\NCC@asecnum@
1189 }{%
1190 \expandafter\let\expandafter\NCC@asecnumset\csname\@tempa\endcsname
1191 }%
1192 }
1193 % \end{macrocode}
1194 % \end{macro}
1195 %
1196 % \begin{macro}{\RunningSectionSuffix}
1197 % The |\RunningSectionSuffix|\marg{suffix} sets a suffix after a title
1198 % of a running section:
1199 % \begin{macrocode}
1200 \newcommand*{\RunningSectionSuffix}[1]{\def\NCC@asectitle{\unskip#1}}
1201 \@onlypreamble\RunningSectionSuffix
1202 % \end{macrocode}
1203 % \end{macro}
1204 %
1205 % \begin{macro}{\NCC@preparesectag}
1206 % The |\NCC@preparesectag|\marg{style}\marg{before} hook prepares the
1207 % |\NCC@makesectag| command:
1208 % \begin{macrocode}
1209 \def\NCC@preparesectag#1#2{\def\NCC@makesectag##1{#1#2##1\NCC@asecnum}}
1210 % \end{macrocode}
1211 % \end{macro}
1212 %
1213 % \begin{macro}{\NCC@secname}
1214 % The |\NCC@secname|\marg{level} command generates section name
1215 % (|main|, |section|, |subsection|, \ldots,
1216 % or |section@vi|, |section@vii|, \ldots\ for new section levels).
1217 % This name is used as the second parameter of the |\addcontentsline|
1218 % command, in the declarations of toc-entries, and in the style
1219 % selection command.
1220 % \begin{macrocode}
1221 \def\NCC@secname#1{%
1222 \ifcase#1main\or section\or subsection\or subsubsection\or
1223 paragraph\or subparagraph\else section@\romannumeral#1\fi
1224 }
1225 % \end{macrocode}
1226 % \end{macro}
1227 %
1228 % \begin{macro}{\NCC@startsection}
1229 % The |\NCC@startsection| command
1230 % has the same syntax as its non-NCC prototype:
1231 % \begin{quote}
1232 % |\NCC@startsection|\marg{type}\marg{level}\marg{indent}\marg{beforeskip}\\
1233 % | |\marg{afterskip}\marg{style}
1234 % \end{quote}
1235 % but works in a bit different way: it ignores the sign of
1236 % \meta{beforeskip}. In the original version the testing
1237 % was applied to set an appropriate |afterindent| mode.
1238 % But we change this mode using |\indentaftersection| and
1239 % |\noindentaftersection| macros.
1240 % \begin{macrocode}
1241 \def\NCC@startsection#1#2#3#4#5#6{%
1242 \@tempskipa #4\relax
1243 \ifdim \@tempskipa <\z@ \@temskipa -\@tempskipa \fi
1244 \NCC@secskip \@tempskipa
1245 \secdef{\NCC@sect{#1}{#2}{#3}{#4}{#5}{#6}}{\NCC@ssect{#3}{#4}{#5}{#6}}%
1246 }
1247 % \end{macrocode}
1248 % \end{macro}
1249 %
1250 % \begin{macro}{\NCC@makesec}
1251 % The interface of |\NCC@ssect| and |\NCC@sect| commands is similar to their
1252 % \LaTeX's prototypes. They are based on the following
1253 % command:
1254 % \begin{quote}
1255 % |\NCC@makesec|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
1256 % \end{quote}
1257 % In fact, there are two versions of this command:
1258 % the traditional version, |\NCC@makesect|, and the
1259 % version with dynamic control of section style,\linebreak |\NCC@makesecx|.
1260 % One of them should be selected before applying the |\NCC@ssect| and |\NCC@sect|
1261 % commands.
1262 % \end{macro}
1263 %
1264 % \begin{macro}{\NCC@ssect}
1265 % The starred form of section:
1266 % \begin{quote}
1267 % |\NCC@ssect|\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{heading}
1268 % \end{quote}
1269 % \begin{macrocode}
1270 \def\NCC@ssect#1#2#3#4#5{%
1271 \let\@svsec\@empty
1272 \NCC@makesec{#1}{#4}{#5}{#3}{}%
1273 \NCC@sec@reset@controls
1274 }
1275 % \end{macrocode}
1276 % \end{macro}
1277 %
1278 % \begin{macro}{\NCC@sect}
1279 % The base form of section:
1280 % \begin{quote}
1281 % |\NCC@sect|\marg{type}\marg{level}\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\\
1282 % | |\oarg{toc-entry}\marg{heading}
1283 % \end{quote}
1284 % \begin{macrocode}
1285 \def\NCC@sect#1#2#3#4#5#6[#7]#8{%
1286 \def\NCC@make{\NCC@makesec{#3}{#6}{#8}{#5}}%
1287 \NCC@makesection{#1}{#2}{#7}{%
1288 \addcontentsline{toc}{\NCC@secname{#2}}{%
1289 \ifnum #2>\c@secnumdepth \else
1290 \numberline{\csname the#1\endcsname}%
1291 \fi
1292 #7%
1293 }%
1294 }%
1295 }
1296 % \end{macrocode}
1297 % \end{macro}
1298 %
1299 % \begin{macro}{\NCC@makesect}
1300 % The traditional section making command:
1301 % \begin{quote}
1302 % |\NCC@makesect|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
1303 % \end{quote}
1304 % \begin{macrocode}
1305 \def\NCC@makesect#1#2#3#4#5{%
1306 \@tempskipa #4\relax
1307 \ifdim \@tempskipa>\z@
1308 \begingroup \normalfont
1309 \NCC@asecnumset
1310 % \end{macrocode}
1311 % The |\NCC@secttitle|\marg{style}\marg{tag}\marg{title} hook prepares
1312 % traditional display section:
1313 % \begin{macrocode}
1314 \NCC@secttitle{#2}{\NCC@hangfrom{\hskip #1\relax\@svsec}}%
1315 {\interlinepenalty \@M\ignorespaces #3\@@par}
1316 \endgroup
1317 #5%
1318 \else
1319 % \end{macrocode}
1320 % The |\NCC@secptitle|\marg{style}\marg{tag}\marg{title} hook prepares
1321 % running section. The |\norunningsuffix| modifier applied in the
1322 % parameter of running section removes a suffix after section title.
1323 % \begin{macrocode}
1324 \def\@svsechd{{\normalfont
1325 \NCC@asecnumset
1326 \def\norunningsuffix{\protect\NCC@nosecsuffix}%
1327 \NCC@secptitle{#2}{\hskip #1\relax{\@svsec}}%
1328 {\ignorespaces #3\NCC@asectitle}#5}}%
1329 \fi
1330 \@xsect{#4}%
1331 }
1332 \def\NCC@secttitle#1#2#3{#1{#2#3}}
1333 \def\NCC@secptitle#1#2#3{#1{#2#3}}
1334 \newcommand*\norunningsuffix{}
1335 \def\NCC@nosecsuffix{\let\NCC@asectitle\@empty}
1336 % \end{macrocode}
1337 % \end{macro}
1338 %
1339 % \subsection{Create Section Styles}
1340 %
1341 % \begin{macro}{\NCC@hangfrom}
1342 % |\NCC@hangfrom|\marg{section tag} works as
1343 % the \LaTeX's |\@hangfrom| command, but its margins can be adjusted
1344 % with the |\adjustsectionmargins| command.
1345 % \begin{macrocode}
1346 \def\NCC@hangfrom{%
1347 \NCC@setsecmargins{\z@skip}{\z@skip}\NCC@hangsecstyle{\z@}{}%
1348 }
1349 % \end{macrocode}
1350 % \end{macro}
1351 %
1352 % \begin{macro}{\NCC@setsecmargins}
1353 % |\NCC@setsecmargins|\marg{left skip}\marg{right skip} sets
1354 % section margins and applies the hook that can be defined by the
1355 % |\adjustsectionmargins| command.
1356 % \begin{macrocode}
1357 \def\NCC@setsecmargins#1#2{%
1358 \leftskip\z@skip \rightskip\z@skip
1359 \parfillskip\@flushglue
1360 \let\\\@normalcr
1361 \NCC@adjsecmargins{#1}{#2}%
1362 \NCC@secmarginshook
1363 }
1364 % \end{macrocode}
1365 % \end{macro}
1366 %
1367 % \begin{macro}{\NCC@adjsecmargins}
1368 % |\NCC@adjsecmargins|\marg{left skip}\marg{right skip} adjusts
1369 % section margins. The |\parfillskip| value is also adjusted to
1370 % a difference between stretchabilities of the \meta{left skip}
1371 % and the \meta{right skip}. Using this trick, we can easy specify
1372 % the |centerlast| style just setting the stretchability of the
1373 % \meta{right skip} as a negation of the \meta{left skip} stretchability.
1374 % To extract a stretchability from a skip, we simply add it multiplied
1375 % by |-1| (while multiplication the stretchability is removed!).
1376 % \begin{macrocode}
1377 \def\NCC@adjsecmargins#1#2{%
1378 \setlength\@tempskipa{#1}\advance\leftskip\@tempskipa
1379 \setlength\@tempskipb{#2}\advance\rightskip\@tempskipb
1380 \advance\@tempskipa -1\@tempskipa \advance\@tempskipb -1\@tempskipb
1381 \advance\@tempskipa -\@tempskipb \advance\parfillskip\@tempskipa
1382 }
1383 % \end{macrocode}
1384 % \end{macro}
1385 %
1386 % \begin{macro}{\NCC@hangsecstyle}
1387 % |\NCC@hangsecstyle|\marg{min tag width}\marg{pos}\marg{section tag}
1388 % starts a hang paragraph and prints its tag. The \meta{min tag width}
1389 % specifies a minimum width of hang indent and \meta{pos} specifies
1390 % an alignment of \meta{section tag} (|l|, |c|, |r|) if its width
1391 % is less than the minimum width.
1392 % \begin{macrocode}
1393 \def\NCC@hangsecstyle#1#2#3{%
1394 \setlength\@tempdima{#1}%
1395 \setbox\@tempboxa\hbox{#3}%
1396 \ifdim \wd\@tempboxa > \@tempdima
1397 \hangindent\wd\@tempboxa \noindent \box\@tempboxa
1398 \else
1399 \hangindent\@tempdima
1400 \noindent \makebox[\@tempdima][#2]{\unhbox\@tempboxa}%
1401 \fi
1402 }
1403 % \end{macrocode}
1404 % \end{macro}
1405 %
1406 % \begin{macro}{\adjustsectionmargins}
1407 % |\adjustsectionmargins|\marg{left skip}\marg{right skip}
1408 % defines the |\NCC@secmarginshook| macro to be applied after
1409 % margins are set. To be sure this hook will be applied only once,
1410 % we release it in the |\NCC@sec@reset@controls| hook.
1411 % \begin{macrocode}
1412 \newcommand*\adjustsectionmargins[2]{%
1413 \NCC@global\def\NCC@secmarginshook{\NCC@adjsecmargins{#1}{#2}}
1414 }
1415 \g@addto@macro\NCC@sec@reset@controls{%
1416 \NCC@global\let\NCC@secmarginshook\@empty
1417 }
1418 \let\NCC@secmarginshook\@empty
1419 % \end{macrocode}
1420 % \end{macro}
1421 %
1422 % \begin{macro}{\NCC@sec}
1423 % A style of sections having dynamic control is defined by the
1424 % |\NCC@sec|\marg{tag} hook. This hook is applied inside a group
1425 % preparing a heading. All section style commands redefine this hook.
1426 % \end{macro}
1427 %
1428 % \begin{macro}{\newplainsectionstyle}
1429 % |\newplainsectionstyle|\marg{name}\marg{indent}\oarg{pos}\marg{left skip}\marg{right skip}
1430 % \begin{macrocode}
1431 \newcommand*\newplainsectionstyle[2]{%
1432 \@ifnextchar[{\NCC@newplainsec{#1}{#2}}{\NCC@newplainsec{#1}{#2}[l]}%
1433 }
1434 \def\NCC@newplainsec#1#2[#3]#4#5{%
1435 \def\@tempa{#3}\def\@tempb{c}%
1436 \ifx\@tempa\@tempb
1437 \expandafter\newcommand\csname NCC@sec@#1\endcsname
1438 {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}%
1439 \let\\\@centercr \advance\parfillskip -\@flushglue
1440 \setlength\parindent{#2}}}%
1441 \else
1442 \def\@tempb{r}%
1443 \ifx\@tempa\@tempb
1444 \expandafter\newcommand\csname NCC@sec@#1\endcsname
1445 {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}%
1446 \let\\\@centercr \advance\parfillskip -\@flushglue
1447 \advance\parfillskip -\@flushglue
1448 \setlength\parindent{#2}}}%
1449 \else
1450 \expandafter\newcommand\csname NCC@sec@#1\endcsname
1451 {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}\setlength\parindent{#2}}}%
1452 \fi
1453 \fi
1454 }
1455 \@onlypreamble\newplainsectionstyle
1456 \@onlypreamble\NCC@newplainsec
1457 % \end{macrocode}
1458 % \end{macro}
1459 %
1460 % \begin{macro}{\newhangsectionstyle}
1461 % |\newhangsectionstyle|\marg{name}\marg{min tag width}\oarg{pos}\marg{left skip}\marg{right skip}
1462 % \begin{macrocode}
1463 \newcommand*\newhangsectionstyle[2]{%
1464 \@ifnextchar[{\NCC@newhangsec{#1}{#2}}{\NCC@newhangsec{#1}{#2}[l]}%
1465 }
1466 \def\NCC@newhangsec#1#2[#3]#4#5{%
1467 \expandafter\newcommand\csname NCC@sec@#1\endcsname
1468 {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}\NCC@hangsecstyle{#2}{#3}}}%
1469 }
1470 \@onlypreamble\newhangsectionstyle
1471 \@onlypreamble\NCC@newhangsec
1472 % \end{macrocode}
1473 % \end{macro}
1474 %
1475 % Specify predefined section styles. The |\@flushglue| is equal to |0pt plus 1fil|.
1476 % \begin{macrocode}
1477 \newhangsectionstyle{hangindent}{\z@}{\z@skip}{\z@skip}
1478 \newhangsectionstyle{hangindent*}{\z@}{\z@skip}{\@flushglue}
1479 \newhangsectionstyle{hangparindent}{\z@}{\parindent}{\z@skip}
1480 \newhangsectionstyle{hangparindent*}{\z@}{\parindent}{\@flushglue}
1481 \newplainsectionstyle{parindent}{\z@}{\parindent}{\z@skip}
1482 \newplainsectionstyle{parindent*}{\z@}{\parindent}{\@flushglue}
1483 \newplainsectionstyle{center}{\z@}[c]{\@flushglue}{\@flushglue}
1484 \newplainsectionstyle{centerlast}{\z@}[c]{\@flushglue}{-\@flushglue}
1485 % \end{macrocode}
1486 %
1487 % \subsection{Make Sections with Dynamic Control}
1488 %
1489 % \begin{macro}{\sectionstyle}
1490 % The |\sectionstyle|\oarg{type}\marg{style} changes a style
1491 % for display sections of the given \meta{type}.
1492 % \begin{macrocode}
1493 \newcommand*{\sectionstyle}[2][]{%
1494 \@ifundefined{NCC@sec@#2}{%
1495 \PackageError{nccsect}{Unknown section style `#2'}{}%
1496 }{%
1497 \expandafter\def\csname NCC@secstyle@#1\endcsname{%
1498 \csname NCC@sec@#2\endcsname
1499 }%
1500 }%
1501 }
1502 % \end{macrocode}
1503 % \end{macro}
1504 %
1505 % \begin{macro}{\NCC@setsectionstyle}
1506 % The |\NCC@setsectionstyle|\marg{level} set a style for the
1507 % given section level. If a style for the given level is
1508 % undefined, the default style is selected.
1509 % \begin{macrocode}
1510 \def\NCC@setsectionstyle#1{%
1511 \edef\@tempa{NCC@secstyle@\NCC@secname{#1}}%
1512 \@ifundefined{\@tempa}{\NCC@secstyle@}{\csname\@tempa\endcsname}%
1513 }
1514 % \end{macrocode}
1515 % \end{macro}
1516 %
1517 % \begin{macro}{\NCC@makesecx}
1518 % The dynamic section making command:
1519 % \begin{quote}
1520 % |\NCC@makesecx|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
1521 % \end{quote}
1522 % It prepares only display sections and ignores the \meta{indent} parameter.
1523 % \begin{macrocode}
1524 \def\NCC@makesecx#1#2#3#4#5{%
1525 \begingroup\normalfont
1526 \NCC@asecnumset
1527 % \end{macrocode}
1528 % The |\NCC@secxtitle|\marg{style}\marg{tag}\marg{title} hook prepares
1529 % display section with dynamic control. The |\NCC@sec| macro is protected
1530 % to prevent its expansion by |\MakeUppercase|.
1531 % \begin{macrocode}
1532 \NCC@secxtitle{#2}{\protect\NCC@sec{\@svsec}}
1533 {\interlinepenalty \@M\ignorespaces #3\@@par}%
1534 \endgroup #5%
1535 \par \nobreak \vskip #4\relax \@afterheading \ignorespaces
1536 }
1537 \def\NCC@secxtitle#1#2#3{#1{#2#3}}
1538 % \end{macrocode}
1539 % \end{macro}
1540 %
1541 % \subsection{Make the Main Section}
1542 %
1543 % \begin{macro}{\partmark}
1544 % Define the |\partmark| if it is undefined yet.
1545 % \begin{macrocode}
1546 \providecommand*\partmark[1]{\markboth{}{}}
1547 % \end{macrocode}
1548 % \end{macro}
1549 %
1550 % \begin{macro}{\NCC@startmainsec}
1551 % The main section is a section of zero level.
1552 % It is prepared with the following command:
1553 % \begin{quote}
1554 % |\NCC@startmainsec|\marg{alignment}\marg{prefix}\marg{beforeskip}\\
1555 % | |\marg{afterskip}\marg{style}
1556 % \end{quote}
1557 % It starts either a new chapter or a new part depending on the class
1558 % loaded. To decide what version should be prepared, we test the
1559 % |\chapter| command on existence.
1560 % \begin{macrocode}
1561 \@ifundefined{chapter}{%
1562 % \end{macrocode}
1563 %
1564 % The case of an article-like class. Zero-level section is the |\part|.
1565 % \begin{macrocode}
1566 \def\NCC@startmainsec#1#2#3#4#5{%
1567 \NCC@preparesectag{\leavevmode#2}{\partname\nobreakspace}%
1568 \NCC@secskip{#3}%
1569 \secdef{\NCC@part{#1}{#4}{#5}}{\NCC@spart{#1}{#4}{#5}}%
1570 }
1571 % \end{macrocode}
1572 %
1573 % \begin{macro}{\NCC@spart}
1574 % Prepare the starred version of part:
1575 % \begin{quote}
1576 % |\NCC@spart|\marg{alignment}\marg{afterskip}\marg{style}\marg{heading}
1577 % \end{quote}
1578 % \begin{macrocode}
1579 \def\NCC@spart#1#2#3#4{%
1580 \let\@svsec\@empty
1581 \NCC@makepart{#1}{#3}{#4}{#2}{}%
1582 \NCC@sec@reset@controls
1583 }
1584 % \end{macrocode}
1585 % \end{macro}
1586 %
1587 % \begin{macro}{\NCC@part}
1588 % Prepare the non-starred version of part:
1589 % \begin{quote}
1590 % |\NCC@part|\marg{alignment}\marg{afterskip}\marg{style}\oarg{toc-entry}\marg{heading}
1591 % \end{quote}
1592 % \begin{macrocode}
1593 \def\NCC@part#1#2#3[#4]#5{%
1594 \def\NCC@make{\NCC@makepart{#1}{#3}{#5}{#2}}%
1595 \NCC@makesection{part}{\z@}{#4}{%
1596 \addcontentsline{toc}{part}{%
1597 \ifnum \c@secnumdepth>\m@ne \numberline{\thepart}\fi
1598 #4%
1599 }%
1600 }%
1601 }
1602 % \end{macrocode}
1603 % \end{macro}
1604 %
1605 % \begin{macro}{\NCC@makepart}
1606 % This command makes a part.
1607 % \begin{quote}
1608 % |\NCC@makepart|\marg{alignment}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
1609 % \end{quote}
1610 % The |\@svsec| is either |\@empty| or contains a part tag.
1611 % \begin{macrocode}
1612 \def\NCC@makepart#1#2#3#4#5{%
1613 \begingroup \normalfont
1614 \NCC@asecnumset
1615 \NCC@makeparttitle{#1}{#2}{#3}%
1616 \endgroup
1617 #5%
1618 \par\nobreak \vskip #4\relax \@afterheading \ignorespaces
1619 }
1620 % \end{macrocode}
1621 % \end{macro}
1622 %
1623 % \begin{macro}{\NCC@makeparttitle}
1624 % This command makes a part title itself. The |\NCC@secmain| hook contains
1625 % the dynamic alignment style or nothing.
1626 % \begin{quote}
1627 % |\NCC@makeparttitle|\marg{alignment}\marg{style}\marg{heading}
1628 % \end{quote}
1629 % \begin{macrocode}
1630 \def\NCC@makeparttitle#1#2#3{%
1631 \ifx\@svsec\@empty \else
1632 \NCC@secmain#1{\let\NCC@asecnum\@empty\@svsec\@@par}\nobreak
1633 \fi
1634 \interlinepenalty \@M \NCC@secmain#1{#2{#3\@@par}}%
1635 }
1636 % \end{macrocode}
1637 % \end{macro}
1638 %
1639 % \begin{macro}{\NCC@partsection}
1640 % Define the |\NCC@partsection| to be equal to the |\NCC@mainsection| command
1641 % which will be specified later when a main section will be declared.
1642 % \begin{macrocode}
1643 \def\NCC@partsection{\NCC@mainsection}
1644 }{
1645 % \end{macrocode}
1646 % \end{macro}
1647 %
1648 % The case of a book-like class. Zero-level section is the |\chapter|.
1649 % \begin{macrocode}
1650 \def\NCC@startmainsec#1#2#3#4#5{%
1651 \NCC@startchap
1652 \NCC@preparesectag{\leavevmode#2}{\@chapapp\nobreakspace}%
1653 \secdef{\NCC@chapter{#1}{#3}{#4}{#5}}{\NCC@schapter{#1}{#3}{#4}{#5}}%
1654 }
1655 % \end{macrocode}
1656 %
1657 % \begin{macro}{\NCC@startchap}
1658 % The start chapter hook:
1659 % \begin{macrocode}
1660 \def\NCC@startchap{%
1661 \if@openright\cleardoublepage\else\clearpage\fi
1662 \thispagestyle{plain}\global\@topnum\z@
1663 }
1664 % \end{macrocode}
1665 % \end{macro}
1666 %
1667 % \begin{macro}{\NCC@schapter}
1668 % Prepare the starred version of chapter:
1669 % \begin{quote}
1670 % |\NCC@schapter|\marg{alignment}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{heading}
1671 % \end{quote}
1672 % \begin{macrocode}
1673 \def\NCC@schapter#1#2#3#4#5{%
1674 \let\@svsec\@empty
1675 \NCC@makechapter{#1}{#2}{#4}{#5}{#3}{}%
1676 \NCC@sec@reset@controls
1677 }
1678 % \end{macrocode}
1679 % \end{macro}
1680 %
1681 % \begin{macro}{\NCC@chapter}
1682 % Prepare the non-starred version of chapter:
1683 % \begin{quote}
1684 % |\NCC@chapter|\marg{alignment}\marg{beforeskip}\marg{afterskip}\marg{style}\\
1685 % | |\oarg{toc-entry}\marg{heading}
1686 % \end{quote}
1687 % It uses the |\NCC@infloats|\marg{action} hook that applies the specified
1688 % action for all registered float types.
1689 % \begin{macrocode}
1690 \def\NCC@chapter#1#2#3#4[#5]#6{%
1691 \@ifundefined{if@mainmatter}{}{\if@mainmatter\else\noheadingtag\fi}%
1692 \def\NCC@make{\NCC@makechapter{#1}{#2}{#4}{#6}{#3}}%
1693 \NCC@makesection{chapter}{\z@}{#5}{%
1694 \typeout{\@chapapp\space\thechapter.}%
1695 \addcontentsline{toc}{chapter}{%
1696 \ifnum \c@secnumdepth>\m@ne
1697 \numberline{\NCC@thetocchapter}\fi
1698 #5%
1699 }%
1700 \NCC@infloats{\addtocontents{\@nameuse{ext@\@captype}}%
1701 {\protect\runinsectionskip}}%
1702 }%
1703 }
1704 % \end{macrocode}
1705 % \end{macro}
1706 %
1707 % \begin{macro}{\beforechapter}
1708 % The |\beforechapter|\marg{something} hook is applied to the nearest
1709 % chapter. An empty value of its parameter means no hook.
1710 % \begin{macrocode}
1711 \newcommand\beforechapter[1]{\gdef\NCC@beforechapter{#1}}
1712 \beforechapter{}
1713 % \end{macrocode}
1714 % \end{macro}
1715 %
1716 % \begin{macro}{\NCC@thetocchapter}
1717 % The following hook allows redefine the appearance of chapter name
1718 % in the TOC:
1719 % \begin{macrocode}
1720 \def\NCC@thetocchapter{\thechapter}
1721 % \end{macrocode}
1722 % \end{macro}
1723 %
1724 % \begin{macro}{\NCC@makechapter}
1725 % This command makes a chapter:
1726 % \begin{quote}
1727 % |\NCC@makechapter|\marg{alignment}\marg{beforeskip}\marg{style}\marg{heading}\\
1728 % | |\marg{afterskip}\marg{action}
1729 % \end{quote}
1730 % The |\@svsec| is either |\@empty| or contains a chapter tag.
1731 % \begin{macrocode}
1732 \def\NCC@makechapter#1#2#3#4#5#6{%
1733 \if@twocolumn
1734 \@topnewpage[\NCC@makechaphead{#1}{#2}{#3}{#4}{#5}]%
1735 \else
1736 \NCC@makechaphead{#1}{#2}{#3}{#4}{#5}%
1737 \fi
1738 \NCC@makechapfinal{#6}%
1739 \@afterheading
1740 \ignorespaces
1741 }
1742 % \end{macrocode}
1743 % \end{macro}
1744 %
1745 % \begin{macro}{\NCC@makechapfinal}
1746 % \begin{macro}{\NCC@makechapfinalgobble}
1747 % The |\NCC@makechapfinal| hook applies a final action which can contain the
1748 % |\chaptermark| command. Its default value is to put the parameter as is.
1749 % If you let this command to be equal to the |\NCC@makechapfinalgobble|, the
1750 % chapter mark will contain no chapter name.
1751 % \begin{macrocode}
1752 \let\NCC@makechapfinal\@firstofone
1753 \def\NCC@makechapfinalgobble#1{%
1754 \let\NCC@makechapmark\NCC@makemark
1755 \def\NCC@makemark{%
1756 \let\NCC@temp\@chapapp
1757 \let\@chapapp\@gobble
1758 \NCC@makechapmark
1759 \let\@chapapp\NCC@temp
1760 }%
1761 #1%
1762 }
1763 \@onlypreamble\NCC@makechapfinalgobble
1764 % \end{macrocode}
1765 % \end{macro}
1766 % \end{macro}
1767 %
1768 % \begin{macro}{\NCC@makechaphead}
1769 % This command makes a chapter head:
1770 % \begin{quote}
1771 % |\NCC@makechaphead|\marg{alignment}\marg{beforeskip}\marg{style}\marg{heading}\\
1772 % | |\marg{afterskip}
1773 % \end{quote}
1774 % \begin{macrocode}
1775 \def\NCC@makechaphead#1#2#3#4#5{%
1776 \ifx\NCC@beforechapter\@empty
1777 \StartFromTextArea \vskip #2%
1778 \else
1779 \begingroup
1780 \@twocolumnfalse
1781 \let\NCC@global\@empty
1782 \NCC@sec@reset@controls
1783 \normalfont \NCC@beforechapter \par
1784 \endgroup
1785 \beforechapter{}%
1786 \fi
1787 \begingroup \normalfont
1788 \NCC@asecnumset
1789 \NCC@makechaptitle{#1}{#3}{#4}%
1790 \endgroup
1791 \par\nobreak \vskip #5\relax
1792 }
1793 % \end{macrocode}
1794 % \end{macro}
1795 %
1796 % \begin{macro}{\NCC@makechaptitle}
1797 % This command makes a chapter title itself:
1798 % \begin{quote}
1799 % |\NCC@makechaptitle|\marg{alignment}\marg{style}\marg{heading}
1800 % \end{quote}
1801 % The |\NCC@secmain| hook contains the dynamic alignment style
1802 % or nothing.
1803 % \begin{macrocode}
1804 \def\NCC@makechaptitle#1#2#3{%
1805 \ifx\@svsec\@empty \else
1806 \NCC@secmain#1{\let\NCC@asecnum\@empty\@svsec\@@par}%
1807 \fi
1808 \interlinepenalty \@M \NCC@secmain#1{#2{#3\@@par}}%
1809 }
1810 % \end{macrocode}
1811 % \end{macro}
1812 %
1813 % \begin{macro}{\epigraph}
1814 % \begin{macro}{\epigraphparameters}
1815 % \begin{quote}
1816 % |\epigraph|\oarg{width}\marg{text}\marg{author}\\
1817 % |\epigraphparameters|\marg{style}\marg{width}\marg{height}\marg{author-style}\\
1818 % | |\marg{after-action}
1819 % \end{quote}
1820 % \begin{macrocode}
1821 \newcommand*\epigraph[1][\NCC@epigraphwidth]{\NCC@epigraph{#1}}
1822 \newcommand*\epigraphparameters[5]{%
1823 \def\NCC@epigraphwidth{#2}%
1824 \long\def\NCC@epigraph##1##2##3{
1825 \beforechapter{\def\epigraphwidth{##1}%
1826 #1\par
1827 \NCC@makeepigraph{#3}{##2}{#4{##3}}\par
1828 #5%
1829 }%
1830 }%
1831 }
1832 % \end{macrocode}
1833 % \end{macro}
1834 % \end{macro}
1835 %
1836 % \begin{macro}{\NCC@makeepigraph}
1837 % \begin{quote}
1838 % |\NCC@makeepigraph|\marg{height}\marg{text}\marg{author}
1839 % \end{quote}
1840 % \begin{macrocode}
1841 \long\def\NCC@makeepigraph#1#2#3{%
1842 \@begin@tempboxa\vtop{\setlength{\hsize}{\epigraphwidth}%
1843 \@parboxrestore{#2\@@par}#3\@@par
1844 }%
1845 \setlength\@tempdima{#1}\advance\@tempdima -\totalheight
1846 \ifdim\@tempdima>\z@
1847 \advance\@tempdima\depth
1848 \dp\@tempboxa\@tempdima
1849 \fi
1850 \leavevmode\box\@tempboxa
1851 \@end@tempboxa
1852 }
1853 % \end{macrocode}
1854 % \end{macro}
1855 % \end{macro}
1856 %
1857 % \subsection{Make Part in Book-like Classes}
1858 %
1859 % \begin{macro}{\NCC@startpart}
1860 % The start-part hook:
1861 % \begin{macrocode}
1862 \def\NCC@startpart{%
1863 \if@openright\cleardoublepage\else\clearpage\fi
1864 \thispagestyle{plain}%
1865 }
1866 % \end{macrocode}
1867 % \end{macro}
1868 %
1869 % \begin{macro}{\NCC@spart}
1870 % Prepare the starred version of part:
1871 % \begin{quote}
1872 % |\NCC@spart|\marg{before}\marg{after}\marg{style}\marg{heading}
1873 % \end{quote}
1874 % \begin{macrocode}
1875 \def\NCC@spart#1#2#3#4{%
1876 \let\@svsec\@empty
1877 \NCC@makepart{#1}{#3}{#4}{#2}{}%
1878 \NCC@sec@reset@controls
1879 }
1880 % \end{macrocode}
1881 % \end{macro}
1882 %
1883 % \begin{macro}{\NCC@part}
1884 % Prepare the non-starred version of part:
1885 % \begin{quote}
1886 % |\NCC@part|\marg{before}\marg{after}\marg{style}\oarg{toc-entry}\marg{heading}
1887 % \end{quote}
1888 % \begin{macrocode}
1889 \def\NCC@part#1#2#3[#4]#5{%
1890 \def\NCC@make{\NCC@makepart{#1}{#3}{#5}{#2}}%
1891 \NCC@makesection{part}{\m@ne}{#4}{%
1892 \addcontentsline{toc}{part}{%
1893 \ifnum \c@secnumdepth>-2
1894 \numberline{\NCC@thetocpart}\fi
1895 #4%
1896 }%
1897 }%
1898 }
1899 % \end{macrocode}
1900 % \end{macro}
1901 %
1902 % \begin{macro}{\NCC@thetocpart}
1903 % The following hook allows redefine the appearance of part name
1904 % in the TOC:
1905 % \begin{macrocode}
1906 \def\NCC@thetocpart{\thepart}
1907 % \end{macrocode}
1908 % \end{macro}
1909 %
1910 % \begin{macro}{\NCC@makepart}
1911 % This command makes a part:
1912 % \begin{quote}
1913 % |\NCC@makepart|\marg{before}\marg{style}\marg{heading}\marg{after}\marg{action}
1914 % \end{quote}
1915 % The |\@svsec| is either |\@empty| or contains a part tag.
1916 % \begin{macrocode}
1917 \def\NCC@makepart#1#2#3#4#5{%
1918 \if@twocolumn \onecolumn \@tempswatrue \else \@tempswafalse \fi
1919 \begingroup\normalfont
1920 \NCC@asecnum@
1921 \NCC@makeparttitle{#1}{#2}{#3}%
1922 \endgroup
1923 \NCC@makepartfinal{#5}#4%
1924 \if@tempswa \twocolumn \fi
1925 }
1926 % \end{macrocode}
1927 % \end{macro}
1928 %
1929 % \begin{macro}{\NCC@makepartfinal}
1930 % \begin{macro}{\NCC@makepartfinalgobble}
1931 % The |\NCC@makepartfinal| hook applies a final action which can contain the
1932 % |\partmark| command. Its default value is to put the parameter as is.
1933 % If you let this command to be equal to the |\NCC@makepartfinalgobble|, the
1934 % chapter mark will contain no chapter name.
1935 % \begin{macrocode}
1936 \let\NCC@makepartfinal\@firstofone
1937 \def\NCC@makepartfinalgobble#1{%
1938 \let\NCC@makepartmark\NCC@makemark
1939 \def\NCC@makemark{%
1940 \let\NCC@temp\partname
1941 \let\partname\@gobble
1942 \NCC@makepartmark
1943 \let\partname\NCC@temp
1944 }%
1945 #1%
1946 }
1947 \@onlypreamble\NCC@makepartfinalgobble
1948 % \end{macrocode}
1949 % \end{macro}
1950 % \end{macro}
1951 %
1952 % \begin{macro}{\NCC@makeparttitle}
1953 % This command makes a part title itself:
1954 % \begin{quote}
1955 % |\NCC@makeparttitle|\marg{before}\marg{style}\marg{heading}
1956 % \end{quote}
1957 % \begin{macrocode}
1958 \def\NCC@makeparttitle#1#2#3{#1%
1959 \ifx\@svsec\@empty \else
1960 {\let\NCC@asecnum\@empty\@svsec\@@par}\nobreak \fi
1961 \interlinepenalty \@M #2{#3\@@par}
1962 }
1963 }
1964 % \end{macrocode}
1965 % \end{macro}
1966 %
1967 % \subsection{Make Captions}
1968 %
1969 % \begin{macro}{\CaptionTagSuffix}
1970 % |\CaptionTagSuffix|\marg{suffix} sets a default suffix after caption tag:
1971 % \begin{macrocode}
1972 \newcommand*{\CaptionTagSuffix}[1]{\def\NCC@acapnum{#1}}
1973 \@onlypreamble\CaptionTagSuffix
1974 % \end{macrocode}
1975 % \end{macro}
1976 %
1977 % \begin{macro}{\captiontagsuffix}
1978 % |\captiontagsuffix|\oarg{type}\marg{suffix} changes a suffix after caption
1979 % tag.
1980 % \begin{macrocode}
1981 \newcommand*\captiontagsuffix[2][]{%
1982 \NCC@prepare@capkey{suffix}{#1}{\def\NCC@acapnum{#2}}%
1983 }
1984 \let\NCC@capsuffix@\@empty
1985 % \end{macrocode}
1986 % \end{macro}
1987
1988 %
1989 % \begin{macro}{\captionstyle}
1990 % |\captionstyle|\oarg{type}\marg{style} selects a style to be applied
1991 % to the caption text. Three styles are available now: |default|, |center|,
1992 % and |centerlast|.
1993 % \begin{macrocode}
1994 \newcommand*\captionstyle[1][]{%
1995 \NCC@set@capkey{style}{style}{#1}%
1996 }
1997 % \end{macrocode}
1998 % \end{macro}
1999 %
2000 % \begin{macro}{\captiontagstyle}
2001 % |\captiontagstyle|\oarg{type}\marg{style} selects a style of caption tag:
2002 % |right| or |para|.
2003 % \begin{macrocode}
2004 \newcommand*\captiontagstyle[1][]{%
2005 \NCC@set@capkey{tag}{tag style}{#1}%
2006 }
2007 % \end{macrocode}
2008 % \end{macro}
2009 %
2010 % \begin{macro}{\captionwidth}
2011 % The |\captionwidth|\oarg{type}\marg{length} specifies a caption width
2012 % in |\@tempdima|. Default width is |\linewidth|.
2013 % \begin{macrocode}
2014 \newcommand*\captionwidth[2][]{%
2015 \NCC@prepare@capkey{width}{#1}{\setlength{\@tempdima}{#2}}%
2016 }
2017 % \end{macrocode}
2018 % \end{macro}
2019 %
2020 % \begin{macro}{\NCC@set@capkey}
2021 % |\NCC@set@capkey|\marg{key}\marg{description}\marg{type}\marg{value}
2022 % \begin{macrocode}
2023 \def\NCC@set@capkey#1#2#3#4{%
2024 \@ifundefined{NCC@makecap#1@#4}
2025 {\PackageError{nccsect}{Unknown caption #2 `#4'}{}%
2026 }{%
2027 \edef\@tempa{\noexpand\NCC@prepare@capkey{#1}{#3}{%
2028 \expandafter\noexpand\csname NCC@makecap#1@#4\endcsname
2029 }%
2030 }%
2031 \@tempa
2032 }%
2033 }
2034 % \end{macrocode}
2035 % \end{macro}
2036 %
2037 % \begin{macro}{\NCC@prepare@capkey}
2038 % |\NCC@prepare@capkey|\marg{key}\marg{type}\marg{definition}
2039 % \begin{macrocode}
2040 \def\NCC@prepare@capkey#1#2{%
2041 \def\@tempa{#2}%
2042 \ifx\@tempa\@empty
2043 \ifx\@captype\@undefined \else \let\@tempa\@captype \fi
2044 \fi
2045 \expandafter\def\csname NCC@cap#1@\@tempa\endcsname
2046 }
2047 % \end{macrocode}
2048 % \end{macro}
2049 %
2050 % \begin{macro}{\NCC@apply@cap}
2051 % |\NCC@apply@cap|\marg{key}
2052 % \begin{macrocode}
2053 \def\NCC@apply@cap#1{%
2054 \@ifundefined{NCC@cap#1@\@captype}%
2055 {\let\@tempa\@empty}{\let\@tempa\@captype}%
2056 \csname NCC@cap#1@\@tempa\endcsname
2057 }
2058 % \end{macrocode}
2059 % \end{macro}
2060 %
2061 % \begin{macro}{\NCC@startcaption}
2062 % This command starts a caption:
2063 % \begin{quote}
2064 % |\NCC@startcaption|\marg{beforeskip}\marg{afterskip}\marg{style}
2065 % \end{quote}
2066 % \begin{macrocode}
2067 \def\NCC@startcaption#1#2#3{%
2068 \secdef{\NCC@caption{#1}{#2}{#3}}{\NCC@scaption{#1}{#2}{#3}}%
2069 }
2070 % \end{macrocode}
2071 % \end{macro}
2072 %
2073 % \begin{macro}{\NCC@scaption}
2074 % Starred version of caption:
2075 % \begin{quote}
2076 % |\NCC@scaption|\marg{beforeskip}\marg{afterskip}\marg{style}\marg{text}
2077 % \end{quote}
2078 % \begin{macrocode}
2079 \long\def\NCC@scaption#1#2#3#4{%
2080 \let\@svsec\@empty
2081 \NCC@makecaption{#3}{#1}{#4}{#2}{}%
2082 \NCC@sec@reset@controls
2083 }
2084 % \end{macrocode}
2085 % \end{macro}
2086 %
2087 % \begin{macro}{\NCC@caption}
2088 % Non-starred version of caption:
2089 % \begin{quote}
2090 % |\NCC@caption|\marg{beforeskip}\marg{afterskip}\marg{style}\oarg{toc-entry}\marg{text}
2091 % \end{quote}
2092 % \begin{macrocode}
2093 \long\def\NCC@caption#1#2#3[#4]#5{%
2094 \def\NCC@make{\NCC@makecaption{#3}{#1}{#5}{#2}}%
2095 \NCC@makesection{\@captype}{\z@}{#4}{%
2096 \begingroup
2097 \let\centering\@empty
2098 \addcontentsline{\@nameuse{ext@\@captype}}{\@captype}{%
2099 \ifnum \c@secnumdepth>\m@ne
2100 \numberline{\@nameuse{the\@captype}}\fi
2101 #4%
2102 }%
2103 \endgroup
2104 }%
2105 }
2106 % \end{macrocode}
2107 % \end{macro}
2108 %
2109 % \begin{macro}{\NCC@makecaption}
2110 % This command makes a caption:
2111 % \begin{quote}
2112 % |\NCC@makecaption|\marg{style}\marg{beforeskip}\marg{text}\marg{afterskip}\marg{action}
2113 % \end{quote}
2114 % The |\@svsec| is either |\@empty| or contains a caption tag.
2115 % \begin{macrocode}
2116 \long\def\NCC@makecaption#1#2#3#4#5{%
2117 \begingroup\par\normalfont
2118 #1{}\addvspace{#2}\noindent
2119 % \end{macrocode}
2120 % Calculate in |\@tempcnta| caption variants:
2121 % 0~-- no caption, 1~-- caption tag only, 2~-- caption text only,
2122 % 3~-- both caption tag and text are nonempty.
2123 % \begin{macrocode}
2124 \ifx\@svsec\@empty \@tempcnta\z@ \else \@tempcnta\@ne \fi
2125 \def\@tempa{#3}%
2126 \ifx\@tempa\@empty \else \advance\@tempcnta\tw@ \fi
2127 % \end{macrocode}
2128 % Put caption in a parbox aligned at the top line.
2129 % \begin{macrocode}
2130 \ifnum\@tempcnta=\z@ \else
2131 \NCC@apply@cap{suffix}%
2132 \NCC@apply@cap{width}%
2133 \NCC@vtopcap{\@parboxrestore\NCC@apply@cap{tag}{#3}\@@par}\par
2134 % \end{macrocode}
2135 % We avoid insert zero skip after parbox to allow captions of
2136 % side-by-side figures to be aligned at their top line.
2137 % \begin{macrocode}
2138 \setlength\@tempskipa{#4}%
2139 \ifdim\@tempskipa=\z@ \else \vskip \@tempskipa\fi
2140 \fi
2141 \endgroup
2142 #5%
2143 }
2144 % \end{macrocode}
2145 % \end{macro}
2146 %
2147 % \begin{macro}{\NCC@vtopcap}
2148 % |\NCC@vtopcap|\marg{text} places a text in a vertical
2149 % top-aligned box. Its width is prepared in |\@tempdima|
2150 % before this macro. If its width is greater than the
2151 % |\linewidth|, we allow overlap the box out of line.
2152 % The overlapping directions are calculated from stretches of
2153 % paragraph marginal skips.
2154 % \begin{macrocode}
2155 \def\NCC@vtopcap#1{%
2156 \ifdim\@tempdima>\linewidth
2157 \@tempskipa \leftskip \advance\@tempskipa -1\@tempskipa
2158 \@tempskipb \rightskip \advance\@tempskipb \parfillskip
2159 \advance\@tempskipb -1\@tempskipb
2160 \vtop{\hb@xt@\linewidth{%
2161 \NCC@ifzeroskip\@tempskipa{}{\hss}%
2162 \vtop{\hsize\@tempdima#1}%
2163 \NCC@ifzeroskip\@tempskipb{}{\hss}%
2164 }}%
2165 \else
2166 \vtop{\hsize\@tempdima#1}%
2167 \fi
2168 }
2169 % \end{macrocode}
2170 % \end{macro}
2171 %
2172 % \begin{macro}{\NCC@ifzeroskip}
2173 % |\NCC@ifzeroskip|\marg{register}\marg{true-clause}\marg{false-clause}
2174 % executes the \meta{true-clause} if the value of skip register
2175 % is exactly zero skip without stretchability. Otherwise, the
2176 % \meta{false-clause} is executed.
2177 % \begin{macrocode}
2178 \def\NCC@ifzeroskip#1{%
2179 \edef\@tempa{\the#1}\edef\@tempb{\the\z@skip}%
2180 \ifx\@tempa\@tempb
2181 \expandafter\@firstoftwo
2182 \else
2183 \expandafter\@secondoftwo
2184 \fi
2185 }
2186 % \end{macrocode}
2187 % \end{macro}
2188 %
2189 % \begin{macro}{\NCC@makecaptag@para}
2190 % The |\NCC@makecaptag@para|\marg{text} prepares run-in tag.
2191 % \begin{macrocode}
2192 \long\def\NCC@makecaptag@para#1{%
2193 \ifnum\@tempcnta<\thr@@ \let\NCC@acapnum\@empty\fi
2194 \NCC@apply@cap{style}{{\@svsec}\ignorespaces#1}%
2195 }
2196 % \end{macrocode}
2197 % \end{macro}
2198 %
2199 % \begin{macro}{\NCC@makecaptag@left}
2200 % The |\NCC@makecaptag@left|\marg{text} prepares flush-left tag.
2201 % \begin{macrocode}
2202 \def\NCC@makecaptag@left{\NCC@separate@captag\raggedright}
2203 % \end{macrocode}
2204 % \end{macro}
2205 %
2206 % \begin{macro}{\NCC@makecaptag@center}
2207 % The |\NCC@makecaptag@center|\marg{text} prepares centered tag.
2208 % \begin{macrocode}
2209 \def\NCC@makecaptag@center{\NCC@separate@captag\centering}
2210 % \end{macrocode}
2211 % \end{macro}
2212 %
2213 % \begin{macro}{\NCC@makecaptag@right}
2214 % The |\NCC@makecaptag@right|\marg{text} prepares flush-right tag.
2215 % \begin{macrocode}
2216 \def\NCC@makecaptag@right{\NCC@separate@captag\raggedleft}
2217 % \end{macrocode}
2218 % \end{macro}
2219 %
2220 % \begin{macro}{\NCC@separate@captag}
2221 % The |\NCC@separate@captag|\marg{style}\marg{text} prepares a
2222 % caption tag in a separate line.
2223 % \begin{macrocode}
2224 \long\def\NCC@separate@captag#1#2{%
2225 \ifodd\@tempcnta
2226 {\let\NCC@acapnum\@empty #1\@svsec\@@par}%
2227 \fi
2228 \ifnum\@tempcnta>\@ne
2229 \ifnum\@tempcnta=\thr@@ \vskip .5ex\fi
2230 \NCC@apply@cap{style}{#2}%
2231 \fi
2232 }
2233 % \end{macrocode}
2234 % \end{macro}
2235 %
2236 % \begin{macro}{\NCC@makecapstyle@default}
2237 % The |\NCC@makecapstyle@default|\marg{text} prepares caption text
2238 % in default \LaTeX's style.
2239 % \begin{macrocode}
2240 \long\def\NCC@makecapstyle@default#1{%
2241 \setbox\@tempboxa\vtop{\hsize\linewidth\@parboxrestore#1\@@par}%
2242 \ifdim\dp\@tempboxa<\baselineskip \centering#1%
2243 \else \box\@tempboxa \fi
2244 }
2245 % \end{macrocode}
2246 % \end{macro}
2247 %
2248 % \begin{macro}{\NCC@makecapstyle@para}
2249 % The |\NCC@makecapstyle@para|\marg{text} prepares ordinary caption.
2250 % \begin{macrocode}
2251 \long\def\NCC@makecapstyle@para#1{#1}
2252 % \end{macrocode}
2253 % \end{macro}
2254 %
2255 % \begin{macro}{\NCC@makecapstyle@left}
2256 % The |\NCC@makecapstyle@left|\marg{text} prepares flush-left caption.
2257 % \begin{macrocode}
2258 \long\def\NCC@makecapstyle@left#1{\raggedright#1}
2259 % \end{macrocode}
2260 % \end{macro}
2261 %
2262 % \begin{macro}{\NCC@makecapstyle@right}
2263 % The |\NCC@makecapstyle@right|\marg{text} prepares flush-right caption.
2264 % \begin{macrocode}
2265 \long\def\NCC@makecapstyle@right#1{\raggedleft#1}
2266 % \end{macrocode}
2267 % \end{macro}
2268 %
2269 % \begin{macro}{\NCC@makecapstyle@center}
2270 % The |\NCC@makecapstyle@center|\marg{text} prepares centered caption.
2271 % \begin{macrocode}
2272 \long\def\NCC@makecapstyle@center#1{\centering#1}
2273 % \end{macrocode}
2274 % \end{macro}
2275 %
2276 % \begin{macro}{\NCC@makecapstyle@centerlast}
2277 % The |\NCC@makecapstyle@centerlast|\marg{text} prepares caption with
2278 % last line centered.
2279 % \begin{macrocode}
2280 \long\def\NCC@makecapstyle@centerlast#1{%
2281 \leftskip\@flushglue \rightskip -\@flushglue
2282 \parfillskip\z@\@plus 2fil\relax#1%
2283 }
2284 % \end{macrocode}
2285 % \end{macro}
2286 %
2287 % \begin{macro}{\RegisterFloatType}
2288 % The |\RegisterFloatType|\marg{type} command registers a float type:
2289 % \begin{macrocode}
2290 \newcommand*{\RegisterFloatType}[1]{%
2291 \edef\NCC@floatlist{\NCC@floatlist{#1}}%
2292 }
2293 \let\NCC@floatlist\@empty
2294 \@onlypreamble\RegisterFloatType
2295 % \end{macrocode}
2296 % \end{macro}
2297 %
2298 % \begin{macro}{\NCC@infloats}
2299 % The |\NCC@infloats|\marg{action} command applies the given \meta{action}
2300 % to all registered float types. During the cycle,
2301 % the |\@captype| contains a name of float and
2302 % the |\@tempcnta| is equal to its registration number
2303 % (1~for the figure float, 2~for the table float, and so on).
2304 % \begin{macrocode}
2305 \def\NCC@infloats#1{%
2306 \@tempcnta\z@
2307 \let\NCC@temp \@captype
2308 \expandafter \@tfor \expandafter \@captype
2309 \expandafter :\expandafter =\NCC@floatlist \do
2310 {\advance\@tempcnta\@ne #1}%
2311 \let\@captype\NCC@temp
2312 }
2313 % \end{macrocode}
2314 % \end{macro}
2315 %
2316 % \subsection{Declare Sections and Captions}
2317 %
2318 % \begin{macro}{\DeclareSection}
2319 % Now we can implement the |\DeclareSection| command.
2320 % It generates:
2321 % \begin{desclist}{}{}
2322 % \item[\cs{NCC@mainsection}] command if \meta{level} = 0;
2323 % \item[\cs{NCC@section}\meta{level-in-roman}] command if \meta{level} $>$ 0;
2324 % \item[\cs{NCC@cap@}\meta{float-type}] command if \meta{level} $<$ 0.
2325 % \end{desclist}
2326 % \begin{macrocode}
2327 \newcommand{\DeclareSection}{\@ifstar{\NCC@dsecx}{\NCC@dsec}}
2328 \def\NCC@dsec#1#2{%
2329 \@ifnextchar[{\NCC@dsect{#1}{#2}}{\NCC@dsect{#1}{#2}[\z@skip]}%
2330 }
2331 \@onlypreamble\DeclareSection
2332 \@onlypreamble\NCC@dsec
2333 % \end{macrocode}
2334 % \end{macro}
2335 %
2336 % \begin{macro}{\NCC@dsect}
2337 % The non-starred version of section declaration command
2338 % prepares display sections with traditional formatting:
2339 % \begin{quote}
2340 % |\NCC@dsect|\marg{level}\marg{type}\oarg{indent}\marg{prefix}\marg{beforeskip}\\
2341 % | |\marg{afterskip}\marg{style}
2342 % \end{quote}
2343 % It is also used for generation of run-in sections
2344 % and captions.
2345 % \begin{macrocode}
2346 \def\NCC@dsect#1#2[#3]#4#5#6#7{%
2347 \ifnum#1>\z@
2348 \expandafter\def\csname NCC@section\romannumeral#1\endcsname{%
2349 \NCC@setsectionsuffix{#1}%
2350 \NCC@preparesectag{#4}{}%
2351 \let\NCC@makesec\NCC@makesect
2352 \NCC@startsection{#2}{#1}{#3}{#5}{#6}{#7}}%
2353 \else
2354 \ifnum#1=\z@
2355 \def\NCC@mainsection{%
2356 \NCC@setsectionsuffix\z@
2357 \let\NCC@secmain\@empty
2358 % \end{macrocode}
2359 % The empty |\NCC@secmain| means standard alignment of main section
2360 % \begin{macrocode}
2361 \NCC@startmainsec{%
2362 \NCC@hangfrom{\hskip #3}\NCC@adjsecmargins{}\@flushglue
2363 \ignorespaces}%
2364 {#4}{#5}{#6}{#7}%
2365 }%
2366 \else
2367 \NCC@dsecf{#2}{#4}{#5}{#6}{#7}%
2368 \fi
2369 \fi
2370 }
2371 \@onlypreamble\NCC@dsect
2372 % \end{macrocode}
2373 % \end{macro}
2374 %
2375 % \begin{macro}{\NCC@dsecx}
2376 % The starred version of section declaration command
2377 % prepares display sections with dynamic formatting:
2378 % \begin{quote}
2379 % |\NCC@dsecx|\marg{level}\marg{type}\marg{prefix}\marg{beforeskip}\marg{afterskip}\marg{style}
2380 % \end{quote}
2381 % It can also be used for generation of captions.
2382 % \begin{macrocode}
2383 \def\NCC@dsecx#1#2#3#4#5#6{%
2384 \ifnum#1>\z@
2385 \expandafter\def\csname NCC@section\romannumeral#1\endcsname{%
2386 \NCC@setsectionsuffix{#1}%
2387 \NCC@setsectionstyle{#1}%
2388 \NCC@preparesectag{#3}{}%
2389 \let\NCC@makesec\NCC@makesecx
2390 \NCC@startsection{#2}{#1}{\z@}{#4}{#5}{#6}}%
2391 \else
2392 \ifnum#1=\z@
2393 % \end{macrocode}
2394 % The non-empty |\NCC@secmain| hook means the dynamic alignment.
2395 % We also redefine the dynamic section style |\NCC@sec| in such a way that the
2396 % right skip stretchability will be |1fil| if the section style has
2397 % no flush glue.
2398 % \begin{macrocode}
2399 \def\NCC@mainsection{%
2400 \NCC@setsectionsuffix\z@
2401 \NCC@setsectionstyle\z@
2402 \let\NCC@secsave\NCC@sec \let\NCC@sec\NCC@secflush
2403 \def\NCC@secmain{\protect\NCC@sec{}}%
2404 \NCC@startmainsec{}{#3}{#4}{#5}{#6}%
2405 }%
2406 \else
2407 \NCC@dsecf{#2}{#3}{#4}{#5}{#6}%
2408 \fi
2409 \fi
2410 }
2411 \@onlypreamble\NCC@dsecx
2412 % \end{macrocode}
2413 % \end{macro}
2414 %
2415 % \begin{macro}{\NCC@secflush}
2416 % |\NCC@secflush|\marg{tag} applies a section style saved in the
2417 % |\NCC@secsave| macro and adjusts |\rightskip| and |\parfillskip|
2418 % if the left and right margins have no stretchability in sum.
2419 % \begin{macrocode}
2420 \def\NCC@secflush#1{\NCC@secsave{#1}%
2421 \@tempskipa\leftskip \advance\@tempskipa\rightskip
2422 \advance\@tempskipa -1\@tempskipa
2423 % \end{macrocode}
2424 % There are three general cases in which the
2425 % correction of right margin is required:
2426 % \begin{center}\small\catcode`|=12
2427 % \begin{tabular}{|l|c|c|c|}\hline
2428 % \tc{\cbox{Case}} & \cbox{\tt\string\leftskip} & \cbox{\tt\string\rightskip}
2429 % & \cbox{\tt\string\parfillskip} \\\hline
2430 % \Strut/.7/
2431 % Left last &\tt x &\tt y &\tt 0pt plus 1fil \\
2432 % Center last &\tt x plus 1fil &\tt y plus -1fil &\tt 0pt plus 2fil \\
2433 % Right last &\tt x plus 1fil &\tt y plus -1fil &\tt 0pt plus 1fil \\\hline
2434 % \end{tabular}
2435 % \end{center}
2436 % In all these cases the correction is simple: we need to add |\parfillskip|
2437 % to the |\rightskip| and set |\parfillskip| to zero.
2438 % \begin{macrocode}
2439 \NCC@ifzeroskip\@tempskipa{%
2440 \advance\rightskip \parfillskip \parfillskip \z@skip
2441 }{}%
2442 \ignorespaces
2443 }
2444 % \end{macrocode}
2445 % \end{macro}
2446 %
2447 % \begin{macro}{\NCC@dsecf}
2448 % This command declares captions of floats:
2449 % \begin{quote}
2450 % |\NCC@dsecf|\marg{type}\marg{prefix}\marg{beforeskip}\marg{afterskip}\marg{style}
2451 % \end{quote}
2452 % \begin{macrocode}
2453 \def\NCC@dsecf#1#2#3#4#5{%
2454 \expandafter\def\csname NCC@cap@#1\endcsname{%
2455 \def\NCC@makesectag####1{#2{\csname #1name\endcsname}%
2456 \nobreakspace####1\NCC@acapnum}%
2457 \NCC@startcaption{#3}{#4}{#5}%
2458 }%
2459 }
2460 \@onlypreamble\NCC@dsectf
2461 % \end{macrocode}
2462 % \end{macro}
2463 %
2464 % \begin{macro}{\DeclarePart}
2465 % In book-like classes, a part is declared in a special way:
2466 % \begin{quote}
2467 % |\DeclarePart|\marg{before}\marg{after}\marg{prefix}\marg{style}
2468 % \end{quote}
2469 % Long parameters are allowed in this declaration.
2470 % \begin{macrocode}
2471 \@ifundefined{chapter}{}{%
2472 \newcommand\DeclarePart[4]{%
2473 \def\NCC@partsection{%
2474 \NCC@startpart
2475 \NCC@preparesectag{\leavevmode#3}{\partname\nobreakspace}%
2476 \secdef{\NCC@part{#1}{#2}{#4}}{\NCC@spart{#1}{#2}{#4}}%
2477 }%
2478 }
2479 \@onlypreamble\DeclarePart
2480 }
2481 % \end{macrocode}
2482 % \end{macro}
2483 %
2484 % \subsection{Caption Patches}
2485 %
2486 % \begin{macro}{\@makecaption}
2487 % We emulate here the |\@makecaption{\fnum@|\meta{type}|}|\marg{caption}
2488 % command to provide the compatibility with packages using it.
2489 % It calls the |\NCC@cap@|\meta{type} command using the type specified
2490 % in |\@captype| command. The counter is already stepped
2491 % before this command and all necessary things are written
2492 % to aux. Therefore, we turn off writing to aux and decrease a value of
2493 % the float counter by |-1| because it will be stepped within again.
2494 % \begin{macrocode}
2495 \long\def\@makecaption#1#2{%
2496 \begingroup
2497 \skipwritingtoaux
2498 \addtocounter\@captype\m@ne
2499 \csname NCC@cap@\@captype\endcsname[]{#2}%
2500 \endgroup
2501 }
2502 % \end{macrocode}
2503 % \end{macro}
2504 %
2505 % Add patch to the \textbf{supertabular} package:
2506 % \begin{macrocode}
2507 \AfterPackage{supertabular}{%
2508 \long\def\ST@caption#1[#2]#3{\par%
2509 \addcontentsline{\csname ext@#1\endcsname}{#1}%
2510 {\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
2511 \begingroup\centering
2512 \def\@captype{#1}%
2513 \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
2514 \endgroup
2515 }
2516 }
2517 % \end{macrocode}
2518 %
2519 % Add patch to the \textbf{xtab} package:
2520 % \begin{macrocode}
2521 \AfterPackage{xtab}{%
2522 \long\def\ST@caption#1[#2]#3{\par%
2523 \@initisotab
2524 \addcontentsline{\csname ext@#1\endcsname}{#1}%
2525 {\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
2526 \begingroup\centering
2527 \def\@captype{#1}%
2528 \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
2529 \endgroup
2530 \global\advance\ST@pageleft -\PWSTcapht
2531 \ST@trace\tw@{Added caption. Space left for xtabular: \the\ST@pageleft}%
2532 }
2533 }
2534 % \end{macrocode}
2535 %
2536 % Add patch to the \textbf{longtable} package:
2537 % \begin{macrocode}
2538 \AfterPackage{longtable}{%
2539 \def\LT@makecaption#1#2#3{%
2540 \LT@mcol\LT@cols c{\hbox to\z@{\hss
2541 \parbox[t]\LTcapwidth{\centering\def\@captype{table}%
2542 \ifx#1\@gobble \NCC@cap@table*{#3}%
2543 \else \@makecaption{\fnum@table}{#3}%
2544 \fi
2545 }%
2546 \hss
2547 }}%
2548 }
2549 }
2550 % \end{macrocode}
2551 %
2552 % \subsection{Declare TOC-Entries}
2553 %
2554 % \begin{macro}{\DeclareTOCEntry}
2555 % The toc-entries declaration command:
2556 % \begin{quote}
2557 % |\DeclareTOCEntry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\
2558 % | |\marg{style}\oarg{next}
2559 % \end{quote}
2560 % \begin{macrocode}
2561 \newcommand*{\DeclareTOCEntry}[5]{%
2562 \@ifnextchar[{\NCC@dtoc{#1}{#2}{#3}{#4}{#5}}%
2563 {\NCC@dtoc{#1}{#2}{#3}{#4}{#5}[\NCC@nexttocnum{#3}{#4}]}%
2564 }
2565 \def\NCC@dtoc#1#2#3#4#5[#6]{%
2566 % \end{macrocode}
2567 % Declare a toc-entry command for a registered float.
2568 % We scan the registration list and find the necessary
2569 % float type comparing its registration number with the negation
2570 % of level. The generated command is |\l@|\meta{float-type}:
2571 % \begin{macrocode}
2572 \ifnum#1<\z@
2573 \@tempswatrue
2574 \NCC@infloats{%
2575 \ifnum#1=-\@tempcnta
2576 \expandafter\def\csname l@\@captype\endcsname
2577 {\NCC@tocentry\z@{#2}{#3}{#4}{#5}}%
2578 \@tempswafalse
2579 \@break@tfor
2580 \fi
2581 }%
2582 % \end{macrocode}
2583 % Incorrect level number. Generate an error.
2584 % \begin{macrocode}
2585 \if@tempswa
2586 \@tempcnta#1\relax
2587 \@tempcnta -\@tempcnta
2588 \PackageError{nccsect}%
2589 {Float type registration number \the\@tempcnta\space
2590 is out of range}{}%
2591 \fi
2592 \else
2593 % \end{macrocode}
2594 % Prepare in |\@tempa| a command name: |\l@section| or |\l@subsection|
2595 % or \ldots\ or |\l@subparagraph| or |\l@section@vi| or \ldots:
2596 % \begin{macrocode}
2597 \ifnum#1>\z@
2598 \edef\@tempa{\noexpand\def\expandafter\noexpand
2599 \csname l@\NCC@secname{#1}\endcsname}%
2600 % \end{macrocode}
2601 % or |\l@part| or |\l@chapter|:
2602 % \begin{macrocode}
2603 \else
2604 \@ifundefined{chapter}{\def\@tempa{\def\l@part}}%
2605 {\def\@tempa{\def\l@chapter}}%
2606 \fi
2607 % \end{macrocode}
2608 % Declare the toc-entry:
2609 % \begin{macrocode}
2610 \@tempa{\NCC@tocentry{#1}{#2}{#3}{#4}{#5}}%
2611 % \end{macrocode}
2612 % Prepare in the |\l@tocskip@|\meta{next-level-in-roman} command
2613 % the left margin adjustment command. The
2614 % |\NCC@tocnumprototype|\marg{style}\marg{prototype} hook
2615 % applies a style to the prototype of toc-entry number.
2616 % \begin{macrocode}
2617 \@tempcnta #1\relax \advance\@tempcnta\@ne
2618 \expandafter\def\csname l@tocskip@\romannumeral\@tempcnta
2619 \endcsname{\NCC@tocadj{\NCC@tocnumprototype{#5}{#6}}}%
2620 \fi
2621 }
2622 \@onlypreamble\DeclareTOCEntry
2623 \@onlypreamble\NCC@dtoc
2624 \def\NCC@nexttocnum#1#2{#1#2\NCC@atocnum}
2625 \def\NCC@tocnumprototype#1#2{\let\applystyle\@firstoftwo#1{#2}}
2626 % \end{macrocode}
2627 % \end{macro}
2628 %
2629 % \begin{macro}{\NCC@tocadj}
2630 % The command increases |\@tempdimb| on the width of the argument:
2631 % \begin{macrocode}
2632 \def\NCC@tocadj#1{%
2633 \settowidth\@tempdima{\let\NCC@atocdo\@firstoftwo#1}%
2634 \advance\@tempdimb\@tempdima
2635 }
2636 % \end{macrocode}
2637 % \end{macro}
2638 %
2639 % \begin{macro}{\DeclareTOCPart}
2640 % Part toc-entry declaration in book-like classes. If optional
2641 % \meta{afterskip} is omitted, the default |\NCC@runskip| value
2642 % is applied after this entry.
2643 % \begin{quote}
2644 % |\DeclareTOCPart|\marg{action}\oarg{afterskip}\marg{prefix}\marg{prototype}\marg{style}
2645 % \end{quote}
2646 % \begin{macrocode}
2647 \@ifundefined{chapter}{}{%
2648 \newcommand*\DeclareTOCPart[1]{%
2649 \@ifnextchar[{\NCC@dtocpart{#1}}{\NCC@dtocpart{#1}[\NCC@runskip]}%
2650 }
2651 \def\NCC@dtocpart#1[#2]#3#4#5{%
2652 \def\l@part##1##2{%
2653 \NCC@tocentry{-1}{%
2654 % \end{macrocode}
2655 % We temporary add |1fil| to the toc right margin to prepare
2656 % a ragged right toc-entry.
2657 % \begin{macrocode}
2658 \TOCMarginDrift{1fil}%
2659 % \end{macrocode}
2660 % Breaks before part are preferred.
2661 % \begin{macrocode}
2662 \addpenalty{-\@highpenalty}#1%
2663 }{#3}{#4}{#5}{##1}{\hss##2}%
2664 \nobreak \vskip #2\relax
2665 \@nobreaktrue
2666 \everypar{\@nobreakfalse\everypar{}}%
2667 }%
2668 }
2669 \@onlypreamble\DeclareTOCPart
2670 \@onlypreamble\NCC@dtocpart
2671 }
2672 % \end{macrocode}
2673 % \end{macro}
2674 %
2675 % \begin{macro}{\NCC@tocentry}
2676 % This command makes a toc-entry:
2677 % \begin{quote}
2678 % |\NCC@tocentry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\
2679 % | |\marg{style}\marg{entry}\marg{page-number}
2680 % \end{quote}
2681 % \begin{macrocode}
2682 \def\NCC@tocentry#1#2#3#4#5#6#7{%
2683 \ifnum #1>\c@tocdepth \else
2684 \par\begingroup\normalfont #2%
2685 \let\applystyle\@firstoftwo
2686 % \end{macrocode}
2687 % Calculate the left margin in the |\@tempdimb| register
2688 % applying the |\l@tocskip@i|, \ldots, |\l@tocskip@|\meta{level-in-roman}
2689 % commands:
2690 % \begin{macrocode}
2691 \@tempdimb\z@ \@tempcnta #1\relax
2692 \@whilenum \@tempcnta >\z@\do
2693 {\@nameuse{l@tocskip@\romannumeral \@tempcnta}%
2694 \advance\@tempcnta\m@ne}%
2695 % \end{macrocode}
2696 % The |\NCC@preparetocnum|\marg{style}\marg{prefix} hook prepares
2697 % the |\NCC@maketocnum|\marg{tag} command creating
2698 % a number-line tag:
2699 % \begin{macrocode}
2700 \NCC@preparetocnum{#5}{#3}%
2701 % \end{macrocode}
2702 % Calculate the hang indent value in |\@tempdima|:
2703 % \begin{macrocode}
2704 \settowidth\@tempdima{\let\NCC@atocdo\@firstoftwo\NCC@maketocnum{#4}}%
2705 % \end{macrocode}
2706 % Produce the toc-entry. The |\NCC@tocentrytitle|\marg{style}\marg{title}
2707 % hook applies the style to the toc-entry title.
2708 % \begin{macrocode}
2709 \@dottedtocline{#1}{\@tempdimb}{\@tempdima}%
2710 {\let\NCC@atocdo\@secondoftwo\NCC@tocentrytitle{#5}{#6\unskip}}%
2711 {\let\applystyle\@secondoftwo#5{#7}}%
2712 % \end{macrocode}
2713 % Allow break after toc-entry:
2714 % \begin{macrocode}
2715 \@nobreakfalse
2716 \endgroup
2717 \fi
2718 }
2719 \def\NCC@preparetocnum#1#2{%
2720 \def\NCC@maketocnum##1{\NCC@atocdo{#1}{}{#2##1\NCC@atocnum}}%
2721 }
2722 \def\NCC@tocentrytitle#1#2{#1{\ignorespaces#2}}
2723 % \end{macrocode}
2724 % \end{macro}
2725 %
2726 % \begin{macro}{\numberline}
2727 % Redefine the |\numberline|\marg{tag} command to work correct
2728 % if the width of tag is greater than |\@tempdima|. The
2729 % tag is prepared with the |\NCC@maketocnum|\marg{tag} command.
2730 % \begin{macrocode}
2731 \DeclareRobustCommand*\numberline[1]{%
2732 \setbox\@tempboxa\hbox{\NCC@maketocnum{#1}}%
2733 \ifdim \wd\@tempboxa > \@tempdima
2734 \box\@tempboxa
2735 \else
2736 \hb@xt@\@tempdima{\unhbox\@tempboxa\hfil}%
2737 \fi
2738 \ignorespaces
2739 }
2740 % \end{macrocode}
2741 % \end{macro}
2742 %
2743 % \begin{macro}{\NCC@maketocnum}
2744 % The default implementation of the |\NCC@maketocnum|\marg{tag} command.
2745 % We must define it because the |\numberline| command must
2746 % work out of scope of toc-entries.
2747 % \begin{macrocode}
2748 \def\NCC@maketocnum#1{#1\NCC@atocnum}
2749 \let\NCC@atocdo\@secondoftwo
2750 % \end{macrocode}
2751 % \end{macro}
2752 %
2753 % \begin{macro}{\NumberlineSuffix}
2754 % The |\NumberlineSuffix|\marg{calc-suffix}\marg{actual-suffix}
2755 % command saves suffices inserted after number tag in the |\numberline|
2756 % command. It saves it in the |\NCC@atocnum| hook as parameters of
2757 % |\NCC@atocdo| command. Letting the last one to |\@firstoftwo| or
2758 % |\@secondoftwo|, we select the \meta{calc-suffix} or \meta{actual-suffix}
2759 % respectively.
2760 % \begin{macrocode}
2761 \newcommand*{\NumberlineSuffix}[2]{\def\NCC@atocnum{\NCC@atocdo{#1}{#2}}}
2762 \@onlypreamble\NumberlineSuffix
2763 % \end{macrocode}
2764 % \end{macro}
2765 %
2766 % \begin{macro}{\TOCMarginDrift}
2767 % The |\TOCMarginDrift|\marg{drift} specifies allowed drift of right margin
2768 % in TOC.
2769 % \begin{macrocode}
2770 \newcommand*\TOCMarginDrift[1]{%
2771 \def\@tempa{#1}%
2772 \ifx\@tempa\@empty \let\NCC@tocdrift\@empty
2773 \else \def\NCC@tocdrift{\@plus #1\relax}\fi
2774 }
2775 % \end{macrocode}
2776 % \end{macro}
2777 %
2778 % \begin{macro}{\PnumPrototype}
2779 % The |\PnumPrototype|\marg{prototype} command saves the page number
2780 % prototype in the |\NCC@pnum| hook and applies the |\NCC@setpnum|
2781 % command.
2782 % \begin{macrocode}
2783 \newcommand*{\PnumPrototype}[1]{\def\NCC@pnum{#1}\NCC@setpnum}
2784 \@onlypreamble\PnumPrototype
2785 \def\NCC@setpnum{%
2786 \settowidth\@tempdima{\NCC@pnum}%
2787 \edef\@pnumwidth{\the\@tempdima}%
2788 \advance\@tempdima 1em
2789 \edef\@tocrmarg{\the\@tempdima \noexpand\NCC@tocdrift}%
2790 }
2791 % \end{macrocode}
2792 % \end{macro}
2793 %
2794 % \begin{macro}{\SetTOCStyle}
2795 % The toc-style hook is embedded into the |\@starttoc| command.
2796 % We also recalculate the page number prototype and update
2797 % margins when a toc starts.
2798 % \begin{macrocode}
2799 \newcommand*{\SetTOCStyle}[1]{\def\NCC@tocstyle{#1}}
2800 \@onlypreamble\SetTOCStyle
2801 \let\NCC@latexstarttoc\@starttoc
2802 \def\@starttoc#1{%
2803 \begingroup
2804 \normalfont \NCC@tocstyle \NCC@setpnum
2805 \NCC@latexstarttoc{#1}%
2806 \endgroup
2807 }
2808 % \end{macrocode}
2809 % \end{macro}
2810 %
2811 % \subsection{Service and Defaults}
2812 %
2813 % \begin{macro}{\StartFromTextArea}
2814 % \begin{macro}{\StartFromHeaderArea}
2815 % These commands are applied at the beginning of page
2816 % to set current position exactly at the first line
2817 % of text area or at the header line, respectively.
2818 % Both these commands are defined in two packages: in this one and in
2819 % the \textbf{textarea}. To be sure that the commands are specified
2820 % in these packages only, we mutually test packages to be loaded.
2821 % \begin{macrocode}
2822 \@ifpackageloaded{textarea}{}{%
2823 \newcommand\StartFromTextArea{\par
2824 {\parskip\z@ \strut\par}\vskip -\baselineskip
2825 }
2826 \newcommand\StartFromHeaderArea{%
2827 \StartFromTextArea
2828 \vskip -\headsep \vskip -\ht\strutbox
2829 }
2830 }
2831 % \end{macrocode}
2832 % \end{macro}
2833 % \end{macro}
2834 %
2835 % \begin{macro}{\bff}
2836 % The |\bff| command tries to set everything bold.
2837 % \begin{macrocode}
2838 \newcommand{\bff}{\normalfont\bfseries\mathversion{bold}}
2839 % \end{macrocode}
2840 % \end{macro}
2841 %
2842 % \begin{macro}{\aftersectionvspace}
2843 % This command eliminates a vertical space inserted after a previous
2844 % section and inserts a vertical space specified.
2845 % \begin{macrocode}
2846 \newcommand*\aftersectionvspace[1]{%
2847 \ifvmode \if@nobreak
2848 \vskip -\lastskip \vskip #1\relax
2849 \fi \fi
2850 }
2851 % \end{macrocode}
2852 % \end{macro}
2853 %
2854 % \begin{macro}{\startsection}
2855 % Define the |\startsection| command. In article-class,
2856 % both zero and negative levels refer to the same part section.
2857 % \begin{macrocode}
2858 \newcommand*{\startsection}[1]{%
2859 \ifnum#1>\z@
2860 \def\@tempa{\csname NCC@section\romannumeral#1\endcsname}%
2861 \else
2862 \ifnum#1=\z@
2863 \def\@tempa{\NCC@mainsection}%
2864 \else
2865 \def\@tempa{\NCC@partsection}%
2866 \fi
2867 \fi
2868 \@tempa
2869 }
2870 % \end{macrocode}
2871 % \end{macro}
2872 %
2873 % \begin{macro}{\part}
2874 % \begin{macro}{\section}
2875 % \begin{macro}{\subsection}
2876 % \begin{macro}{\subsubsection}
2877 % \begin{macro}{\paragraph}
2878 % \begin{macro}{\subparagraph}
2879 % Set aliases for almost all section levels, except chapter.
2880 % The part is called here as a section of a negative level.
2881 % \begin{macrocode}
2882 \def\part{\startsection\m@ne}
2883 \def\section{\startsection\@ne}
2884 \def\subsection{\startsection\tw@}
2885 \def\subsubsection{\startsection\thr@@}
2886 \def\paragraph{\startsection4}
2887 \def\subparagraph{\startsection5}
2888 % \end{macrocode}
2889 % \end{macro}
2890 % \end{macro}
2891 % \end{macro}
2892 % \end{macro}
2893 % \end{macro}
2894 % \end{macro}
2895 %
2896 % \begin{macro}{\caption}
2897 % Redefine the |\caption| command. We do this at the beginning
2898 % of document to reject possible redefinitions of captions
2899 % in other packages such as |float|. I think this is not the
2900 % |float|'s responsibility to decide where a caption must go on:
2901 % before or after the float body. And what about complicated
2902 % floats consisting of side floats and etc.? We also reset to zero
2903 % the |\abovecaptionskip| and |\belowcaptionskip| registers if they
2904 % are specified to provide partial compatibility with the |float|
2905 % package. If the registers are not specified (as in |ncc| class),
2906 % they are emulated with macros.
2907 % \begin{macrocode}
2908 \AtBeginDocument{%
2909 \def\caption{%
2910 \ifx\@captype\@undefined
2911 \@latex@error{\noexpand\caption outside float}\@ehd
2912 \expandafter\@gobble
2913 \else
2914 \expandafter\@firstofone
2915 \fi
2916 {\csname NCC@cap@\@captype\endcsname}%
2917 }%
2918 \@ifundefined{abovecaptionskip}{\def\abovecaptionskip{\z@}}%
2919 {\abovecaptionskip\z@}%
2920 \@ifundefined{belowcaptionskip}{\def\belowcaptionskip{\z@}}%
2921 {\belowcaptionskip\z@}%
2922 }
2923 % \end{macrocode}
2924 % \end{macro}
2925 %
2926 % Registration of standard floats:
2927 % \begin{macrocode}
2928 \RegisterFloatType{figure}
2929 \RegisterFloatType{table}
2930 % \end{macrocode}
2931 %
2932 % Declare all sections and captions except the part and chapter:
2933 % \begin{macrocode}
2934 \DeclareSection{-2}{table}{}{\z@}{10pt}{}
2935 \DeclareSection{-1}{figure}{}{10pt}{\z@}{}
2936 \DeclareSection*1{section}{}%
2937 {3.5ex \@plus 1ex \@minus .2ex}%
2938 {2.3ex \@plus .2ex}{\Large\bff}
2939 \DeclareSection*2{subsection}{}%
2940 {3.25ex \@plus 1ex \@minus .2ex}%
2941 {1.5ex \@plus .2ex}{\large\bff}
2942 \DeclareSection*3{subsubsection}{}%
2943 {3ex \@plus 1ex \@minus .2ex}%
2944 {1.5ex \@plus .2ex}{\normalsize\bff}
2945 \DeclareSection4{paragraph}{}%
2946 {\NCC@runskip}{-1em}{\normalsize\bff}
2947 \DeclareSection5{subparagraph}[\parindent]{}%
2948 {\NCC@runskip}{-1em}{\normalsize\bff}
2949 \@ifundefined{chapter}{
2950 % \end{macrocode}
2951 %
2952 % Declare the part and toc-entries for the article-like style:
2953 % \begin{macrocode}
2954 \DeclareSection*0{part}{\Large\bff}%
2955 {5ex \@plus 1ex \@minus .2ex}%
2956 {4ex \@plus .2ex}{\huge\bff}
2957 \DeclareTOCEntry{-2}{}{}{9}{}% table
2958 \DeclareTOCEntry{-1}{}{}{9}{}% figure
2959 \DeclareTOCEntry0{\runinsectionskip\def\@dotsep{1000}}{}{III}{\bff}[]
2960 \DeclareTOCEntry1{\runinsectionskip}{}{9}{}
2961 \DeclareTOCEntry2{}{}{9.9}{}
2962 \DeclareTOCEntry3{}{}{9.9.9}{}
2963 }{
2964 % \end{macrocode}
2965 %
2966 % \begin{macro}{\ChapterPrefixStyle}
2967 % Specify the appearance of chapter prefix in the toc and the header.
2968 % \begin{macrocode}
2969 \newcommand*{\ChapterPrefixStyle}[1]{%
2970 \def\NCC@thetocchapter{\thechapter}%
2971 \let\NCC@makechapfinal\NCC@makechapfinalgobble
2972 \@for\@tempa:=#1\do{%
2973 \@ifundefined{NCC@chapin@\@tempa}{%
2974 \PackageError{nccsect}{Unknown style `\@tempa'\MessageBreak
2975 Only the `toc' and `header' styles are allowed}{}%
2976 }{\csname NCC@chapin@\@tempa\endcsname}%
2977 }%
2978 }
2979 \def\NCC@chapin@toc{\def\NCC@thetocchapter{\@chapapp\ \thechapter}}
2980 \def\NCC@chapin@header{\let\NCC@makechapfinal\@firstofone}
2981 \@onlypreamble\ChapterPrefixStyle
2982 \@onlypreamble\NCC@chapin@toc
2983 \@onlypreamble\NCC@chapin@header
2984 % \end{macrocode}
2985 % \end{macro}
2986 %
2987 % \begin{macro}{\chapter}
2988 % Declare the part, the chapter, toc-entries for the
2989 % book-like style, and specify default epigraph parameters:
2990 % \begin{macrocode}
2991 \def\chapter{\startsection\z@}
2992 \DeclarePart{\StartFromTextArea\vfil\centering}%
2993 {\vfil\newpage \if@twoside\if@openright
2994 \mbox{}\thispagestyle{empty}\newpage\fi\fi}%
2995 {\vspace{4ex}\huge\bff}{\Huge\bff}
2996 \DeclareSection*0{chapter}{\vspace{3ex}\huge\bff}{10ex}%
2997 {8ex \@plus .2ex}{\Huge\bff}
2998 \DeclareTOCEntry{-2}{}{}{9.9}{}% table
2999 \DeclareTOCEntry{-1}{}{}{9.9}{}% figure
3000 \DeclareTOCPart{\NCC@secskip{4ex \@plus .2ex}\def\@dotsep{1000}}
3001 {}{II}{\large\bff}
3002 \DeclareTOCEntry0{\runinsectionskip\def\@dotsep{1000}%
3003 \aftergroup\penalty\aftergroup\@highpenalty}{}{9}{\bff}
3004 \DeclareTOCEntry1{}{}{9.9}{}[9.9]
3005 \DeclareTOCEntry2{}{}{9.9.9}{}[9.9.9]
3006 \DeclareTOCEntry3{}{}{}{}[\qquad]
3007 \epigraphparameters{\StartFromHeaderArea\small\raggedleft}%
3008 {.45\linewidth}{5\baselineskip}%
3009 {\raggedleft\itshape}{\vspace{2ex}}
3010 }
3011 % \end{macrocode}
3012 % \end{macro}
3013 %
3014 % Declare other toc-entries:
3015 % \begin{macrocode}
3016 \DeclareTOCEntry4{}{}{}{}[\qquad]
3017 \DeclareTOCEntry5{}{}{}{}[\qquad]
3018 % \end{macrocode}
3019 %
3020 % Set defaults:
3021 % \begin{macrocode}
3022 \noindentaftersection
3023 \sectionstyle{hangindent}
3024 \SectionTagSuffix{\quad}
3025 \RunningSectionSuffix{}
3026 \captionwidth{\linewidth}
3027 \captionstyle{default}
3028 \captiontagstyle{para}
3029 \CaptionTagSuffix{:\hskip .7em \@plus .2em \@minus .1em}
3030 \NumberlineSuffix{\quad}{\enskip}
3031 \PnumPrototype{99}
3032 \TOCMarginDrift{}
3033 \SetTOCStyle{}
3034 %</package>
3035 % \end{macrocode}
3036 \endinput