summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/ncctools
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-11 23:55:29 +0000
committerKarl Berry <karl@freefriends.org>2006-01-11 23:55:29 +0000
commit48243fdbbe15cb58c4136497707e37637e7d4100 (patch)
tree9de6f823e6a2520490bab3ea3f0828852d1a8db3 /Master/texmf-dist/source/latex/ncctools
parentf7ffde8f769cd6f1d473ae231d219b99b3fa5263 (diff)
trunk/Master/texmf-dist/source/latex/ncctools
git-svn-id: svn://tug.org/texlive/trunk@408 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/ncctools')
-rw-r--r--Master/texmf-dist/source/latex/ncctools/dcounter.dtx336
-rw-r--r--Master/texmf-dist/source/latex/ncctools/desclist.dtx154
-rw-r--r--Master/texmf-dist/source/latex/ncctools/extdash.dtx257
-rw-r--r--Master/texmf-dist/source/latex/ncctools/manyfoot.dtx1514
-rw-r--r--Master/texmf-dist/source/latex/ncctools/mboxfill.dtx130
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccbbb.dtx93
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccboxes.dtx427
-rw-r--r--Master/texmf-dist/source/latex/ncctools/ncccomma.dtx100
-rw-r--r--Master/texmf-dist/source/latex/ncctools/ncccropbox.dtx166
-rw-r--r--Master/texmf-dist/source/latex/ncctools/ncccropmark.dtx155
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccfancyhdr.dtx1053
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccfloats.dtx497
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccfoots.dtx94
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccmath.dtx1163
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccparskip.dtx84
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccpic.dtx253
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccrules.dtx397
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccsect.dtx2101
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccstretch.dtx74
-rw-r--r--Master/texmf-dist/source/latex/ncctools/nccthm.dtx1109
-rw-r--r--Master/texmf-dist/source/latex/ncctools/ncctools.ins75
-rw-r--r--Master/texmf-dist/source/latex/ncctools/tocenter.dtx314
-rw-r--r--Master/texmf-dist/source/latex/ncctools/watermark.dtx216
23 files changed, 10762 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/ncctools/dcounter.dtx b/Master/texmf-dist/source/latex/ncctools/dcounter.dtx
new file mode 100644
index 00000000000..bc0997f5d06
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/dcounter.dtx
@@ -0,0 +1,336 @@
+% \iffalse
+%%
+%% File: dcounter.dtx Copyright (C) 1998-2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{dcounter}
+%<package> [2005/04/25 v1.2 Dynamic Counters (NCC)]
+%
+% \changes{v1.0}{1998/12/19}{Initial version}
+% \changes{v1.1}{2004/11/23}{Minor corrections of the documentation}
+% \changes{v1.2}{2005/04/25}{Emulate dynamic style for non-dynamic counters}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{dcounter}
+\GetFileInfo{dcounter.sty}
+\begin{document}
+\title{The \textsf{dcounter} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{dcounter.dtx}
+\end{document}
+%</driver>
+% \fi
+% This package implements a concept of \emph{dynamic counters}. The
+% counter declared as dynamic is really created at the first use
+% and receives at that moment the \emph{count style} which was
+% established by the |\countstyle| command. For example,
+% if |\countstyle{section}| is established, all dynamically created
+% counters will be subordinated to |section| counter (i.e., reset
+% to zero when |section| counter is stepped) and their typesetting
+% command |\the|\emph{foo} will be equal to
+% |\thesection.\arabic{|\emph{foo}|}|. This package is compatible with
+% |calc| package.
+%
+% \section{User Interface}
+%
+% \DescribeMacro\DeclareDynamicCounter
+% To declare a dynamic counter \meta{foo} you have to write
+% \begin{quote}
+% |\DeclareDynamicCounter|\marg{foo}
+% \end{quote}
+% If the \meta{foo} counter does not exist, its name is added to the list of
+% dynamic counters. This allows create a counter at the first use
+% with one of the following commands
+% \begin{tabbing}
+% | \setcounter|\marg{foo}\marg{number}\qquad\qquad\=
+% |\stepcounter|\marg{foo}\\
+% | \addtocounter|\marg{foo}\marg{number}\>
+% |\refstepcounter|\marg{foo}
+% \end{tabbing}
+% If the \meta{foo} counter exists, it will emulate the dynamic style.
+% I use the following trick for such counters: let |\the|\meta{foo} command
+% empty and test it at the beginning of document; if it is empty, the
+% count style of this counter is redefined on the base of dynamic
+% style.\footnote{This trick was added in version 1.2 of the package.}
+% This allows work with existing counters by the same manner as with
+% ``true dynamic'' counters.
+%
+% \DescribeMacro\countstyle
+% To specify a count style you have to use the command
+% \begin{quote}
+% |\countstyle|\marg{counter}
+% \end{quote}
+% The parameter \meta{counter} have to be existing counter, or dynamic
+% counter, or empty. Empty \meta{counter} means the \emph{plain} count
+% style without subordination. If \meta{counter} not exists and is
+% dynamic it is created here within the previously specified count style.
+% The default count style is the plain style.
+%
+% The |\counstyle| command has an optional parameter useful for
+% special purposes. If you want to create some counters in another style
+% that is specified by |\countstyle| command, you can write
+% \begin{quote}
+% |\countstyle|\oarg{list of counters}\marg{another counter}
+% \end{quote}
+% Here \meta{list of counters} is the list of comma separated counters
+% whose count style you want to subordinate to
+% \meta{another counter}. This command creates all undefined counters of
+% the list. The list may contain not only undefined counters but also
+% existing counters. If counter in the list
+% exists, its count style will be modified to be subordinated to
+% \meta{another counter}. Note, that if this counter was subordinated
+% before to any other counter, \emph{the previous subordination will be
+% rejected}. For example, let you want to use the |book| document class
+% and set |\Roman| enumeration of chapters, independent arabic
+% enumeration of sections and to subordinate enumeration of figures,
+% tables and equations to the \emph{section} counter. You can write
+% \begin{quote}
+% |\documentclass{book}|\\
+% |\usepackage{dcounter}|\\
+% |\renewcommand\thechapter{\Roman{chapter}}|\\
+% |\countstyle[section]{}|\\
+% |\countstyle[figure,table,equation]{section}|
+% \end{quote}
+% After that the \emph{chapter} counter will not affect on
+% \emph{section} counter, and all figure, table, and equation numbers
+% will typeset as |\thesection.\arabic{|\emph{foo}|}|.
+%
+% \DescribeMacro\DynamicCount
+% The command
+% \begin{quote}
+% |\DynamicCount|\marg{counter}
+% \end{quote}
+% sets the count style for \meta{counter} exactly the same as for
+% dynamically created counters and creates this counter if it is
+% undefined. This command is internally used in emulation of dynamic
+% counters and in the |\countstyle| command with optional parameter.
+% Since version 1.2, this command is obsolete, but it is saved for
+% backward compatibility.
+%
+% \textbf{Note}. All described commands are used in the preamble.
+%
+% \StopEventually{}
+%
+% \section{The Basic Implementation Part}
+%
+% \begin{macro}{\DCNT@list}
+% \begin{macro}{\DCNT@elist}
+% We begin from the initialization of the list of dynamic counters.
+% |\DCNT@list| contains a list of undeclared counters and
+% |\DCNT@elist| contains a list of existing counters that are declared
+% as dynamic counters.
+% \begin{macrocode}
+%<*package>
+\def\DCNT@list{}
+\def\DCNT@elist{}
+\@onlypreamble\DCNT@elist
+% \end{macrocode}
+% Their items will have the form |\@elt|\marg{counter}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\DCNT@in}
+% The macro |\DCNT@in|\marg{list}\marg{yes}\marg{no}
+% tests the list of counters \meta{list} to contain the counter
+% |\DCNT@foo| and after testing executes \meta{yes}-sequence if
+% |\DCNT@foo| found or \meta{no}-sequence if not. To restrict
+% the scope of internal modifications made by this macro we always
+% enclose it into a group. While processing the list of counters the
+% command executes |\DCNT@noteq|\marg{counter} hook for every
+% counter which name is distinct from the tested name.
+% \begin{macrocode}
+\def\DCNT@in#1#2#3{\@tempswafalse
+ \let\@elt\DCNT@elt #1%
+ \if@tempswa #2\else #3\fi
+}
+\def\DCNT@elt#1{\def\DCNT@name{#1}%
+ \ifx\DCNT@name\DCNT@foo \@tempswatrue \else \DCNT@noteq{#1}\fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DCNT@define}
+% The command |\DCNT@define|\marg{command}\marg{foo}
+% tests the counter \meta{foo} to be undefined and, if it is true,
+% tries to create it dynamically. After that it executes \meta{command}
+% with the \meta{foo} parameter.
+% \begin{macrocode}
+\def\DCNT@define#1#2{%
+ \@ifundefined{c@#2}%
+ {{\edef\DCNT@foo{#2}\let\DCNT@noteq\@gobble
+ \DCNT@in\DCNT@list{\newcounter{#2}\DCNT@the{#2}}{}%
+ }}{}%
+ #1{#2}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DCNT@the}
+% The command |\DCNT@the|\marg{foo} redefines |\the|\meta{foo}
+% command to typeset it in the count style subordinated to |\DCNT@main|
+% counter. It also adds the name \meta{foo} to the resetting list of\/
+% |\DCNT@main| counter.
+% \begin{macrocode}
+\def\DCNT@the#1{%
+ \ifx\DCNT@main\@empty
+ \expandafter\xdef\csname the#1\endcsname
+ {\noexpand\@arabic \expandafter\noexpand \csname c@#1\endcsname}%
+ \else
+ \expandafter\xdef\csname the#1\endcsname
+ {\expandafter\noexpand \csname the\DCNT@main\endcsname
+ .\noexpand\@arabic \expandafter\noexpand \csname c@#1\endcsname}%
+ \@addtoreset{#1}\DCNT@main
+ \fi
+}
+\let\DCNT@main\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \section{The Preamble Only Commands}
+%
+% \begin{macro}{\DeclareDynamicCounter}
+% The following command tests the counter and adds it to the list of
+% dynamic counters if it does not exist or to the list
+% of emulated counters if it already exists. In the last case,
+% |\the|\meta{counter} command is defined as empty command. It will be
+% redefined later at the beginning of document.
+% \begin{macrocode}
+\newcommand*{\DeclareDynamicCounter}[1]{%
+ \begingroup
+ \edef\DCNT@foo{#1}%
+ \ifx\DCNT@foo\@empty
+ \PackageError{dcounter}%
+ {Cannot declare a dynamic counter with empty name}{}%
+ \fi
+ \let\DCNT@noteq\@gobble
+ \@ifundefined{c@#1}%
+ {\DCNT@in\DCNT@list{}{\@cons\DCNT@list{{#1}}}}%
+ {\DCNT@in\DCNT@elist{}{\@cons\DCNT@elist{{#1}}}%
+ \expandafter\global\expandafter\let
+ \csname the#1\endcsname\@empty}%
+ \endgroup
+}
+\@onlypreamble\DeclareDynamicCounter
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\countstyle}
+% Now we implement |\countstyle| command which redefines |\DCNT@main|
+% macro to new main counter. It tests the counter to be defined and
+% tries to define it if\/ not.
+% \begin{macrocode}
+\newcommand{\countstyle}{\@ifnextchar[{\DCNT@lcstyle}{\DCNT@cstyle}}
+\@onlypreamble\countstyle
+\def\DCNT@cstyle#1{\edef\DCNT@foo{#1}%
+ \ifx\DCNT@foo\@empty \else
+ \DCNT@define\@gobble{#1}%
+ \@ifundefined{c@#1}{\@nocounterr{#1}}{}%
+ \fi
+ \let\DCNT@main\DCNT@foo
+}
+\@onlypreamble\DCNT@cstyle
+% \end{macrocode}
+% The special variant of this command with optional parameter locally
+% sets the special count style and redefines all counters in list via
+% the |\DynamicCount| command.
+% \begin{macrocode}
+\def\DCNT@lcstyle[#1]#2{%
+ {\DCNT@cstyle{#2}\@for\@tempa:=#1\do{\DynamicCount\@tempa}}%
+}
+\@onlypreamble\DCNT@lcstyle
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DynamicCount}
+% The macro |\DynamicCount|\marg{foo} modifies the count style of
+% the counter \meta{foo} and defines this counter if it is undefined.
+% \begin{macrocode}
+\newcommand*{\DynamicCount}[1]{%
+ \@ifundefined{c@#1}%
+ {\newcounter{#1}}%
+% \end{macrocode}
+% If the counter is already defined, we check all resetting lists and
+% remove all references to this counter.
+% \begin{macrocode}
+ {{\edef\DCNT@foo{#1}\let\DCNT@noteq\DCNT@add
+ \let\@elt\DCNT@remove \cl@@ckpt
+ }}%
+ \DCNT@the{#1}%
+}
+\@onlypreamble\DynamicCount
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DCNT@remove}
+% The |\DCNT@remove|\marg{foo} command removes all references
+% to |\DCNT@foo| counter from the |\cl@|\meta{foo} list of counters.
+% \begin{macrocode}
+\def\DCNT@remove#1{\expandafter\DCNT@remlist\csname cl@#1\endcsname}
+\def\DCNT@remlist#1{%
+ {\let\@tempa\@empty \DCNT@in#1{\global\let#1\@tempa}{}}%
+}
+\@onlypreamble\DCNT@remove
+\@onlypreamble\DCNT@remlist
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DCNT@add}
+% The |\DCNT@add|\marg{counter} command locally adds
+% |\@elt|\marg{counter} to |\@tempa|.
+% \begin{macrocode}
+\def\DCNT@add#1{%
+ \let\@elt\relax\edef\@tempa{\@tempa\@elt{#1}}\let\@elt\DCNT@elt
+}
+\@onlypreamble\DCNT@add
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DCNT@eltemu}
+% The |\DCNT@emu|\marg{counter} command test |\the|\meta{counter}
+% command to be empty and redefines the counter in the dynamic style.
+% This command is applied to all existing counters that are emulated as
+% dynamic counters.
+% \begin{macrocode}
+\def\DCNT@emu#1{%
+ \expandafter\ifx\csname the#1\endcsname\@empty
+ \DynamicCount{#1}\fi
+}
+\@onlypreamble\DCNT@emu
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Final Modifications}
+%
+% Finally, we modify |\setcounter| and |\addtocounter| commands.
+% We do it at the beginning of the document to avoid conflict with
+% the |calc| package. If\/ the list of dynamic counters is empty,
+% we delete all commands of the package. We also define all
+% dynamically emulated counters if their |\the| command is empty.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \ifx\DCNT@list\@empty
+ \@onlypreamble\DCNT@list
+ \@onlypreamble\DCNT@in
+ \@onlypreamble\DCNT@elt
+ \@onlypreamble\DCNT@define
+ \@onlypreamble\DCNT@the
+ \@onlypreamble\DCNT@main
+ \@onlypreamble\DCNT@name
+ \@onlypreamble\DCNT@foo
+ \@onlypreamble\DCNT@noteq
+ \else
+ \let\DCNT@setcounter\setcounter
+ \def\setcounter{\DCNT@define\DCNT@setcounter}
+ \let\DCNT@addtocounter\addtocounter
+ \def\addtocounter{\DCNT@define\DCNT@addtocounter}
+ \fi
+ {\let\@elt\DCNT@emu \DCNT@elist}%
+}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/desclist.dtx b/Master/texmf-dist/source/latex/ncctools/desclist.dtx
new file mode 100644
index 00000000000..b9498e8913e
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/desclist.dtx
@@ -0,0 +1,154 @@
+% \iffalse
+%%
+%% File: desclist.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{desclist}
+%<package> [2004/11/23 v1.1 Desclist Package (NCC)]
+%
+% \changes{v1.0}{2002/01/09}{This version was uploaded to CTAN}
+% \changes{v1.1}{2004/11/21}{Desclist suffix was enclosed in braces}
+% \changes{v1.1}{2004/11/23}{Documentation was prepared}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{desclist}
+\GetFileInfo{desclist.sty}
+\begin{document}
+\title{The \textsf{desclist} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{desclist.dtx}
+\end{document}
+%</driver>
+% \fi
+% The package implements the |desclist| environment and redefines
+% the |description| environment to provide an optional parameter
+% as a prototype for calculation the hang indent of the list.
+%
+% \section{User Interface}
+%
+% \DescribeMacro{desclist}
+% The |desclist| environment is similar to the |description|
+% environment but adds more control for typesetting list labels.
+% The usage:
+% \begin{quote}
+% |\begin{desclist}|\marg{prefix}\marg{suffix}\oarg{prototype}\\
+% |\item|\oarg{label} \meta{text}\\
+% \ldots\\
+% |\end{desclist}|
+% \end{quote}
+% The \meta{prefix} is inserted before the label and the suffix
+% is inserted after the label. The optional \meta{prototype} parameter
+% specifies a prototype for calculation the minimum width of a list label
+% and for calculation the hang indent of a list text.
+% If this parameter is omitted, the standard hang indent value is used
+% and the minimum width of list labels is equal to zero.
+%
+% A list label is generated in the |\item|\oarg{label} command
+% as follows:
+% \begin{quote}
+% \meta{prefix}\meta{label}\marg{suffix}|\hfil|
+% \end{quote}
+% Therefore, you can finish the \meta{label} with a command having a parameter
+% to replace a suffix with something else. The |\hfil| command at the end of
+% label adds necessary horizontal space if the label width is less than the
+% minimum width of list label. Using a \meta{prototype} together with the
+% |\hfill| command in \meta{prefix} and/or \meta{suffix}
+% parameters, you can align left, align right, or center narrow list labels.
+%
+% The following example shows the benefits of the |desclist| environment:
+% \begin{desclist}{\sf}{ \rm\hfill---}[Mark]
+% \newcommand*\Skip[1]{}
+% \item[M] an item with a narrow label;
+% \item[MM] an item with a narrow label;
+% \item[Mark] an item with a normal label;
+% \item[Long mark] an item with too wide label; and
+% \item[A mark without dash.\Skip] Here we skip the desclist suffix.
+% \end{desclist}
+% It was prepared as follows:
+% \begin{quote}
+% |\begin{desclist}{\sf}{ \rm\hfill---}[Mark]|\\
+% |\newcommand*\Skip[1]{}|\\
+% |\item[M] an item with a narrow label;|\\
+% |\item[MM] an item with a narrow label;|\\
+% |\item[Mark] an item with a normal label;|\\
+% |\item[Long mark] an item with too wide label; and|\\
+% |\item[A mark without dash.\Skip] Here we skip|\\
+% |the desclist suffix.|\\
+% |\end{desclist}|
+% \end{quote}
+%
+% \DescribeMacro{description}
+% The package also redefines the |description| environment to allow
+% an optional parameter. In fact, the new implementation of |description|
+% is equivalent to
+% \begin{quote}
+% |\begin{desclist}{\normalfont\bfseries}{}|\oarg{prototype}\\
+% \ldots\\
+% |\end{desclist}|
+% \end{quote}
+% \StopEventually{}
+%
+% \section{The Implementation}
+% \begin{macro}{desclist}
+% The definition of the |desclist| environment is quite simple.
+% If an optional parameter is omitted, pass an empty one
+% to the internal command.
+% \begin{macrocode}
+%<*package>
+\newenvironment*{desclist}[2]{%
+ \@ifnextchar[{\NCC@dlist{#1}{#2}}{\NCC@dlist{#1}{#2}[]}%
+}{%
+ \endlist
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@dlist}
+% The internal definition of the |desclist| is based on the |\list|:
+% \begin{macrocode}
+\def\NCC@dlist#1#2[#3]{%
+ \list{}{%
+% \end{macrocode}
+% Specify just the same list parameters as in the |description|
+% if the optional parameter is empty:
+% \begin{macrocode}
+ \def\@tempa{#3}\ifx\@tempa\@empty
+ \labelwidth\z@ \itemindent-\leftmargin
+% \end{macrocode}
+% In other case, use the prototype to calculate the label width
+% and margins:
+% \begin{macrocode}
+ \else
+ \settowidth\leftmargin{#1#3{#2}}%
+ \advance\leftmargin\labelsep
+ \labelwidth=\leftmargin
+ \itemindent\z@
+ \fi
+% \end{macrocode}
+% Finally, define the |\makelabel| command adding the desclist
+% prefix and suffix and finishing it with |\hfil| to allow left
+% alignment for narrow labels. The suffix is enclosed in braces,
+% to allow a trick with ignoring it in the label mark if necessary
+% (see the example above):
+% \begin{macrocode}
+ \def\makelabel##1{\hspace\labelsep #1##1{#2}\hfil}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{description}
+% Now we redefine the |description| environment. We do not test
+% is it defined or not.
+% \begin{macrocode}
+\def\description{\desclist{\normalfont\bfseries}{}}
+\let\enddescription=\enddesclist
+%</package>
+% \end{macrocode}
+% \end{macro}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/extdash.dtx b/Master/texmf-dist/source/latex/ncctools/extdash.dtx
new file mode 100644
index 00000000000..7723fa0a5f3
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/extdash.dtx
@@ -0,0 +1,257 @@
+% \iffalse
+%%
+%% File: extdash.dtx Copyright (C) 1998-2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{extdash}
+%<package> [2005/01/29 v1.2 Extended Dash Package (NCC)]
+%
+% \changes{v1.0}{1998/12/20}{Initial version}
+% \changes{v1.1}{2004/11/23}{Minor corrections of the documentation}
+% \changes{v1.2}{2005/01/29}{Change spaces surround em-dash}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{extdash}
+\GetFileInfo{extdash.sty}
+\begin{document}
+\title{The \textsf{extdash} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{extdash.dtx}
+\end{document}
+%</driver>
+% \fi
+% The package implements the commands, |\Hyphdash|, |\Endash|, and
+% |\Emdash|, to control hyphenation of compound words and ordinary
+% words dashed by \emph{em-dash}. Some additional commands and
+% shortcuts are also introduced.
+%
+% \section{User Interface}
+%
+% \DescribeMacro{\Hyphdash}
+% \DescribeMacro{\Hyphdash*}
+% The main purpose of the |extdash| package is to allow hyphenation
+% of compound words. When the word |something-something| occur the only
+% hyphenation point after the dash is available. To allow hyphenation
+% of both words joint by dash you can write
+% \begin{center}
+% |something\Hyphdash something|\quad or easier\quad
+% |something\-/something|
+% \end{center}
+% (the last case is available if\/ you use the package |extdash|
+% with |shortcuts| option). Some times the line break immediately after
+% the dash is inadmissible. To avoid it you can write
+% \begin{center}
+% |something\Hyphdash* something|\quad or easier\quad
+% |something\=/something|
+% \end{center}
+% (the last case is also shortcut). An example is the word
+% \emph{$L$-approximation} which can't be broken at the dash.
+%
+% \DescribeMacro{\Endash}
+% \DescribeMacro{\Endash*}
+% Analogously, you can use |\Endash| command (may be with star) to join
+% words by \emph{en-dash}. Shortcuts for it are |\--| and |\==|.
+%
+% \DescribeMacro{\Emdash}
+% \DescribeMacro{\Emdash*}
+% The last case is the use of \emph{em-dash} when some glue
+% before and after em-dash have to be added. The command |\Emdash| adds
+% this glue, named |\Halfspace|, which natural width is equal to the
+% \DescribeMacro{\Halfspace}
+% \DescribeMacro{\Halfspace*}
+% half of the ordinary interword space. The |\Halfspace| command
+% produces the \emph{elastic} horizontal space and its |*|-form
+% produces the unbreakable elastic space. All these commands have
+% shortcuts, named
+% \begin{center}
+% |\---|\qquad |\===|\qquad |\-,|\qquad |\=,|
+% \end{center}
+% Note, that |\Emdash| command removes extra space before and after it.
+% When |\Emdash| appears at the beginning of a paragraph (the direct
+% speech) the space after it will be rigid and unbreakable.
+%
+% The standard em-dash is longer that it is required by Russian
+% typesetting rules. To decrease its length to required one you have
+% to use |extdash| package with |cyremdash| option.
+%
+% \section{The Package Options}
+%
+% The |extdash| package provides two options, |shortcuts| and
+% |cyremdash|:
+% \begin{center}
+% |\usepackage[shortcuts,cyremdash]{extdash}|
+% \end{center}
+%
+% First option redefines \LaTeX{} commands |\-| and |\=| in
+% such a way to recognize shortcut sequences. If\/ no shortcut
+% recognized the corresponding original command will be called.
+% In other words, when no shortcut recognized the command |\-|
+% sets extra hyphenation point and |\=| means the accent command.
+%
+% The last option redefines |\Emdash| to be shorter than the standard
+% em-dash.
+%
+% \section{The Shortcuts Table}
+%
+% \begin{center}
+% \begin{tabular}{l@{\qquad}l@{\qquad\qquad}l@{\qquad}l}
+% Command & Shortcut & Command & Shortcut \\
+% \cs{Hyphdash} & \cs{-/} & \cs{Hyphdash*} & \cs{=/} \\
+% \cs{Endash} & \cs{--} & \cs{Endash*} & \cs{==} \\
+% \cs{Emdash} & \cs{---} & \cs{Emdash*} & \cs{===} \\
+% \cs{Halfspace}& \cs{-,} & \cs{Halfspace*}& \cs{=,}
+% \end{tabular}
+% \end{center}
+%
+% \emph{All described commands and shortcuts are robust.}
+%
+% \StopEventually{}
+%
+% \section{The Basic Implementation Part}
+%
+% \begin{macro}{\EXD@test}
+% \begin{macro}{\EXD@break}
+% First we implement the command, |\EXD@test|. It recognizes the
+% star after the command, sets |\EXD@break| command to be equal
+% to |\nobreak| if\/ star is found or |\@empty| if\/ not, and calls
+% its parameter.
+% \begin{macrocode}
+%<*package>
+\def\EXD@test#1{%
+ \@ifstar{\let\EXD@break\nobreak #1}{\let\EXD@break\@empty #1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\Hyphdash}
+% \begin{macro}{\Endash}
+% \begin{macro}{\Emdash}
+% \begin{macro}{\Halfspace}
+% Now we declare user's level commands
+% \begin{macrocode}
+\DeclareRobustCommand{\Hyphdash}{\EXD@test{\EXD@dash-}}
+\DeclareRobustCommand{\Endash}{\EXD@test{\EXD@dash{--}}}
+\DeclareRobustCommand{\Emdash}{\EXD@test{\EXD@emd@sh}}
+\DeclareRobustCommand{\Halfspace}{\@tempcnta\z@
+ \@ifstar{\nobreak\EXD@space\ignorespaces}{\EXD@space\ignorespaces}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\EXD@dash}
+% \begin{macro}{\EXD@emd@sh}
+% \begin{macro}{\EXD@space}
+% and then the basic commands
+% \begin{macrocode}
+\def\EXD@dash#1{%
+ \nobreak\leavevmode\hbox{#1}\EXD@break\hskip\z@skip \ignorespaces
+}
+\def\EXD@emd@sh{%
+ \ifvmode
+ \EXD@emdash\nobreak\hskip.35em
+ \else
+ \unskip\nobreak\@tempcnta\m@ne
+ \EXD@space \EXD@emdash \EXD@break \EXD@space
+ \fi \ignorespaces
+}
+% \end{macrocode}
+% The |\@tempcnta| specifies the width of half-space. It can have
+% the following values: |-1|, |0|, or |+1|. The negative value
+% means using the space before em-dash (the space is narrow at this point),
+% zero value means an ordinary half space, and the positive value
+% means a half-space after em-dash (the space is wider at this point).
+% This trick compensates a visual effect of wider space before an em-dash
+% especially if the punctuation mark goes before.
+% \begin{macrocode}
+\def\EXD@space{%
+ \edef\@tempa{%
+ \ifnum\@tempcnta<\z@ .4\else \ifnum \@tempcnta=\z@ .5\else .6\fi\fi
+ }%
+ \hskip \@tempa\fontdimen2\font \@plus .5\fontdimen3\font
+ \@minus \@tempa\fontdimen4\font
+ \@tempcnta -\@tempcnta
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\EXD@emdash}
+% The last basic command is the default \emph{em-dash}. It could be
+% redefined later in |cyremdash| option.
+% \begin{macrocode}
+\def\EXD@emdash{\leavevmode\hbox{---}}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Shortcuts}
+%
+% \begin{macrocode}
+\DeclareOption{shortcuts}{%
+% \end{macrocode}
+%
+% \begin{macro}{\HyphOrDash}
+% \begin{macro}{\BarOrDash}
+% The commands |\HyphOrDash| and |\BarOrDash| will be called by |\-| and
+% |\=| commands. They choose the corresponding shortcut or the original
+% commands saved in |\EXD@hyph| and |EXD@dash|.
+% \begin{macrocode}
+ \DeclareRobustCommand{\HyphOrDash}{%
+ \let\EXD@break\@empty
+ \@ifnextchar/{\EXD@d@sh}{%
+ \@ifnextchar-{\EXD@hdash}{%
+ \@ifnextchar,{\EXD@sp@ce}{\EXD@hyph}%
+ }%
+ }%
+ }
+ \DeclareRobustCommand{\BarOrDash}{%
+ \let\EXD@break\nobreak
+ \@ifnextchar/{\EXD@d@sh}{%
+ \@ifnextchar={\EXD@bdash}{%
+ \@ifnextchar,{\nobreak\EXD@sp@ce}{\EXD@bar}%
+ }%
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Shortcuts:
+% \begin{macrocode}
+ \def\EXD@d@sh/{\EXD@dash-}
+ \def\EXD@sp@ce,{\EXD@space}
+ \def\EXD@hdash-{\@ifnextchar-{\EXD@hhdash}{\EXD@dash{--}}}
+ \def\EXD@bdash={\@ifnextchar={\EXD@bbdash}{\EXD@dash{--}}}
+ \def\EXD@hhdash-{\EXD@emd@sh}
+ \def\EXD@bbdash={\EXD@emd@sh}
+% \end{macrocode}
+%
+% We turn on the shortcuts mechanism at the beginning of the document to
+% avoid conflict with |fontenc| package which redefines accents.
+% \begin{macrocode}
+ \AtBeginDocument{%
+ \let\EXD@hyph\- \let\@dischyph\HyphOrDash \let\-\@dischyph
+ \let\EXD@bar\= \let\@acciii\BarOrDash \let\=\@acciii
+ }
+}
+% \end{macrocode}
+%
+% \section{Cyrillic Em-dash}
+%
+% \begin{macrocode}
+\DeclareOption{cyremdash}{%
+ \def\EXD@emdash{\leavevmode\hb@xt@.8\fontdimen6\font{--\hss--}}
+}
+\ProcessOptions\relax
+%</package>
+% \end{macrocode}
+%
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/manyfoot.dtx b/Master/texmf-dist/source/latex/ncctools/manyfoot.dtx
new file mode 100644
index 00000000000..470a7b605b2
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/manyfoot.dtx
@@ -0,0 +1,1514 @@
+% \iffalse
+%%
+%% File: manyfoot.dtx Copyright (C) 1998--2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}[1993/12/01]
+%<package>\ProvidesPackage{manyfoot}
+%<package> [2005/09/11 v1.10 Many Footnote Levels Package (NCC)]
+%
+% \changes{v1.0}{1998/11/09}{Initial version}
+% \changes{v1.1}{1998/11/13}{Compatibility problems solved}
+% \changes{v1.2}{1998/11/15}{Such footnotes may now appear in minipages!}
+% \changes{v1.3}{1998/11/23}{Floating support bug fixed}
+% \changes{v1.4}{1998/12/19}{Hand footnotes are moved to nccfoots package}
+% \changes{v1.4}{1998/12/19}{Options |ruled| and |para*| added}
+% \changes{v1.5}{2003/02/26}{|\DeclareNewFootnote| command introduced}
+% \changes{v1.5}{2003/02/26}{Compatibility with footmisc added}
+% \changes{v1.5}{2003/02/27}{More compatibility with footmisc}
+% \changes{v1.5}{2003/03/03}{|\Footnote|\marg{suffix} and
+% |\Footnotemark|\marg{suffix} added}
+% \changes{v1.5}{2003/03/16}{Option |perpage| added}
+% \changes{v1.5}{2003/03/26}{The |\MFL@footnoterule| introduced
+% for more compatibility with footmisc}
+% \changes{v1.5}{2003/04/02}{Custom footnote rules support added}
+% \changes{v1.6}{2003/05/11}{Restore |\footnotemargin| support occasionally removed}
+% \changes{v1.6}{2003/05/12}{Add support for |multiple| option from footmisc}
+% \changes{v1.7}{2004/09/20}{The |\ExtraParaSkip| command introduced}
+% \changes{v1.8}{2004/11/23}{Minor corrections of the documentation}
+% \changes{v1.9}{2005/02/10}{|\NCC@makemark| replaced with |\NCC@makefnmark|}
+% \changes{v1.9}{2005/05/11}{Introduce the |\SetFootnoteHook| command}
+% \changes{v1.10}{2005/09/11}{Remove overflow in calculation the fudge factor}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage[para]{manyfoot}
+\DeclareNewFootnote{A}
+\DeclareNewFootnote[para]{B}[roman]
+\GetFileInfo{manyfoot.sty}
+\begin{document}
+\title{The \textsf{manyfoot} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{manyfoot.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% This package implements a command, |\newfootnote|, that adds
+% footnote levels to the standard \LaTeX's footnote mechanism. Footnotes
+% of every additional level are automatically grouped together
+% on a \LaTeXe{} output page and are separated from another levels
+% by the special vertical space and rule.
+% The |\newfootnote| command allows customization of the
+% way footnotes of additional level are represented in \LaTeXe{}
+% documents. Two
+% customization styles are available now: the |plain| style is the
+% ordinary \LaTeX's style of footnote representation; the |para| style
+% causes footnotes to be typeset as a run-in paragraph (derived from
+% Donald Knuth's \TeX book and from another sources such as the package
+% |fnpara| by Dominik Wujastyk and Chris Rowley and the package
+% |footmisc| by Robin Fairbairns).
+%
+% An additional |\DeclareNewFootnote| command is introduced since the
+% version~1.5 of the package. It simplifies creation of new
+% footnote levels with automatic enumeration. Thanks to Frank Mittelbach
+% for this suggestion and for many other proposals for the package
+% improvement.
+%
+% Since version 1.5, a new footnote rule selection method is
+% introduced (thanks to Christian Tapp |<chr.tapp@gmx.de>|
+% for the idea of this improvement). It allows a customization of
+% footnote rules to be inserted before footnote levels.
+%
+% \section{User Interface}
+%
+% \DescribeMacro\extrafootnoterule
+% Footnotes of different levels are separated at the output page
+% by the special footnote rule, |\extrafootnoterule|.
+% By the default this command is empty. If you want to separate
+% footnotes by a footnote rule you may redefine it
+% or call the package with the |ruled| option:
+% \begin{quote}
+% |\usepackage[ruled]{manyfoot}|
+% \end{quote}
+% In this case, the |\extrafootnoterule| receives a value of the
+% default footnote rule command.
+%
+% \DescribeMacro\defaultfootnoterule
+% The default footnote rule is saved in the |\defaultfootnoterule| command
+% at the beginning of document (we provide this for compatibility with
+% the |splitrule| option of the \textbf{footmisc} package).
+%
+% The style |para| of footnotes typesetting needs many code. To save
+% space, the support for this style is loaded with |para| or |para*| options.
+% If you are going to use run-in paragraph footnotes indented as
+% ordinary footnotes, use the package with the
+% |para| option:
+% \begin{quote}
+% |\usepackage[para]{manyfoot}|
+% \end{quote}
+% To suppress indentation, use it with the |para*| option:
+% \begin{quote}
+% |\usepackage[para*]{manyfoot}|
+% \end{quote}
+% Note, that these options only \emph{allow} you to generate
+% additional footnote levels in |para| style.
+% But what style you prefer for every footnote level is up to you. For
+% example, let as generate two footnote levels: the first---in ordinary
+% style and the second---in |para| style. To do this we have to write
+% the following code in the preamble of the document:
+% \begin{quote}
+% |\usepackage[para]{manyfoot}|\\
+% |\newfootnote{A}|\\
+% |\newfootnote[para]{B}|
+% \end{quote}
+% \DescribeMacro\newfootnote
+% The mandatory parameter of |\newfootnote| is a \emph{suffix} to be added
+% to the end of command names generated by |\newfootnote| command.
+% The optional parameter is a customization
+% style for generated footnote level (two styles now implemented, named
+% |plain| and |para|; the default is |plain|).
+%
+% This example generates
+% two commands, |\FootnotetextA| and |\FootnotetextB|, for insertion of
+% a text into corresponding footnote levels. Their syntax
+% is the following:
+% \begin{quote}
+% |\Footnotetext|\meta{suffix}\marg{marker}\marg{inserted
+% text}
+% \end{quote}
+% They put the \meta{inserted text} marked with \meta{marker} into
+% \TeX's insert register |\footins|\meta{suffix} (this insert is also
+% generated by |\newfootnote| command). We use \emph{the hand} style of
+% footnote marking, because the choice of how such footnotes have to be
+% marked is user's one. Such a way simplifies the syntax of new commands
+% and minimize a number of additional commands needed.
+%
+% \DescribeMacro\Footnotemark
+% \DescribeMacro\Footnotetext
+% \DescribeMacro\Footnote
+% It is clear that accompany to |\Footnotetext|\meta{suffix} must
+% present something like \emph{the hand footnote mark} command. Such
+% commands are provided by |nccfoots| package which is automatically
+% loaded in this package. Their syntax is the following:
+% \begin{quote}
+% |\Footnotemark|\marg{marker}\\
+% |\Footnotetext|\marg{marker}\marg{inserted text}\\
+% |\Footnote|\marg{marker}\marg{inserted text}
+% \end{quote}
+% The first command is useful for all footnote levels. Two last commands
+% are the hand companions for \LaTeX's |\footnote...| commands.
+%
+% The question is what these commands have to do when \meta{marker} is
+% empty? In such a case we leave the current marker unchanged.
+% Therefore, |\Footnote| command is equal to
+% \begin{quote}
+% |\Footnotemark|\marg{marker}|\Footnotetext{}|\marg{inserted text}
+% \end{quote}
+% This is useful for |\Footnotetext|\meta{suffix} commands in
+% |plain| style. For |para| style the empty \meta{marker} means
+% the footnote without marker (this is the special case used for
+% splitting long footnotes in |para| style; see below).
+%
+% Finally, we explain\footnoteA{This is the first A-level footnote.}
+% on the previous example\footnoteB{This is the first B-level
+% footnote.} how to automate\footnoteA{The second
+% A-footnote.} enumeration of the
+% additional\footnoteB{The second B-footnote.}
+% footnote\footnoteA{The third A-footnote.}
+% levels\footnoteB{The third very very very very very very very very very
+% long B-footnote.} (we have used in this
+% sentence a number of level's |A| and |B| footnotes to show how this
+% package works). Let us enumerate the footnotes of |A|~level by arabic
+% numbers and the footnotes of |B|~level by roman numbers. We allocate
+% two new counters named |footnoteA| and |footnoteB| and define the
+% corresponding |\footnote...| commands with automatic enumeration. The
+% corresponding code is the following
+% \begin{quote}
+% |\newcounter{footnoteA}|\\
+% |\newcommand{\footnoteA}{%|\\
+% | \stepcounter{footnoteA}%|\\
+% | \Footnotemark\thefootnoteA \FootnotetextA{}}|\\
+% |\newcounter{footnoteB}|\\
+% |\newcommand{\footnoteB}{%|\\
+% | \stepcounter{footnoteB}%|\\
+% | \Footnotemark\thefootnoteB \FootnotetextB\thefootnoteB}|\\
+% |\renewcommand{\thefootnoteB}{\roman{footnoteB}}|
+% \end{quote}
+% To produce footnotes presented here, we have done the following
+% \begin{verbatim}
+% Finally, we explain\footnoteA{This is the first A-level
+% footnote.} on the previous example\footnoteB{This is the first
+% B-level footnote.} how to automate\footnoteA{The second
+% A-footnote.} enumeration of the additional\footnoteB{The second
+% B-footnote.} footnote\footnoteA{The third A-footnote.}
+% levels\footnoteB{The third very very very very very very very
+% very very long B-footnote.}\end{verbatim}
+%
+% \section{Declaring New Footnotes}
+%
+% \DescribeMacro\DeclareNewFootnote
+% To create a new footnote level with automate enumeration, you need to
+% type a bulk of code: create a new footnote level (e.g.~|\newfootnote{A}|),
+% create a counter for automate enumeration (e.g.~|\newcounter{footnoteA}|),
+% and create a footnote insertion command (e.g.~|\newcommand{\footnoteA}|).
+% All these things can be automated with the |\DeclareNewFootnote| command
+% used in the preamble only:
+% \begin{quote}
+% |\DeclareNewFootnote|\oarg{footnote style}\marg{suffix}\oarg{enumeration style}
+% \end{quote}
+% Here \meta{footnote style} is the customization style (|plain| is default) and
+% \meta{enumeration style} is a style of numbering. This macro
+% also prepares |\footnotemark|\meta{suffix}, |\footnotetext|\meta{suffix},
+% |\Footnotemark|\meta{suffix}, and |\Footnote|\meta{suffix} commands for
+% completeness.
+% For example, the command |\DeclareNewFootnote{A}| creates the following:
+% \begin{itemize}
+% \item The new plain footnote level with \TeX's insert register |\footinsA|;
+% \item The counter |footnoteA| with arabic numbering;
+% \item The command |\FootnoteA|\marg{marker}\marg{inserted text};
+% \item The command |\FootnotemarkA|\marg{marker};
+% \item The command |\FootnotetextA|\marg{marker}\marg{inserted text};
+% \item The command |\footnoteA|\oarg{number}\marg{inserted text};
+% \item The command |\footnotemarkA|\oarg{number}; and
+% \item The command |\footnotetextA|\oarg{number}\marg{inserted text}.
+% \end{itemize}
+% The first three |\Footnote...| commands work as their analogues without
+% suffix, and the behavior of three last commands is just the same as for
+% ordinary |\footnote|, |\footnotemark|, and |\footnotetext|.
+% Examples of footnote controls shown in the previous section can be easy
+% specified in the following two lines:
+% \begin{quote}
+% |\DeclareNewFootnote{A}|\\
+% |\DeclareNewFootnote[para]{B}[roman]|
+% \end{quote}
+%
+% \section{Custom Footnote Rules}
+%
+% \DescribeMacro\SelectFootnoteRule
+% A custom footnote rule can be specified for every new footnote level.
+% Just store the |\SelectFootnoteRule| command before a new footnote
+% declaration. Its syntax is the following:
+% \begin{quote}
+% |\SelectFootnoteRule|\oarg{priority}\marg{rule name}\oarg{action}
+% \end{quote}
+% The \meta{priority} is a nonnegative integer number specifying an importance
+% of the rule. It controls the process of a footnote rule selection while
+% typeset (see more detail description below). The default priority is 0.
+% The \meta{rule name} is a prefix of the footnote rule command to be used
+% before the next footnote level. The command |\|\meta{rule name}|footnoterule|
+% is used as a footnote rule. The \meta{action} parameter specifies an
+% additional action to be applied just before the next footnote group if it
+% is nonempty (for example, an action can produce a marginal mark near the
+% footnote group). The default action is empty. A footnote rule and
+% an action must insert a material of zero height in vertical mode.
+%
+% Two footnote rule commands are predefined:
+% |\extrafootnoterule| and |\defaultfootnoterule|. The |\extrafootnoterule|
+% is selected with zero priority before a new footnote level if no other
+% footnote rule was selected with the |\SelectFootnoteRule| command. The
+% |\defaultfootnoterule| is usually equal to the |\footnoterule|, but if
+% the |\footnoterule| was redefined in the \textbf{footmisc} package with
+% the |splitrule| option, the |\defaultfootnoterule| will save the
+% original value of the footnote rule. So, if you want to select an ordinary
+% footnote rule for the next footnote level, use the following command
+% \begin{quote}
+% |\SelectFootnoteRule{default}|
+% \end{quote}
+% The following example create four footnote levels with rule inserted between
+% footnotes A,B and C,D:
+% \begin{quote}
+% |\DeclareNewFootnote{A}|\\
+% |\DeclareNewFootnote[para]{B}[alph]|\\
+% |\SelectFootnoteRule[1]{default}|\\
+% |\DeclareNewFootnote{C}[roman]|\\
+% |\DeclareNewFootnote{D}[Roman]|
+% \end{quote}
+% To use more custom footnote rules, you must create corresponding commands
+% in some way.
+%
+% The algorithm of footnote rule insertion while a page output is the following:
+% \begin{itemize}
+% \item At first, we set the |\defaultfootnoterule| to be the current rule.
+% Then we test the insert register of the standard footnote group.
+% If it is empty, we set the priority of current rule to |1|,
+% otherwise to |-1| (|-1| means that this rule is already played).
+% \item After that, we do the following for every next footnote group.
+% We compare the priority of current rule and the priority of rule
+% linked with the next footnote group. If the current priority is less
+% or equal to the next priority, the current rule is changed to the
+% next rule and the current priority is set to the next priority.
+% Then we test an insert register of the next footnote group.
+% If this footnote group is nonempty, we insert the current rule
+% before it and decrease the current priority to |-1| (played rule).
+% \end{itemize}
+%
+% \DescribeMacro\footnoterulepriority
+% The priority for the rule of standard footnote group is specified
+% in the |\footnoterulepriority| command. Its default value is |1| (this means that
+% the standard footnote rule is more important then every next rule of 0th priority).
+% You can redefine this priority with the |\renewcommand|.
+%
+% \section{Add Hooks at the Beginning of Footnotes}
+%
+% \DescribeMacro\SetFootnoteHook
+% Since version 1.9, a new command |\SetFootnoteHook|\marg{text} is introduced.
+% This command is used before a new footnote declaration and specifies
+% an action applied for such footnotes.
+%
+% If the new footnote level is plain, the hook is applied at the beginning of
+% every its footnote. For example, the following declaration specifies
+% A-footnotes with hang numbering:
+% \begin{quote}
+% |\SetFootnoteHook{\hangindent=1.8em\noindent}|\\
+% |\DeclareNewFootnote{A}|
+% \end{quote}
+%
+% For para-footnotes, the hook is applied in the output routine after
+% merging all para-footnotes together. The following declaration specified
+% B-footnotes starting with the word ``Cases:'' typeset in boldface:
+% \begin{quote}
+% |\SetFootnoteHook{\noindent\textbf{Cases:}\quad}|\\
+% |\DeclareNewFootnote[para]{B}[alph]|\\
+% \end{quote}
+%
+% \section{Per-page Footnotes Numbering}
+%
+% The per-page resetting of counters can be implemented with the |perpage|
+% package by David Kastrup. For example, if you need to
+% reset the |footnoteA| counter every page, just insert the following
+% in the preamble of you document (after declaring the footnote level A of course):
+% \begin{quote}
+% |\usepackage{perpage}|\\
+% |\MakePerPage{footnoteA}|
+% \end{quote}
+% If all new footnote levels declared with the |\DeclareNewFootnote| command
+% must reset every page, use the |perpage| option:
+% \begin{quote}
+% |\usepackage[perpage]{manyfoot}|
+% \end{quote}
+% In this case, the |perpage| package is loaded automatically and the
+% |\MakePerPage| command is applied to every counter created with the
+% |\DeclareNewFootnote|.
+%
+% \section{Splitting of Para-Footnotes}
+%
+% The algorithm proposed by Donald Knuth for processing run-in
+% paragraph footnotes has some shortages. Namely, small overfulls of
+% output page frequently arise and the automatical splitting of long
+% footnotes is impossible. First bug is corrected here (look at the
+% implementation section below), but the second one couldn't be easily
+% eliminated.
+%
+% \DescribeMacro\SplitNote
+% To split a long footnote near the end of the output page we propose
+% the following method. You should decide where the splitting have to be
+% done. Then you split footnote ``by hands" into two parts. You leave
+% \emph{the first part} at the same position in the text and complete its
+% text by the command |\SplitNote|. You move \emph{the second part} down
+% in the source file and attach it to any text corresponding to the next
+% page via the |\Footnotetext...| command with \emph{the empty marker}.
+% E.g. you source text will look as follows:
+% \begin{verbatim}
+% This text goes on the current
+% page\footnoteB{This is the beginning of the long
+% footnote ... the splitting must be here\SplitNote}
+% ...
+% This text goes on the next
+% page\FootnotetextB{}{and the end of the split
+% footnote is here ...}\end{verbatim}
+% If both parts of split footnote get into the same output page, the
+% splitting is ignored.
+%
+% \section{Footnotes within Minipages and Multicolumns}
+%
+% If you attach an additional level footnote to some text inside a
+% minipage, it will appear at the bottom of the page nor the minipage.
+%
+% The package correctly works together with |multicol| package and
+% gives good results when switching between one and two columns by
+% \LaTeX's commands |\twocolumn| and |\onecolumn|.
+%
+% \section{Compatibility with footmisc}
+%
+% The |footmisc| package also provides the |para| option. You cannot
+% use this option with |footmisc| if you plan to use it (or |para*|)
+% with |manyfoot|.
+%
+% The footnote margins management from the |footmisc| package acts on the
+% |manyfoot| also, but with some limitations concerning to footnotes
+% in the |para| style:
+% \begin{itemize}
+% \item If the |manyfoot| package is loaded with the |para*| option,
+% the margin management options of the |footmisc| package have no
+% influence on additional footnotes of |manyfoot| in |para| style.
+% \item If the |manyfoot| package is loaded with the |para| option,
+% the margin management options |flushmargin| and |hang| of the
+% |footmisc| package appropriately change the indentation of |para|
+% footnotes created with the |manyfoot| package. More exactly, a
+% nonnegative value of the |\footnotemargin| is taken into
+% account in this case. But if a width of the starting footnote
+% marker becomes greater than |0.8em|, the hang indentation of such
+% footnote will exceed the value of |\footnotemargin|.
+% \end{itemize}
+% Footnotes having the |plain| style inherit all
+% formatting specified in the |footmisc|, because they use the
+% standard |\@makefntext| hook.
+%
+% \section{Add Extra Skip for Para-Footnotes}
+%
+% The algorithm used for calculation the vertical space occupied
+% with para-footnotes has one serious disadvantage. It cannot exactly
+% calculate how many vertical space the collected para-footnotes will
+% occupy because the formatting of such footnotes in vertical box is
+% applied in the output routine \textit{after} \TeX\ decides on page
+% breaking. For example, if collected para-footnotes occupy 2.25 lines,
+% the algorithm reserves the vertical space of |2.25\normalbaselineskip|
+% for them, but when such footnotes will be formatted in vbox, 3 lines
+% will be necessary of course. This is the reason why the use of
+% para-footnotes can lead to page overfull. To compensate this
+% overfull we use a special trick: we add a special space to
+% a value of skip for all insert registers taking part with
+% para-inserts.
+% When the insertions are formatted in the output routine, the
+% adjusted space is turned back. So, the additional space appears
+% and the overfull disappears.
+%
+% The value of space to be adjusted is calculated as follows:
+% \begin{center}
+% |max(\footnotesep-\height\strut,0)+0.5\normalbaselineskip|
+% \end{center}
+% We take into account here that the
+% value of |\footnotesep| can be larger than the height of |\strut|
+% and the total height of para-footnotes is less than the required
+% height by |0.5\baselineskip| on the average.
+%
+% \DescribeMacro\ExtraParaSkip
+% Sometimes, the assumptions on the required extra space are wrong
+% and footnotes can overlap on the text (this situation can occur
+% in long tables). So, the new command, |\ExtraParaSkip|\marg{space},
+% was introduced since version 1.7 (by the proposal of Uwe L\"uck
+% |<ednotes.sty@web.de>| and Florian Kragl |<a9902976@unet.univie.ac.at>|)
+% to adjust the default extra space.
+% The command can be used in the preamble only.
+% It can be used more than once. The later use of the command
+% overrides the previous one.
+%
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% First we load |nccfoots| package, containing hand footnote mark
+% commands and the command |\NCC@makefnmark|\marg{marker} which
+% generates marker in |\@thefnmark| command.
+% \begin{macrocode}
+%<*package>
+\RequirePackage{nccfoots}
+% \end{macrocode}
+%
+% \begin{macro}{\extrafootnoterule}
+% Then we define the empty |\extrafootnoterule| command and implement |ruled|
+% option that sets the |\extrafootnoterule| to be equal to the
+% |\defaultfootnoterule|. The |\defaulfootnoterule| is later defined
+% at the beginning
+% of document. It is set to the |\pagefootnoterule| if the last is specified
+% or to the |\footnoterule| if not.
+% This trick provides the compatibility with the |splitrule| option of the
+% \textbf{footmisc} package in which the default |\footnoterule| is saved
+% in |\pagefootnoterule| and then redefined.
+% \begin{macrocode}
+\newcommand{\extrafootnoterule}{}
+\DeclareOption{ruled}{\def\extrafootnoterule{\defaultfootnoterule}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@columnwidth}
+% \begin{macro}{\MFL@floathook}
+% We use the dimen |\MFL@columnwidth| instead of |\columnwidth| while
+% producing the footnote for insertion. We set this dimen to be equal
+% to |\columnwidth| at the beginning of document and within the
+% |\@floatplacement| command. The command |\MFL@floathook| does this
+% job. Later, in |para| option, we'll add to this hook the resetting of
+% the fudge factor.
+% \begin{macrocode}
+\newdimen\MFL@columnwidth
+\def\MFL@floathook{\MFL@columnwidth\columnwidth}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\MFL@insert}
+% The command |\MFL@insert|\marg{insert register}\marg{text}
+% inserts the text to the insert register and sets the standard
+% splitting parameters. We let this command to be equal |\MFL@mpinsert|
+% when go into a minipage. To use this command after a minipage we save
+% its value in |\MFL@realinsert| command.
+% To support |multiple| option from |footmisc| we add the
+% |\FN@mf@prepare| command from |footmisc| (suggested by Frank Mittelbach).
+% \begin{macrocode}
+\long\def\MFL@insert#1#2{%
+ \insert#1{\splittopskip\footnotesep \splitmaxdepth \dp\strutbox
+ \floatingpenalty\@MM #2%
+ }%
+ \FN@mf@prepare
+}
+\providecommand\FN@mf@prepare{}
+\let\MFL@realinsert\MFL@insert
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@applyhook}
+% The command |\MFL@applyhook|\marg{insert register} applies a hook
+% corresponding to the given insert register.
+% \begin{macrocode}
+\def\MFL@applyhook#1{\csname MFL@hook\string#1\endcsname}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Footnote Styles Support}
+%
+% \DescribeMacro{\MFL@start...}
+% Every additional footnote level has deal with its own
+% \emph{insert register}
+% which is allocated by the |\newfootnote| command. This insert register is
+% automatically initialized with the same values as the |\footins|
+% register. You can modify its parameters and do something more in
+% the command
+% \begin{quote}
+% |\MFL@start|\meta{style}\marg{insert register}
+% \end{quote}
+% You must do all modifications globally, because this command is called
+% within the group. It is called at the beginning of the document for
+% every
+% footnote of such style and is needed in the preamble only.
+%
+% \DescribeMacro{\MFL@fnote...}
+% To put footnote into the insert register the command
+% \begin{quote}
+% |\MFL@fnote|\meta{style}\marg{insert
+% register}\marg{marker}\marg{inserted text}
+% \end{quote}
+% is used. Note that you have to define it with |\long| modifier if you
+% allow footnotes consisting of a number of paragraphs. You have to use
+% the macros |\MFL@insert| and |\MFL@columnwidth| instead of |\insert|
+% and |\columnwidth|.
+%
+% \DescribeMacro{\MFL@process...}
+% And the last style customization command
+% \begin{quote}
+% |\MFL@process|\meta{style}\marg{insert register}
+% \end{quote}
+% is called within the output routine to prepare the box of the
+% \meta{insert register} for joining it with another footnote inserts.
+%
+% Do some comments on joining algorithm. It joins together all nonempty
+% footnote insert boxes and puts the result into |\footins| box. Special
+% vertical space and footnote rule are added between every
+% two neighboring nonempty inserts. This space
+% is defined by the skip value from the second neighbor. In other words the skip
+% of the \meta{insert register} is the vertical space to be added
+% between
+% this insert and any nonempty footnote insert coming before it in the
+% \emph{list of footnote inserts}. Note that this skip can be
+% modified while processing of the document (the |multicol| package
+% multiplies |\skip| and |\count| of |\footins| to the number of columns
+% when goes into multicolumns mode; we do the same with these parameters
+% of all another footnote inserts to provide the compatibility with
+% |multicol| package).
+%
+% \DescribeMacro{\MFL@skip}
+% This command adds the vertical space just before the
+% |\MFL@process...| command. The value of this space is also calculated
+% in |\@tempskipa|. Note that this command is inserted
+% \emph{between} vertical boxes in joining procedure. If processed box
+% is the first nonempty footnote box (|\footins| register and all
+% registers going in footins list before the processed insert are
+% empty), the command |\MFL@skip| is ignored.
+%
+% \subsection{Plain Footnote Style}
+%
+% \begin{macro}{\MFL@startplain}
+% \begin{macro}{\MFL@fnoteplain}
+% \begin{macro}{\MFL@processplain}
+% It is very simple. The commands
+% |\MFL@startplain| and |\MFL@processplain| do nothing
+% \begin{macrocode}
+\let\MFL@startplain\@gobble
+\@onlypreamble\MFL@startplain
+\let\MFL@processplain\@gobble
+% \end{macrocode}
+% and the command |\MFL@fnoteplain| does near the same as the usual
+% \@footnotetext command.
+% \begin{macrocode}
+\long\def\MFL@fnoteplain#1#2#3{\NCC@makefnmark{#2}%
+ \MFL@insert#1{\reset@font\footnotesize
+ \interlinepenalty\interfootnotelinepenalty
+ \hsize\MFL@columnwidth \@parboxrestore
+ \protected@edef\@currentlabel{\@thefnmark}%
+ \color@begingroup
+ \MFL@applyhook{#1}%
+ \@makefntext{%
+ \rule\z@\footnotesep\ignorespaces#3\@finalstrut\strutbox}%
+ \color@endgroup
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Para Footnote Style}
+%
+% \begin{macro}{\ifMFL@paraindent}
+% This style is too complicated. We load its
+% commands optionally. First we define |\ifMFL@paraindent| command to
+% switch between indented and non-indented versions of |para| footnotes.
+% \begin{macrocode}
+\newif\ifMFL@paraindent \MFL@paraindenttrue
+% \end{macrocode}
+% \end{macro}
+%
+% Now we implement the |para| option.
+% \begin{macrocode}
+\DeclareOption{para}{%
+% \end{macrocode}
+%
+% \begin{macro}{\footglue}
+% The |\footglue| skip is the horizontal space between footnotes in
+% run-in paragraph. It's name goes from \TeX book
+% (Appendix D. Dirty Tricks) and we don't rename this
+% register. This gives us an additional protection from the usage
+% this package in the document where another package also provides
+% footnotes in |para| style.
+% \begin{macrocode}
+ \newskip\footglue
+% \end{macrocode}
+% Contrarily to |footmisc| package we initialize this skip in terms of
+% the footnote size (nor the normal size).
+% \begin{macrocode}
+ {\footnotesize \global\footglue=1em plus.3em minus.3em }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SplitNote}
+% \begin{macro}{\ifMFL@split}
+% The switch |MFL@split| provides footnote splitting and
+% the command |\SplitNote| simply sets this switch to \emph{true}.
+% \begin{macrocode}
+ \newif\ifMFL@split \MFL@splitfalse
+ \newcommand\SplitNote{\MFL@splittrue}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\MFL@startpara}
+% Now we prepare |para| support routines. The first is the starting
+% routine.
+% \begin{macrocode}
+ \def\MFL@startpara#1{%
+% \end{macrocode}
+% It adds to insert's skip additional space |\MFL@paraskip| (it is
+% non-stretchable and is calculated at the beginning of the document).
+% \begin{macrocode}
+ \global\advance\skip#1\MFL@paraskip
+% \end{macrocode}
+% Then we define the command named |\MFL@split\footins|\meta{suffix}
+% which saves splitting information for the corresponding footnote
+% level. While processing the document this command will have the
+% |\MFL@applyhook|\marg{insert register} value (without splitting) or
+% |\noindent| value (with splitting).
+% \begin{macrocode}
+ \MFL@setsplit{#1}{\MFL@applyhook{#1}}%
+ }
+ \@onlypreamble\MFL@startpara
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@fnotepara}
+% The next command inserts footnote into \meta{insert register}.
+% We use Knuth's trick to inform the output procedure how many
+% horizontal space occupy the footnote by modifying its vertical size
+% as \emph{fudgefactor}${}\times{}$\emph{footnotebaselineskip} where
+% \emph{fudgefactor} is the ratio of \emph{footnotebaselineskip} to
+% |\columnwidth|. The real vertical size of such footnote is not needed
+% because the footnote is save in |\hbox| nor |\vbox| and
+% while processing to the run-in paragraph will be unboxed.
+%
+% This footnote command is not |\long| because the |\par| command cannot
+% be used in |\hbox|. At the beginning we make footnote mark and
+% set current label only if footnote mark was nonempty. We use below the
+% temporary switch |@tempswa| to select the case of nonempty footnote
+% mark.
+% \begin{macrocode}
+ \def\MFL@fnotepara#1#2#3{\let\@thefnmark\@empty
+ \NCC@makefnmark{#2}%
+ \MFL@insert#1{\reset@font\footnotesize
+ \ifx\@thefnmark\@empty \@tempswafalse \else
+ \@tempswatrue
+ \protected@edef\@currentlabel{\@thefnmark}%
+ \fi
+ \color@begingroup
+% \end{macrocode}
+% Now we test the width of the footnote mark and if\/ it less than
+% |0.8em| we calculate in |\@tempdima| the difference between |0.8em|
+% and the natural width of the marker. This horizontal space is
+% inserted before the footnote mark. Why it is needed? While the
+% processing of |para| insert we set |\parindent| to |1em|. And taking
+% into account that the marker width is at least |0.8em| we obtain the
+% distance at least |1.8em| between the footnote text and the left
+% margin. It is exactly the same distance as for footnotes in |plain|
+% style. Why we add this space using |\hskip|? It should be removed
+% when line will be broken at this point.
+% We add this space when the switch |MFL@paraindent| is true.
+% \begin{macrocode}
+ \if@tempswa
+ \setbox\@tempboxa\hbox{\@makefnmark}%
+ \ifMFL@paraindent
+ \@tempdima.8em \advance\@tempdima-\wd\@tempboxa
+ \ifdim \@tempdima<\z@ \@tempdima\z@ \fi
+ \else
+ \@tempdima\z@
+ \fi
+ \fi
+ \setbox\@tempboxa\hbox{%
+ \if@tempswa
+ \hskip\@tempdima\unhbox\@tempboxa\nobreak
+ \fi
+% \end{macrocode}
+% Well. Now we insert the footnote text into hbox and test the
+% |MFL@split| switch.
+% If it is true (splitting needed) we add at the end of text the special
+% small penalty |-1|. It will indicate us where the splitting needed.
+% In false case we set penalty |-10| and insert |\footglue| space.
+% \begin{macrocode}
+ \ignorespaces#3\unskip\strut
+ \ifMFL@split \penalty\m@ne\space \else
+ \penalty-10 \hskip\footglue
+ \fi
+ }%
+% \end{macrocode}
+% And finally we use Knuth's trick.
+% \begin{macrocode}
+ \dp\@tempboxa\z@ \ht\@tempboxa\MFL@fudgefactor\wd\@tempboxa
+ \box\@tempboxa
+ \color@endgroup
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@processpara}
+% This is the last procedure of |para| style which is called in the
+% output routine. We must reorganize the box of the \meta{insert
+% register} which is the ``vbox of hboxes".
+% \begin{macrocode}
+ \def\MFL@processpara#1{%
+% \end{macrocode}
+% Firstly we redefine |\MFL@skip| command decreasing its skip by
+% |\MFL@paraskip|.
+% \begin{macrocode}
+ \advance\@tempskipa -\MFL@paraskip
+ \edef\MFL@skip{\vskip\the\@tempskipa\relax}%
+ \setbox#1\vbox{%
+% \end{macrocode}
+% Now we execute the first step of Knuth's algorithm: convert the ``vbox
+% of hboxes" to ``hbox of hboxes".
+% \begin{macrocode}
+ \unvbox#1\setbox\@tempboxa\hbox{}\MFL@makehhbox
+% \end{macrocode}
+% The second step is unhboxing of all first level hboxes. After that we
+% have the normal hbox which can be easily converted to paragraph vbox.
+% \begin{macrocode}
+ \setbox\@tempboxa\hbox{\unhbox\@tempboxa\MFL@removehboxes}%
+% \end{macrocode}
+% Now we set all needed parameters to prepare run-in paragraph.
+% When we set a |\parindent|, we do test on the compatibility with
+% |footmisc| package. If this package is in use, the |\footnotemargin|
+% register is specified. To provide just the same indent of the first line
+% for para footnotes as for ordinary footnotes, we calculate the par indent
+% as |\footnotemargin-0.8em| (|0.8em| is the width of marker going after).
+% This calculation is executed in the only case of nonnegative
+% |\footnotemargin| value.
+% \begin{macrocode}
+ \footnotesize
+ \hsize\MFL@columnwidth \@parboxrestore
+ \ifMFL@paraindent
+ \@ifundefined{footnotemargin}%
+ {\parindent\footglue}%
+ {\parindent\footnotemargin\relax
+ \ifdim\parindent<\z@ \parindent\footglue
+ \else \advance\parindent -0.8em \fi}%
+ \fi
+% \end{macrocode}
+% Then we call |\MFL@split\footins|\meta{suffix} macro to set |\noindent|
+% if\/ it is needed (this case occurs when the footnote was splitted at
+% the previous page) or apply its hook otherwise.
+% \begin{macrocode}
+ \csname MFL@split\string#1\endcsname
+% \end{macrocode}
+% Here is the right place where |\footnotesep| rule have to be inserted.
+% \begin{macrocode}
+ \rule\z@\footnotesep
+% \end{macrocode}
+% Finally, we convert prepared hbox to vbox and test the last penalty
+% (it is
+% the penalty of the last |para| footnote inserted into this vbox). This
+% penalty is |-10| or |-1|. The case |-1| means that the last
+% footnote continues onto the next page (splitting case; see the
+% command |\MFL@fnotepara|). In this case we adjust the last line of
+% paragraph to the right margin and set |\MFL@split\footins|\meta{suffix}
+% macro to |\noindent|. Otherwise, we apply the hook as its default value.
+% \begin{macrocode}
+ \unhbox\@tempboxa\unskip
+ \ifnum\lastpenalty=\m@ne \parfillskip\z@
+ \MFL@setsplit{#1}{\noindent}%
+ \else
+ \MFL@setsplit{#1}{\MFL@applyhook{#1}}%
+ \fi
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@makehhbox}
+% This procedure converts ``vbox of hboxes" to ``hbox of hboxes".
+% Its implementation has minimal distinctions from the original code
+% described in \TeX book. We removed from it the initialization of
+% the accumulating box (|\@tempboxa|) and added a possibility some boxes
+% in the list to be vboxes nor hboxes. Such vboxes arises because
+% while processing a minipage we put all internal footnotes
+% into vbox to prevent their splitting.
+% We use the box 0 as the temporary box here.
+% \begin{macrocode}
+ \def\MFL@makehhbox{%
+ \loop\setbox\z@\lastbox \ifhbox\z@
+ \setbox\@tempboxa\hbox{\box\z@\unhbox\@tempboxa}%
+ \repeat
+ \ifvbox\z@ \unvbox\z@ \MFL@makehhbox \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@removehboxes}
+% This is an internal procedure described in \TeX book to unboxing ``hbox
+% of hboxes".
+% \begin{macrocode}
+ \def\MFL@removehboxes{\setbox\@tempboxa\lastbox
+ \ifhbox\@tempboxa{\MFL@removehboxes}\unhbox\@tempboxa\fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@setsplit}
+% This macro sets the value of |\MFL@split\footins|\meta{suffix} macro.
+% \begin{macrocode}
+ \def\MFL@setsplit#1#2{%
+ \expandafter\gdef\csname MFL@split\string#1\endcsname{#2}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% Finally, we have to prepare something for work.
+% We add to |\MFL@floathook| the calculation of the fudge factor.
+% Such a calculation is needed when we switch between one and two
+% columns by the standard \LaTeX{} commands. The original Knuth's
+% version of the algorithm produces an overflow if |\normalbaselineskip|
+% greater or equal to |16pt|. In version 1.10, the calculation
+% was improved to remove overflow. Now overflow appears when
+% |\normalbaselineskip| is |64pt|. I think it will be enough for
+% all applications. By the way, in ordinary cases the new version
+% calculates the fudge factor two times more accurate than the
+% Knuth's one.
+% \begin{macrocode}
+ \g@addto@macro\MFL@floathook{%
+ \begingroup
+ \footnotesize \@tempdima\normalbaselineskip
+ \multiply \@tempdima \@cclvi
+ \@tempdimb \columnwidth
+ \divide \@tempdimb \@cclvi
+ \divide \@tempdima \@tempdimb
+ \xdef\MFL@fudgefactor{\strip@pt\@tempdima}%
+ \endgroup
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\MFL@paraskip}
+% The last trick is the calculation of |\MFL@paraskip|~--- the skip
+% which has to be added to the skip of all |para| style footnote
+% inserts and then ``turned back" while preparing of run-in paragraph.
+% Why it is needed? Two reasons. The first, the
+% value of |\footnotesep| may be larger than the height of |\strut|.
+% And we nowhere take into account this exceeding. The second, the
+% total height of |para| footnotes is less then the real height of
+% the prepared run-in paragraph by |0.5\baselineskip| on the average.
+% So we have to add it to the |\skip| register for the compensation.
+%
+% \begin{macro}{\ExtraParaSkip}
+% I new command, |\ExtraParaSkip|\marg{space}, is introduced here
+% by the proposal of Uwe L\"uck |<ednotes.sty@web.de>|. Using it,
+% everyone can adjust a value of skip to be added to all |\skip|
+% registers of para-inserts.
+% \begin{macrocode}
+ \newcommand*\ExtraParaSkip[1]{%
+ \def\MFL@xparaskip{\advance\@tempdima#1\relax}%
+ }
+ \let\MFL@xparaskip\relax
+ \@onlypreamble\ExtraParaSkip
+ \@onlypreamble\MFL@xparaskip
+% \end{macrocode}
+% \end{macro}
+%
+% We do calculations of the |\MFL@paraskip| at the beginning of
+% the document.
+% \begin{macrocode}
+ \AtBeginDocument{%
+ \begingroup
+ \footnotesize
+ \@tempdima\footnotesep
+ \advance\@tempdima -\ht\strutbox
+ \ifdim\@tempdima<\z@ \@tempdima\z@ \fi
+ \advance\@tempdima.5\normalbaselineskip
+ \MFL@xparaskip % Add extra para skip
+ \xdef\MFL@paraskip{\the\@tempdima\relax}%
+ \endgroup
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Finally, we implement |para*| option which suppresses indentation of
+% |para| footnotes.
+% \begin{macrocode}
+\DeclareOption{para*}{%
+ \@ifundefined{MFL@startpara}{\ExecuteOptions{para}}{}%
+ \MFL@paraindentfalse
+}
+% \end{macrocode}
+%
+% \subsection{Perpage Option}
+%
+% The |perpage| option just sets the true value for the |MFL@perpage|:
+% \begin{macrocode}
+\newif\ifMFL@perpage \MFL@perpagefalse
+\DeclareOption{perpage}{\MFL@perpagetrue}
+% \end{macrocode}
+% Now we can process the package options:
+% \begin{macrocode}
+\ProcessOptions\relax
+% \end{macrocode}
+% After that, we test the |MFL@perpage| and load the |perpage| package
+% on demand:
+% \begin{macrocode}
+\ifMFL@perpage \RequirePackage{perpage}\fi
+% \end{macrocode}
+%
+% \subsection{Additional Footnotes Support}
+%
+% \begin{macro}{\MFL@list}
+% We initialize the list of all additional footnote levels to be empty.
+% \begin{macrocode}
+\def\MFL@list{}
+% \end{macrocode}
+% Its items will have the form |\@elt|\marg{style}\meta{insert register}
+% \end{macro}
+%
+% \begin{macro}{\SelectFootnoteRule}
+% Next we implement the footnote rule selection command.
+% It defines the |\MFL@rule| command that is later used in the
+% |\MFL@newinsert| command to specify accompany footnote level rule.
+% \begin{macrocode}
+\newcommand*{\SelectFootnoteRule}[2][0]{%
+ \edef\@tempa{\noexpand\MFL@selectrule{#1}{%
+ \expandafter\noexpand\csname #2footnoterule\endcsname}}%
+ \@ifnextchar[{\@tempa}{\@tempa[]}%
+}
+\def\MFL@selectrule#1#2[#3]{\def\MFL@rule{\MFL@joinrule{#1}{#2}{#3}}}
+\SelectFootnoteRule{extra}% Set the default footnote rule
+\@onlypreamble\SelectFootnoteRule
+\@onlypreamble\MFL@selectrule
+\@onlypreamble\MFL@rule
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SetFootnoteHook}
+% |\SetFootnoteHook|\marg{hook} saves a hook in the internal command.
+% When a new footnote is created, this hook is applied to it.
+% \begin{macrocode}
+\newcommand{\SetFootnoteHook}[1]{\def\MFL@footnotehook{\MFL@fhook{#1}}}
+\@onlypreamble\SetFootnoteHook
+\@onlypreamble\MFL@footnotehook
+\SetFootnoteHook{}% Empty hook by default
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@fhook}
+% |\MFL@fhook|\marg{hook}\marg{insert register} associates a hook with
+% the given insert register and resets the current hook.
+% \begin{macrocode}
+\long\def\MFL@fhook#1#2{%
+ \expandafter\def\csname MFL@hook\string#2\endcsname{#1}%
+ \SetFootnoteHook{}%
+}
+\@onlypreamble\MFL@fhook
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newfootnote}
+% Then we implement the basic command which generates additional
+% footnote levels.
+% \begin{macrocode}
+\newcommand*{\newfootnote}[2][plain]{%
+% \end{macrocode}
+% Firstly, we test the \meta{style} to be valid.
+% \begin{macrocode}
+ \@ifundefined{MFL@fnote#1}{%
+ \PackageError{manyfoot}{Unknown footnote style #1}%
+ {Known styles are `plain' and `para'\MessageBreak
+ (if the package was loaded with the para or para* option)}}{}%
+% \end{macrocode}
+% Then we allocate and initialize a new insert
+% \begin{macrocode}
+ \expandafter\MFL@newinsert\csname footins#2\endcsname
+% \end{macrocode}
+% generate |\Footnotetext|\meta{suffix} and its hook
+% \begin{macrocode}
+ \edef\@tempa{\noexpand\newcommand
+ \expandafter\noexpand\csname Footnotetext#2\endcsname
+ {\expandafter\noexpand\csname MFL@fnote#1\endcsname{%
+ \expandafter\noexpand\csname footins#2\endcsname}}%
+ \noexpand\MFL@footnotehook{%
+ \expandafter\noexpand\csname footins#2\endcsname}%
+ }%
+ \@tempa
+% \end{macrocode}
+% and finally add the description of this insert to the list of
+% additional footnote inserts.
+% \begin{macrocode}
+ \@cons\MFL@list{{#1}\csname footins#2\endcsname}%
+}
+\@onlypreamble\newfootnote
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@newinsert}
+% The initialization of a new insert. A current rule selection command
+% is linked with the new insert by the insert count number.
+% \begin{macrocode}
+\def\MFL@newinsert#1{\newinsert#1%
+ \expandafter\let\csname MFL@join\number #1\endcsname \MFL@rule
+ \SelectFootnoteRule{extra}% Reset to default rule again
+ \skip#1\skip\footins \dimen#1\dimen\footins \count#1\count\footins
+}
+\@onlypreamble\MFL@newinsert
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@makemark}
+% All additional footnote mark commands with automatic numbering are based
+% on the following command:
+% \begin{quote}
+% |\MFL@makemark|\marg{counter}\marg{stepcounter}\marg{command}\oarg{number}
+% \end{quote}
+% This command tests an optional parameter and, if it exists, prepares the marker
+% using the specified number. Otherwise, it at first executes the
+% \meta{stepcounter}\marg{counter} command (it is either |\stepcounter| or |\@gobble|)
+% and then makes a mark. Finally, it executes the \meta{command} parameter.
+% Check for |multiple| footnotes added as suggested by Frank Mittelbach.
+% \begin{macrocode}
+\def\MFL@makemark#1#2#3{%
+ \FN@mf@check
+ \@ifnextchar[{\MFL@xmkmark{#1}{#3}}{#2{#1}\MFL@mkmark{#1}{#3}}%
+}
+\providecommand\FN@mf@check{}
+\def\MFL@xmkmark#1#2[#3]{%
+ \begingroup
+ \csname c@#1\endcsname #3\relax
+ \unrestored@protected@xdef\@thefnmark{\csname the#1\endcsname}%
+ \endgroup
+ #2%
+}
+\def\MFL@mkmark#1#2{\protected@xdef\@thefnmark{\csname the#1\endcsname}%
+ #2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DeclareNewFootnote}
+% Now we define the service command simplifying creation of footnotes
+% in almost all cases.
+% \begin{macrocode}
+\newcommand*{\DeclareNewFootnote}[2][plain]{%
+ \@ifnextchar[{\MFL@declare{#1}{#2}}{\MFL@declare{#1}{#2}[arabic]}%
+}
+\def\MFL@declare#1#2[#3]{%
+% \end{macrocode}
+% We start from creation a new footnote level:
+% \begin{macrocode}
+ \newfootnote[#1]{#2}%
+% \end{macrocode}
+% Now we prepare the |\@tempa| command which will create other commands
+% at the end of macro. A counter creation command is prepared at first:
+% \begin{macrocode}
+ \edef\@tempa{\noexpand\newcounter{footnote#2}%
+% \end{macrocode}
+% After that we prepare the redefinition of the enumeration style
+% \begin{macrocode}
+ \noexpand\renewcommand
+ \expandafter\noexpand\csname thefootnote#2\endcsname{%
+ \expandafter\noexpand\csname @#3\endcsname
+ \expandafter\noexpand\csname c@footnote#2\endcsname
+ }%
+% \end{macrocode}
+% and specify the per-page resetting if necessary:
+% \begin{macrocode}
+ \ifMFL@perpage \noexpand\MakePerPage{footnote#2}\fi
+% \end{macrocode}
+% Next we prepare the |\footnote|\meta{suffix} command:
+% \begin{macrocode}
+ \noexpand\newcommand
+ \expandafter\noexpand\csname footnote#2\endcsname{%
+ \noexpand\MFL@makemark{footnote#2}{\noexpand\stepcounter}{%
+ \noexpand\@footnotemark
+ \noexpand\let\noexpand\@tempb\noexpand\@thefnmark
+ \expandafter\noexpand\csname Footnotetext#2\endcsname{%
+ \noexpand\@tempb
+ }%
+ }%
+ }%
+% \end{macrocode}
+% After that we prepare the |\footnotemark|\meta{suffix} command:
+% \begin{macrocode}
+ \noexpand\newcommand
+ \expandafter\noexpand\csname footnotemark#2\endcsname{%
+ \noexpand\MFL@makemark{footnote#2}{\noexpand\stepcounter}{%
+ \noexpand\@footnotemark
+ }%
+ }%
+% \end{macrocode}
+% Then we prepare the |\footnotetext|\meta{suffix} command:
+% \begin{macrocode}
+ \noexpand\newcommand
+ \expandafter\noexpand\csname footnotetext#2\endcsname{%
+ \noexpand\MFL@makemark{footnote#2}{\noexpand\@gobble}{%
+ \noexpand\let\noexpand\@tempb\noexpand\@thefnmark
+ \expandafter\noexpand\csname Footnotetext#2\endcsname{%
+ \noexpand\@tempb
+ }%
+ }%
+ }%
+% \end{macrocode}
+% Finally, we provide suffixed equivalents for |\Footnotemark|
+% and |\Footnote| commands:
+% \begin{macrocode}
+ \noexpand\newcommand
+ \expandafter\noexpand\csname Footnotemark#2\endcsname{%
+ \noexpand\Footnotemark
+ }%
+ \noexpand\newcommand
+ \expandafter\noexpand\csname Footnote#2\endcsname[1]{%
+ \noexpand\Footnotemark{####1}%
+ \expandafter\noexpand\csname Footnotetext#2\endcsname{####1}%
+ }%
+ }%
+% \end{macrocode}
+% And now all prepared commands are created:
+% \begin{macrocode}
+ \@tempa
+}
+\@onlypreamble\DeclareNewFootnote
+\@onlypreamble\MFL@declare
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@start}
+% This command executes the |\MFL@start|\meta{suffix} command.
+% It works at the preamble of the document only once for every
+% additional footnote level.
+% \begin{macrocode}
+\def\MFL@start#1{\csname MFL@start#1\endcsname}
+\@onlypreamble\MFL@start
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{The Basic Implementation Part}
+%
+% Now we have to build into \LaTeXe{} the support for additional
+% footnote levels. There are a number of points where the modifications
+% should be done. We do all real modifications at the beginning of the
+% document. Here we prepare macros needed.
+%
+% \subsubsection{Modifications of Output Routine}
+%
+% \begin{macro}{\MFL@joinnotes}
+% First point of modifications is the output routine. We choose the
+% strategy of joining of the additional footnotes with |\footins|
+% at the points where it is really needed. The procedure
+% |\MFL@joinnotes| implements this job. It will be added later to the
+% beginning of |\@makecol| and |\@doclearpage| macros.\footnote{The
+% version 1.2 of this package added this procedure to the beginning of
+% \texttt{\bslash @specialoutput} instead of \texttt{\bslash
+% @doclearpage}. It was incorrect because
+% the special output routine is often called to add the next float to
+% the output page without ejecting it. As a result the additional
+% footnotes disappeared before floats. Thanks to Fran\c cois Patte who
+% found this bug.}
+%
+% Since version 1.5, the |\MFL@joinnotes| has a parameter~---
+% a command the joining procedure is called before. We add a protection
+% from double attempt for joining and restore the |\footnoterule| after
+% execution of the parameter command. The |MFL@joined| conditional command
+% is used for this purpose. Another improvement is concerned with the
+% footnote rule customization procedure introduced. We now manage
+% the footnote rule to be inserted before levels using the priorities.
+% The default priority for the standard |\footnoterule| is defined
+% with the |\footnoterulepriority| command.
+% \begin{macrocode}
+\newcommand{\footnoterulepriority}{1}
+\newif\ifMFL@joined \MFL@joinedfalse
+\def\MFL@joinnotes#1{%
+ \ifMFL@joined #1%
+ \else
+ \let\MFL@savedrule \footnoterule
+% \end{macrocode}
+% After saving a footnote rule we test the standard footnote insert,
+% and prepare the current footnote rule for additional levels.
+% \begin{macrocode}
+ \let\MFL@currule \defaultfootnoterule
+ \ifvoid \footins
+ \let\MFL@curpriority \footnoterulepriority
+ \else
+ \let\MFL@curpriority \m@ne
+ \fi
+% \end{macrocode}
+% Now we join inserts.
+% \begin{macrocode}
+ \let\MFL@elt\@elt
+ \let\@elt\MFL@join \MFL@list
+ \let\@elt\MFL@elt
+% \end{macrocode}
+% And finally, we process the parameter command and restore the |\footnoterule|.
+% \begin{macrocode}
+ \MFL@joinedtrue #1\MFL@joinedfalse
+ \let\footnoterule \MFL@savedrule
+ \fi
+}
+% \end{macrocode}
+% The insert joining procedure simply calls the numbered join command
+% linked with the insert.
+% \begin{macrocode}
+\def\MFL@join#1#2{\csname MFL@join\number #2\endcsname{#1}{#2}}
+% \end{macrocode}
+% The last one calls the |\MFL@joinrule| command with 5 parameters:
+% \begin{quote}
+% |\MFL@joinrule|\marg{priority}\marg{rule}\marg{action}\marg{style}\marg{register}
+% \end{quote}
+% First we select the rule comparing the priority of current rule and
+% the new one.
+% \begin{macrocode}
+\def\MFL@joinrule#1#2#3#4#5{%
+ \ifnum #1<\MFL@curpriority \else
+ \let\MFL@currule#2%
+ \def\MFL@curpriority{#1}%
+ \fi
+ \ifvoid#5\else
+% \end{macrocode}
+% Well. The current insert is nonempty. At first, we calculate the skip
+% of insert. Within |multicols| environment it has the size multiplied
+% in |\col@number| times matching to its natural size. Therefore, we
+% have to divide it by |\col@number| in such a case.
+% \begin{macrocode}
+ \@tempskipa\skip#5%
+ \MFL@ifmcol{\divide\@tempskipa\col@number}{}%
+ \edef\MFL@skip{\vskip\the\@tempskipa\relax}%
+% \end{macrocode}
+% Now we process the current insert by the style processing driver
+% \begin{macrocode}
+ \csname MFL@process#4\endcsname #5%
+% \end{macrocode}
+% and finally we join it with |\footins| insert and decrease the
+% current priority to |-1|.
+% \begin{macrocode}
+ \ifvoid\footins
+ \let\footnoterule\MFL@currule
+ \setbox\footins\vbox{#3\unvbox#5}%
+ \else
+ \setbox\footins\vbox{%
+ \unvbox\footins\MFL@skip\MFL@currule#3\unvbox#5%
+ }%
+ \fi
+ \let\MFL@curpriority \m@ne
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@reinsout}
+% When the special output is called to process float insertion, all
+% accumulated footnotes should be reinserted after the output box.
+% This job carries out |\@reinserts| command. We will add to it
+% the reinsertion of all additional footnotes with the help of
+% |\MFL@reinsout| macro. Note that |\@reinserts| command is called at
+% two points: when the float is the marginal note
+% (|\count\@currbox|~=~0) or when it is the real float. At the second
+% case we must take into account the height of all additional footnotes
+% by adding it to the |\@pageht| value.
+% \begin{macrocode}
+\def\MFL@reinsout#1#2{\ifvoid#2\else
+ \ifnum\count\@currbox>\z@
+ \advance\@pageht \ht#2%
+ \advance\@pageht \skip#2%
+ \advance\@pageht \dp#2%
+ \fi
+ \insert#2{\unvbox#2}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Minipages Support}
+%
+% \begin{macro}{\MFL@reinsert}
+% The command reinserts all additional footins by adding if\/
+% necessary the empty insertion (such a way is used in |multicol|).
+% It is used in |minipage| and |multicols| environments.
+% The point of using it at a minipage is the beginning of the minipage.
+% Using this command we release the additional footnote boxes to
+% accumulate footnotes inside the minipage.
+% \begin{macrocode}
+\def\MFL@reinsert{{\let\@elt\MFL@reins \MFL@list}}
+\def\MFL@reins#1#2{\ifvoid#2\else\insert#2{}\fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@mpinsert}
+% Here we define the minipage insertion command which manually adds
+% vbox to the insertion box. The last footnote within minipage can
+% split. So, we specially enclose it into vbox and unvbox the
+% previous last footnote.
+% \begin{macrocode}
+\long\def\MFL@mpinsert#1#2{%
+ \global\setbox#1\vbox{%
+ \unvbox#1\setbox\@tempboxa\lastbox
+ \ifvbox\@tempboxa \unvbox\@tempboxa \fi
+ \vbox{#2}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@mpreinsert}
+% This macro is useful when we really insert footnotes at the end of the
+% minipage. We suppress splitting of all minipage insertions except
+% the last one. To do this we extract the last box from the insertion
+% box, then put another footnotes into the insert enclosing them into
+% vbox, and then put the last unvboxed footnote.
+% \begin{macrocode}
+\def\MFL@mpreinsert#1#2{%
+ \ifvoid#2\else
+ \setbox\@tempboxa\vbox{\unvbox#2\global\setbox#2\lastbox}%
+ \setbox\z@\box#2%
+ \ifdim\ht\@tempboxa>\z@ \MFL@realinsert#2{\box\@tempboxa}\fi
+ \MFL@realinsert#2{\unvbox\z@}%
+ \fi
+}
+% \end{macrocode}
+% Then we define two hooks which will be added to the beginning and to
+% the end of a minipage. We do them in not inner mode only (for
+% the first level minipages).
+% \end{macro}
+%
+% \begin{macro}{\MFL@minipage}
+% We release all box registers of the additional inserts at the
+% beginning of\/ minipage to use
+% them inside the minipage to accumulate inner inserts.
+% \begin{macrocode}
+\def\MFL@minipage{%
+ \ifinner\else
+ \MFL@reinsert \let\MFL@insert\MFL@mpinsert
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@endminipage}
+% We simply reinsert all footnotes at the end of the first level
+% minipage.
+% \begin{macrocode}
+\def\MFL@endminipage{%
+ \ifinner\else
+ {\let\@elt\MFL@mpreinsert \MFL@list}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Multicol Package Support}
+%
+% \begin{macro}{\MFL@mult}
+% The command modifies parameters of the insert register.
+% It is useful in the scope of |multicol| package only.
+% \begin{macrocode}
+\def\MFL@mult#1#2{%
+ \multiply\count#2\col@number
+ \multiply\skip#2\col@number
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MFL@ifmcol}
+% The next macro tests the multicolumn mode. There are two
+% conditions which have to be satisfied if we are in the multicolumn
+% mode: the value of |\col@number| should be greater then 1 and the
+% value of |\footins| count should be at least 2000.
+% \begin{macrocode}
+\def\MFL@ifmcol#1#2{\@tempswafalse
+ \ifnum\col@number>\@ne
+ \ifnum\count\footins>1999 \@tempswatrue \fi
+ \fi
+ \if@tempswa #1\else #2\fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{What Do We Do at the Beginning of Document?}
+%
+% \begin{macrocode}
+\AtBeginDocument{%
+% \end{macrocode}
+% Firstly, we process starting commands for every level
+% \begin{macrocode}
+ {\let\@elt\MFL@start \MFL@list}
+% \end{macrocode}
+% Then we define the |\defaultfootnoterule| to provide compatibility
+% with \textbf{footmisc}. We set it equal to |\pagefootnoterule|
+% or |\footnoterule|.
+% \begin{macrocode}
+ \@ifundefined{defaultfootnoterule}{%
+ \@ifundefined{pagefootnoterule}%
+ {\let\defaultfootnoterule\footnoterule}%
+ {\let\defaultfootnoterule\pagefootnoterule}%
+ }{}%
+% \end{macrocode}
+% Then we modify |\@doclearpage| and |\@makecol| commands by added
+% the joining algorithm at their beginning.
+% \begin{macrocode}
+ \let\MFL@doclearpage\@doclearpage
+ \def\@doclearpage{\MFL@joinnotes\MFL@doclearpage}
+ \let\MFL@makecol\@makecol
+ \def\@makecol{\MFL@joinnotes\MFL@makecol}
+% \end{macrocode}
+% Then we modify |\@reinserts| command of the output routine to
+% process reinsertion of all additional footnotes.
+% \begin{macrocode}
+ \g@addto@macro\@reinserts{%
+ \let\MFL@elt\@elt
+ \let\@elt\MFL@reinsout \MFL@list
+ \let\@elt\MFL@elt
+ }
+% \end{macrocode}
+% Then we execute |\MFL@floathook| and add it into |\@floatplacement|
+% command which is called when the column mode is
+% changed. One important note: in the multicolumn mode of |multicol|
+% package the width of footnotes is unchanged. So, we test
+% this case by the command |\MFL@ifmcol|.
+% \begin{macrocode}
+ \MFL@floathook
+ \g@addto@macro\@floatplacement{\MFL@ifmcol{}{\MFL@floathook}}
+% \end{macrocode}
+%
+% The next is the |minipage| environment. We modify |\@iiiminipage| and
+% |\endminipage| adding to them hooks describe earlier.
+% \begin{macrocode}
+ \let\MFL@iminipage\@iiiminipage
+ \def\@iiiminipage{\MFL@minipage\MFL@iminipage}
+ \g@addto@macro\endminipage\MFL@endminipage
+% \end{macrocode}
+%
+% Finally, we do some tricks to provide the compatibility with
+% |multicol| package. If this package is loaded, the command
+% |\multi@column@out| should be defined
+% \begin{macrocode}
+ \@ifundefined{multi@column@out}
+% \end{macrocode}
+% If it is undefined, the |multicol| specific commands are not useful.
+% So, we delete |\MFL@mult| command and modify |\MFL@ifmcol| command to
+% choose the second case every time.
+% \begin{macrocode}
+ {\@onlypreamble\MFL@mult \let\MFL@ifmcol\@secondoftwo}
+% \end{macrocode}
+% If |multicol| package presents, we add the joining algorithm to the
+% beginning of |\multi@column@out| command
+% \begin{macrocode}
+ {\let\MFL@mcolout\multi@column@out
+ \def\multi@column@out{\MFL@joinnotes\MFL@mcolout}
+% \end{macrocode}
+% and add the multiplication of additional footins parameters
+% by the number of columns to the end of |\init@mult@footins| command.
+% We can't do this globally. So, we save the previous value of |\@elt|
+% command and then restore it after the calculation.
+% We also modify |\reinsert@footnotes| command.
+% \begin{macrocode}
+ \g@addto@macro\init@mult@footins{%
+ \let\MFL@elt\@elt
+ \let\@elt\MFL@mult \MFL@list
+ \let\@elt\MFL@elt
+ }
+ \g@addto@macro\reinsert@footnotes{\MFL@reinsert}
+ }
+}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/mboxfill.dtx b/Master/texmf-dist/source/latex/ncctools/mboxfill.dtx
new file mode 100644
index 00000000000..1a4793b38d8
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/mboxfill.dtx
@@ -0,0 +1,130 @@
+% \iffalse
+%%
+%% File: mboxfill.dtx Copyright (C) 2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{mboxfill}
+%<package> [2005/05/13 v1.0 Fill space with mbox (NCC)]
+%
+% \changes{v1.0}{2005/05/13}{This version was uploaded to CTAN}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{mboxfill}
+\GetFileInfo{mboxfill.sty}
+\begin{document}
+\title{The \textsf{mboxfill} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{mboxfill.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \section{User Interface}
+%
+% \DescribeMacro\mboxfill
+% This package implements the command
+% \begin{quote}
+% |\mboxfill|\oarg{width}\oarg{leader-type}\marg{pattern}
+% \end{quote}
+% filling a free horizontal space with \meta{pattern}.
+%
+% The \meta{width} parameter specifies a width of box pattern
+% to be used as leaders. If it is omitted, the pattern width is used.
+% The |\width|, |\height|, |\depth|,
+% and |\totalheight| macros can be used in this parameter.
+% Length expressions are also allowed if the \textsf{calc}
+% package is loaded.
+%
+% The \meta{leader-type} parameter specifies a type of leaders
+% to be used: |c| means |\cleaders|, |x| means |\xleaders|, and
+% empty value (default) means |\leaders|. Depending on type, an
+% extra space is distributed between fill entries as follows:
+% in |c| case, fill entries are centered, in |x| case, fill entries
+% are uniformly distributed, and in other cases, fill entries are
+% aligned to the multiple of their width counted from the
+% left boundary of filled box.
+%
+% When the specified \meta{width} differs from the pattern
+% width, the pattern is centered inside the box to fill with.
+% As a consequence, when |x|-leaders are used, a bit of space
+% will be left from both sides of fill area. To remove this
+% space, use the special value of \meta{leader-type} parameter,
+% namely |s|.
+%
+% Example:
+% \begin{quote}
+% |\noindent\mboxfill{*}\mbox{}\\|\\
+% |\mbox{}\mboxfill[2\width]{+}\mbox{}\\|\\
+% |\mbox{}\mboxfill[2\width]{\hfill+}\mbox{}\\|\\
+% |\mbox{}\mboxfill[2\width]{+\hfill}\mbox{}\\|\\
+% |A text\mboxfill[1.5\width]{*}\mbox{}\\|\\
+% |\mbox{}\mboxfill[1.5\width]{*}\mbox{}\\|\\
+% |\mbox{}\mboxfill[1.5\width][c]{*}\mbox{}\\|\\
+% |\mbox{}\mboxfill[1.5\width][x]{*}\mbox{}\\|\\
+% |\mbox{}\mboxfill[1.5\width][s]{*}\mbox{}\\[-2ex]|\\
+% |\mbox{}\hrulefill|
+% \end{quote}
+% It produces the following:
+%
+% \noindent\mboxfill{*}\mbox{}\\
+% \mbox{}\mboxfill[2\width]{+}\mbox{}\\
+% \mbox{}\mboxfill[2\width]{\hfill+}\mbox{}\\
+% \mbox{}\mboxfill[2\width]{+\hfill}\mbox{}\\
+% A text\mboxfill[1.5\width]{*}\mbox{}\\
+% \mbox{}\mboxfill[1.5\width]{*}\mbox{}\\
+% \mbox{}\mboxfill[1.5\width][c]{*}\mbox{}\\
+% \mbox{}\mboxfill[1.5\width][x]{*}\mbox{}\\
+% \mbox{}\mboxfill[1.5\width][s]{*}\mbox{}\\[-2ex]
+% \mbox{}\hrulefill
+%
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% \begin{macrocode}
+%<*package>
+\newcommand*\mboxfill[1][\width]{%
+ \def\@tempa{\setlength\@tempdima{#1}}%
+ \@ifnextchar[{\NCC@mboxfill}{\NCC@mboxfill[]}%
+}
+\def\NCC@mboxfill[#1]#2{%
+ \@begin@tempboxa\hbox{#2}%
+% \end{macrocode}
+% Set the required box width in |\@tempdima|:
+% \begin{macrocode}
+ \@tempa
+% \end{macrocode}
+% Test the case of |s|-leaders. They work like |x|-leaders,
+% but a special kern is added to both sides of the fill area
+% to compensate extra-space added in the box.
+% \begin{macrocode}
+ \edef\@tempa{#1}\def\@tempb{s}%
+ \ifx\@tempa\@tempb
+ \@tempdimb\width
+ \advance\@tempdimb -\@tempdima
+ \let\@tempa\xleaders
+ \def\@tempb{\kern.5\@tempdimb}%
+ \else
+% \end{macrocode}
+% Other cases: if leader-type is incorrect, we use |\leaders|.
+% \begin{macrocode}
+ \@ifundefined{#1leaders}{\let\@tempa\leaders}%
+ {\def\@tempa{\csname#1leaders\endcsname}}%
+ \let\@tempb\@empty
+ \fi
+% \end{macrocode}
+% |\@tempa| contains required leaders, |\@tempb| is a kern or empty.
+% Fill the space.
+% \begin{macrocode}
+ \leavevmode\@tempb\@tempa
+ \hb@xt@\@tempdima{\hss\unhbox\@tempboxa\hss}\hfill\@tempb
+ \@end@tempboxa
+}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccbbb.dtx b/Master/texmf-dist/source/latex/ncctools/nccbbb.dtx
new file mode 100644
index 00000000000..6f470c3cfd0
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccbbb.dtx
@@ -0,0 +1,93 @@
+% \iffalse
+%%
+%% File: nccbbb.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{nccbbb}
+%<package> [2004/11/24 v1.1 Pure Black Board Bold (NCC)]
+%
+% \changes{v1.0}{2002/01/31}{This version was uploaded to CTAN}
+% \changes{v1.1}{2004/11/24}{Bug in |\bbbz| command fixed}
+% \changes{v1.1}{2004/11/24}{Documentation was prepared}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nccbbb}
+\GetFileInfo{nccbbb.sty}
+\begin{document}
+\title{The \textsf{nccbbb} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccbbb.dtx}
+\end{document}
+%</driver>
+% \fi
+% \section{User Interface}
+%
+% \DescribeMacro{\bbb...}
+% The package implements the following poor black board bold math symbols:
+% \begin{center}
+% \begin{tabular}{l@{\qquad}c@{\qquad\vrule\qquad}l@{\qquad}c}
+% Command & Symbol & Command & Symbol\\
+% |\bbbb| & $\bbbb$ & |\bbbm| & $\bbbm$ \\
+% |\bbbc| & $\bbbc$ & |\bbbn| & $\bbbn$ \\
+% |\bbbd| & $\bbbd$ & |\bbbo| & $\bbbo$ \\
+% |\bbbe| & $\bbbe$ & |\bbbp| & $\bbbp$ \\
+% |\bbbf| & $\bbbf$ & |\bbbq| & $\bbbq$ \\
+% |\bbbg| & $\bbbg$ & |\bbbr| & $\bbbr$ \\
+% |\bbbh| & $\bbbh$ & |\bbbs| & $\bbbs$ \\
+% |\bbbi| & $\bbbi$ & |\bbbz| & $\bbbz$ \\
+% |\bbbk| & $\bbbk$ & |\bbbzero| & $\bbbzero$ \\
+% |\bbbl| & $\bbbl$ & |\bbbone| & $\bbbone$ \\
+% \end{tabular}
+% \end{center}
+% It was designed to provide the compatibility with old macros of NCC-\LaTeX.
+% We recommend use the |\mathbb| command from the |amsfonts| package
+% instead.
+% \StopEventually{}
+%
+% \section{The Implementation}
+% Declare commands of the user interface:
+% \begin{macrocode}
+%<*package>
+\newcommand\bbbb{\NCC@bbb{B}}
+\newcommand\bbbc{{\NCC@bbbz{C{\NCC@bbbr{.03}{.35}{.9}{.1}}}}}
+\newcommand\bbbd{\NCC@bbb{D}}
+\newcommand\bbbe{\NCC@bbb{E}}
+\newcommand\bbbf{\NCC@bbb{F}}
+\newcommand\bbbg{{\NCC@bbbz{G{\NCC@bbbr{.05}{.3}{.88}{.09}}}}}
+\newcommand\bbbh{\NCC@bbb{H}}
+\newcommand\bbbi{\NCC@bbb{I}}
+\newcommand\bbbk{\NCC@bbb{K}}
+\newcommand\bbbl{\NCC@bbb{L}}
+\newcommand\bbbm{\NCC@bbbi{M}}
+\newcommand\bbbn{\NCC@bbbi{N}}
+\newcommand\bbbo{{\NCC@bbbz{O{\NCC@bbbr{.05}{.3}{.9}{.09}}}}}
+\newcommand\bbbp{\NCC@bbb{P}}
+\newcommand\bbbq{{\NCC@bbbz{Q{\NCC@bbbr{.05}{.3}{.9}{.09}}}}}
+\newcommand\bbbr{\NCC@bbb{R}}
+\newcommand\bbbs{{\NCC@bbbz{S{\NCC@bbbr{.5}{.3}{.45}{.07}%
+ \NCC@bbbr{0}{.55}{.5}{.07}}}}}
+\newcommand\bbbz{{\NCC@bbbz{{\mathsf Z}{\@tempdima\wd\z@\wd\z@ 0.33\@tempdima}}%
+ \mathsf Z}}
+\newcommand\bbbzero{{\NCC@bbbz{O{\NCC@bbbr{.05}{.3}{.9}{.06}%
+ \NCC@bbbr{.05}{.6}{.9}{.06}}}}}
+\newcommand\bbbone{\mathrm{1\NCC@bbbz{l{\kern -0.88\wd\z@}}}}
+% \end{macrocode}
+%
+% Define base commands:
+% \begin{macrocode}
+\def\NCC@bbb#1{\mathrm{I\mskip -3.5mu#1}}
+\def\NCC@bbbi#1{\mathrm{I\NCC@bbbz{{\mskip -3.5mu I}{\wd\z@\z@}}%
+ \mskip -3mu#1}}
+\def\NCC@bbbz{\mathpalette\NCC@bbbz@}
+\def\NCC@bbbz@#1#2{\NCC@bbbz@@{#1}#2}
+\def\NCC@bbbz@@#1#2#3{\setbox\z@\hbox{$\m@th#1{\mathrm{#2}}$}#3\box\z@}
+\def\NCC@bbbr#1#2#3#4{\raise #1\ht\z@\hbox to \z@{\kern #2\wd\z@
+ \vrule \@height #3\ht\z@ \@width #4\wd\z@\hss}}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccboxes.dtx b/Master/texmf-dist/source/latex/ncctools/nccboxes.dtx
new file mode 100644
index 00000000000..f0a761fd3d6
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccboxes.dtx
@@ -0,0 +1,427 @@
+% \iffalse
+%%
+%% File: nccboxes.dtx Copyright (C) 2002--2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{nccboxes}
+%<package> [2005/02/07 v1.2 Additional Boxes (NCC)]
+%
+% \changes{v1.03}{2002/01/29}{This version is uploaded to CTAN}
+% \changes{v1.04}{2002/03/20}{Internal changes in |\jvbox|}
+% \changes{v1.04}{2002/03/20}{The |\jparbox| command introduced}
+% \changes{v1.05}{2002/05/24}{Bug in |\jparbox| (incorrect width) fixed}
+% \changes{v1.1}{2004/11/28}{Documentation was prepared}
+% \changes{v1.2}{2005/02/07}{Add |\tc| command}
+% \changes{v1.2}{2005/02/07}{Allow lengthes in the Strut parameter}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nccboxes}
+\GetFileInfo{nccboxes.sty}
+\begin{document}
+\title{The \textsf{nccboxes} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccboxes.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% The package implement special boxes and struts from NCC-\LaTeX.
+%
+% \section{User Interface}
+%
+% \DescribeMacro{\jhbox}
+% This macro specifies a horizontal box whose width is calculate
+% using a prototype and alignment position is specified in the same manner
+% as in the |\makebox| command. The syntax:
+% \begin{quote}
+% |\jhbox|\marg{prototype}\oarg{pos}\marg{text}
+% \end{quote}
+% Here \meta{prototype} is a text whose width will be the width of generated
+% box, \meta{pos} is an alignment parameter (|l|, |c|, |r|, or |s|;
+% default is |c|).
+%
+% \DescribeMacro{\jvbox}
+% This macro specifies a horizontal box whose height, depth, and vertical
+% alignment is calculated using a prototype. The syntax:
+% \begin{quote}
+% |\jvbox|\marg{prototype}\oarg{pos}\marg{text}
+% \end{quote}
+% The \meta{text} argument is vertically aligned with respect to the
+% strut defined by the \meta{prototype} parameter. The optional
+% \meta{pos} parameter defines an alignment position
+% (|t|, |c|, or |b|; default is |c|). If |t| is used, the \meta{text} is
+% raised in such a way that its height will be equal to the height of
+% the prototype's strut. For the |b| case, the depths will be equal, and,
+% for the |c| case, the \meta{text} is vertically centered with respect to
+% the prototype's strut. The height and depth of the prepared box are
+% calculated as a maximum between the corresponding parameters of the
+% \meta{prototype} and the vertically adjusted \meta{text}.
+%
+% \DescribeMacro{\jparbox}
+% This macro prepares a paragraph box of the required width and
+% vertically aligns it with respect to the prototype just in the same manner
+% as the |\jvbox|. The syntax:
+% \begin{quote}
+% |\jparbox|\marg{prototype}\oarg{pos}\marg{width}\marg{text}
+% \end{quote}
+% The \meta{prototype} and \meta{pos} parameters have the same meaning
+% as described for |\jvbox|. The \meta{width} is the width
+% of the paragraph box and the \meta{text} is the box content.\pagebreak
+%
+% \DescribeMacro{\addbox}
+% This macro specifies a horizontal box whose height and depth are
+% adjusted using the given values. The syntax:
+% \begin{quote}
+% |\addbox|\marg{height-adjust}\marg{depth-adjust}\marg{text}
+% \end{quote}
+% For example, |\addbox{.5ex}{.5ex}{text}| increases the height
+% and depth of produced box on |0.5ex|.
+%
+% \DescribeMacro{\pbox}
+% This macro implements a simple one-column table. The syntax:
+% \begin{quote}
+% |\pbox|\oarg{pos}\marg{body}
+% \end{quote}
+% The \meta{pos} parameter may consist of two letters defining
+% a relative alignment of the table rows in the column
+% (|l|, |c|, or |r|) and the vertical alignment of the whole table
+% with respect to surrounding text (|t|, |c|, or |b|).
+% Centering is the default alignment. The distance between
+% table rows does not depend on the |\arraystretch| value.
+%
+% \DescribeMacro{\picbox}
+% The |\picbox|\marg{body} macro is equivalent to
+% \begin{quote}
+% |\begin{picture}(0,0)(0,0)|\meta{body}|\end{picture}|.
+% \end{quote}
+%
+% To prepare fancy tables, the following commands can be used:
+%
+% \DescribeMacro{\Strut}
+% \DescribeMacro{\Strutletter}
+% The |\Strut/|\meta{value}|/| command is a special strut whose
+% height and depth are calculated from the strut prototype
+% command |\Strutletter| (letter |A| by default) as follows:
+% if \meta{value} is positive, the full height of the current
+% |\strutbox| multiplied by the \meta{value} is added to the
+% height of strut prototype, otherwise the depth of strut prototype
+% increases with the modulus of \meta{value} multiplied
+% by the full height of |\strutbox|. For example,
+% |\Strut/1/| inserts a strut which height exceeds the height
+% of the letter |A| from the current font on the interline distance.
+% A natural length is also possible as a value of |\Strut|'s
+% parameter. So, the |\Strut/2mm/| means a strut with the height
+% exceeding the height of strut letter over 2~mm.
+% The |\Strut| without parameter is equal to |\Strut/0/|.
+% Spaces after the |\Strut| are ignored.
+%
+% \DescribeMacro{\tstrut}
+% \DescribeMacro{\bstrut}
+% \DescribeMacro{\tbstrut}
+% \DescribeMacro{\Strutstretch}
+% The |\tstrut|, |\bstrut|, and |\tbstrut| commands insert
+% struts exceeding the height, depth, and both height and depth
+% of the strut prototype |\Strutletter| by a special small amount.
+% This amount is calculated in such a way that the full height
+% of |\tbstrut| will be equal to 1.5 of full height of the
+% current |\strutbox|. The stretch factor 1.5 is specified in
+% the |\Strutstretch| command. These commands are used in tables
+% to insert a space between a horizontal line and a table row.
+% But if the height and depth of row contents exceeds the
+% height and depth of inserted strut, the inserted strut will
+% take no effect.
+%
+% \DescribeMacro{\cbox}
+% The |\cbox/|\meta{value}|/|\oarg{pos}\marg{body} command
+% prepares a box whose body is a one-column table. Its height and
+% depth are enlarged using |\tstrut| at the beginning and
+% |\bstrut| at the end of body. The horizontal alignment
+% (|l|, |c|, or |r|) in the column and the vertical
+% alignment (|t|, |c|, or |b|) are defined in the
+% \meta{pos} parameter. Centered alignment is used by
+% default. The resulting box is vertically aligned with
+% respect to the |\Strut/|\meta{value}|/| using the
+% |\jvbox| command. The |\cbox*| command does the same
+% but vanishes the height and depth of the resulting box.
+% The |\cbox| command is used in the headers of tables.
+% Its star form is useful in cells having vertical spans.
+%
+% \DescribeMacro{\cboxstyle}
+% The |\cboxstyle| specifies a style applied to all
+% |\cbox| commands. It can set a font size, shape, color,
+% etc. The default value of |\cboxstyle| is empty.
+%
+% We demonstrate the usage of struts and |\cbox| on the
+% following example:
+% \begin{center}\catcode`|=12
+% \renewcommand\cboxstyle{\small\bf}
+% \setlength{\tabcolsep}{10pt}
+% \begin{tabular}{|l|c|c|c|}\hline
+% \cbox*/-1.5/{Vertically\\spanned head} & \cbox{Simple head}
+% &\multicolumn2{c|}{\cbox{Very long head\\of two lines}}\\\cline{2-4}
+% &\cbox{subhead} &\cbox{subhead} &\cbox{subhead}\\\hline
+% \Strut/1/ Text & field & field & field \\
+% Text & field & field & field \\
+% \bstrut Text & field & field & field \\\hline
+% \end{tabular}
+% \end{center}
+% It was produced as follows:
+% \begin{quote}
+% |\begin{center}|\\
+% | \renewcommand\cboxstyle{\small\bf}|\\
+% | \setlength{\tabcolsep}{10pt}|\\
+% \verb+ \begin{tabular}{|l|c|c|c|}\hline+\\
+% | \cbox*/-1.5/{Vertically\\spanned head} & \cbox{Simple head}|\\
+% \verb+ &\multicolumn2{c|}{\cbox{Very long head\\of two lines}}\\+\\
+% | \cline{2-4}|\\
+% | &\cbox{subhead} &\cbox{subhead} &\cbox{subhead}\\\hline|\\
+% | \Strut/1/ Text & field & field & field \\|\\
+% | Text & field & field & field \\|\\
+% | \bstrut Text & field & field & field \\\hline|\\
+% | \end{tabular}|\\
+% |\end{center}|
+% \end{quote}
+%
+% \DescribeMacro{\tc}
+% To center a table field, the |\tc|\marg{field} command is introduced
+% since version 1.2 of the package. It inserts |\hspace*{\fill}|
+% before and after the \meta{field}.
+%
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% \begin{macro}{\addbox}
+% The implementation of
+% |\addbox|\marg{height-adjust}\marg{depth-adjust}\marg{text}.
+% We use the |\setlength| in calculations
+% of box's height and depth for compatibility with the |calc|
+% package.
+% \begin{macrocode}
+%<*package>
+\newcommand*{\addbox}[3]{%
+ \@begin@tempboxa\hbox{#3}%
+ \setlength\@tempdima{#1}%
+ \advance\@tempdima \ht\@tempboxa
+ \ht\@tempboxa \@tempdima
+ \setlength\@tempdima{#2}%
+ \advance\@tempdima \dp\@tempboxa
+ \dp\@tempboxa \@tempdima
+ \leavevmode\box\@tempboxa
+ \@end@tempboxa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\jhbox}
+% The implementation of |\jhbox|\marg{prototype}\oarg{pos}\marg{text}
+% is very simple:
+% \begin{macrocode}
+\newcommand*{\jhbox}[1]{\settowidth\@tempdima{#1}\makebox[\@tempdima]}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\jvbox}
+% The |\jvbox|\marg{prototype}\oarg{pos}\marg{text} is implemented
+% as follows. We prepare a vertical strut
+% in zero box using the \meta{prototype}. Then we vertically adjust the
+% content of the |\jvbox| and put the strut and the adjusted box.
+% \begin{macrocode}
+\newcommand*{\jvbox}[1]{%
+ \setbox\z@\hbox{\color@begingroup#1\color@endgroup}%
+ \setbox\z@\hbox{\vrule \@width\z@ \@height\ht\z@ \@depth\dp\z@}%
+ \NCC@jvbox
+}
+\newcommand*{\NCC@jvbox}[2][]{%
+ \setbox\@tempboxa\hbox{\color@begingroup#2\color@endgroup}%
+ \let\m@t\vss \let\m@b\vss
+ \@tfor\@tempa :=#1\do {%
+ \expandafter\let\csname m@\@tempa\endcsname\relax}%
+ \@tempdima\ht\z@ \advance\@tempdima -\ht\@tempboxa
+ \ifx\m@t\relax \else
+ \@tempdimb\dp\@tempboxa \advance\@tempdimb -\dp\z@
+ \ifx\m@b\relax \@tempdima \@tempdimb \else
+ \advance\@tempdimb \@tempdima \@tempdima .5\@tempdimb
+ \fi
+ \fi
+ \leavevmode \box\z@ \raise\@tempdima\box\@tempboxa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\jparbox}
+% The implementation of
+% |\jparbox|\marg{prototype}\oarg{pos}\marg{width}\marg{body}
+% is based on |\jvbox|, but we prepare the
+% \meta{body} in the vertical box.
+% \begin{macrocode}
+\newcommand*{\jparbox}[1]{%
+ \@ifnextchar[{\NCC@jparbox{#1}}{\NCC@jparbox{#1}[]}%
+}
+\long\def\NCC@jparbox#1[#2]#3#4{%
+ \@begin@tempboxa\vtop{\setlength\@tempdima{#3}%
+ \hsize\@tempdima\@parboxrestore#4\@@par}%
+ \setlength\@tempdima{#3}% vbox containing only display equations can
+ \wd\@tempboxa\@tempdima % have lesser width. We correct it here
+ \jvbox{#1}[#2]{\box\@tempboxa}%
+ \@end@tempboxa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pbox}
+% Now we implement the |\pbox|\oarg{pos}\marg{body} command.
+% It is a simple one-column table. The |\arraystretch|
+% has no effect on it. The \meta{pos} is a combination of
+% vertical (tbc) and horizontal (lcr) positions. For example,
+% |lt| means left adjusted table with first line on the base line.
+% \begin{macrocode}
+\newcommand*{\pbox}[2][]{%
+ \let\m@l\hss \let\m@r\hss \let\m@t\vss \let\m@b\vss
+ \@tfor\@tempa:=#1\do{%
+ \expandafter\let\csname m@\@tempa\endcsname\relax%
+ }%
+ \leavevmode\hbox{\color@begingroup
+ $\ifx\m@t\relax \vtop \else\ifx\m@b\relax \vbox\else \vcenter\fi\fi
+ \bgroup \baselineskip\z@\lineskip\z@
+ \def\\{\strut\@stackcr}%
+ \halign{\m@l\ignorespaces ##\unskip\m@r\cr #2\strut\crcr}%
+ \egroup$\color@endgroup
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\picbox}
+% The |\picbox|\marg{body} command:
+% \begin{macrocode}
+\newcommand*{\picbox}[1]{%
+ \setbox\@tempboxa\hb@xt@\z@{\ignorespaces#1\hss}%
+ \ht\@tempboxa\z@\dp\@tempboxa\z@
+ \leavevmode\box\@tempboxa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Strutletter}
+% \begin{macro}{\Strutstretch}
+% Here we specify macros for preparing special struts.
+% The |\Strutletter| is the prototype for special struts.
+% The |\Strutstretch| is a stretch of line height in |\cbox|
+% with respect to |\strut|. We prepare special struts in
+% the |\NCC@strutbox|. The |\NCC@strutsep| is a half
+% of difference between stretched |\strut| and the full height
+% of the |\Strutletter|.
+% \begin{macrocode}
+\newcommand{\Strutletter}{A}
+\newcommand{\Strutstretch}{1.5}
+\newsavebox\NCC@strutbox
+\newdimen\NCC@strutsep
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\NCC@setstrut}
+% The |\NCC@setstrut|\marg{command}|/|\meta{value}|/|
+% tests the sequence |/|\meta{value}|/|, prepares the specified
+% strut in the |\NCC@strutbox|, calculates the |\NCC@strutsep|,
+% and then calls the \meta{command}.
+% The |/|\meta{value}|/| sequence is optional. If it is omitted,
+% |/0/| is supposed.
+% \begin{macrocode}
+\def\NCC@setstrut#1{%
+ \setbox\NCC@strutbox\hbox{\vphantom{\Strutletter}}%
+ \@tempdima\ht\strutbox \advance\@tempdima\dp\strutbox
+ \NCC@strutsep \Strutstretch\@tempdima
+ \advance\NCC@strutsep -\ht\NCC@strutbox
+ \advance\NCC@strutsep -\dp\NCC@strutbox
+ \NCC@strutsep .5\NCC@strutsep
+ \@ifnextchar/{\NCC@setstrutn{#1}}{\NCC@setstrutl{#1}\z@}%
+}
+\def\NCC@setstrutn#1/#2/{\NCC@setstrutl{#1}{#2\@tempdima}}
+\def\NCC@setstrutl#1#2{%
+ \@defaultunits\@tempdima#2\relax\@nnil
+ \ifdim\@tempdima>\z@
+ \advance\@tempdima \ht\NCC@strutbox
+ \ht\NCC@strutbox \@tempdima
+ \else
+ \@tempdima -\@tempdima
+ \advance\@tempdima \dp\NCC@strutbox
+ \dp\NCC@strutbox \@tempdima
+ \fi
+ #1%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Strut}
+% Now we define the |\Strut/|\meta{value}|/|.
+% It is quite simple:
+% \begin{macrocode}
+\newcommand{\Strut}{%
+ \NCC@setstrut{\leavevmode\copy\NCC@strutbox\ignorespaces}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\tstrut}
+% \begin{macro}{\bstrut}
+% \begin{macro}{\tbstrut}
+% Next we define |\tstrut|, |\bstrut|, and |\tbstrut| via the |\addbox|
+% command. All these struts use the |\NCC@setstrut| to calculate
+% special strut parameters.
+% \begin{macrocode}
+\newcommand{\tstrut}{%
+ \NCC@setstrut{}\addbox\NCC@strutsep\z@{\copy\NCC@strutbox}%
+}
+\newcommand{\bstrut}{%
+ \NCC@setstrut{}\addbox\z@\NCC@strutsep{\copy\NCC@strutbox}%
+}
+\newcommand{\tbstrut}{%
+ \NCC@setstrut{}\addbox\NCC@strutsep\NCC@strutsep{\copy\NCC@strutbox}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\cbox}
+% \begin{macro}{\cboxstyle}
+% Now, we define the
+% |\cbox/|\meta{value}|/|\oarg{pos}\marg{body} command and its
+% star-form. It is useful in headers of tables. The |\cboxstyle| is
+% a styling command applied to every |\cbox|.
+% \begin{macrocode}
+\newcommand{\cboxstyle}{}
+\newcommand{\cbox}{%
+ \@ifstar{\def\@tempa{\ht\@tempboxa\z@ \dp\@tempboxa\z@}\NCC@xcbox}%
+ {\let\@tempa\relax\NCC@xcbox}%
+}
+\def\NCC@xcbox{%
+ \leavevmode \hbox\bgroup\color@begingroup
+ \cboxstyle\NCC@setstrut{\NCC@ycbox}%
+}
+\newcommand*{\NCC@ycbox}[2][]{%
+ \setbox\@tempboxa\hbox{%
+ \jvbox{\addbox\NCC@strutsep\NCC@strutsep{\copy\NCC@strutbox}}[#1]%
+ {\pbox[#1t]{\tstrut\ignorespaces #2\unskip\bstrut}}}%
+ \@tempa \box\@tempboxa
+ \color@endgroup\egroup
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\tc}
+% And finally, we define the |\tc|\marg{field} command.
+% \begin{macrocode}
+\newcommand{\tc}[1]{\hspace*{\fill}#1\hspace*{\fill}}
+%</package>
+% \end{macrocode}
+% \end{macro}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/ncccomma.dtx b/Master/texmf-dist/source/latex/ncctools/ncccomma.dtx
new file mode 100644
index 00000000000..8126358aadd
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/ncccomma.dtx
@@ -0,0 +1,100 @@
+% \iffalse
+%%
+%% File: ncccomma.dtx Copyright (C) 2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{ncccomma}
+%<package> [2005/02/10 v1.0 Smart Math Comma Package (NCC)]
+%
+% \changes{v1.0}{2005/02/10}{Initial version}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{ncccomma}
+\GetFileInfo{ncccomma.sty}
+\begin{document}
+\title{The \textsf{ncccomma} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{ncccomma.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% The package implements the smart comma in math mode.
+% Let us compare this solution with the concurrent solution from
+% the |icomma| package by Walter Schmidt:
+% \begin{itemize}
+% \item In |icomma|, a comma in math works as the
+% punctuation mark if a space goes after it. Otherwise,
+% it work as an ordinary character;
+% \item In |ncccomma|, a comma in math works as an ordinary
+% character if a decimal character goes after it.
+% Otherwise, it works as a punctuation mark.
+% \end{itemize}
+% The solution used in this package is more expansive because
+% we compare the next character with up to ten decimal chars.
+% But this solution needs less number of spaces to be inserted into
+% original document (the space is only necessary in the place
+% of a comma delimiting something and a decimal number).
+%
+% \DescribeMacro{\mathcomma}
+% The original math comma is saved in the |\mathcomma| macro.
+% This macro is useful together with the |dcolumn| package.
+% If a comma should be \emph{printed} as the
+% decimal separator in a column of type |D|, it must be specified
+% as |{\mathcomma}|, rather than |{,}|, since the latter
+% leads to an error. For example:
+% \begin{quote}
+% |\begin{tabular}{D{,}{\mathcomma}{-1}}|
+% \end{quote}
+%
+% \DescribeMacro{\ordcommalist}
+% The list of decimal characters is saved in the |\ordcommalist|.
+% It initial definition is
+% \begin{quote}
+% |\newcommand\ordcommalist{0123456789}|
+% \end{quote}
+% You can redefine it if necessary.
+%
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% We save the original comma in |\mathcomma| and then specify
+% the comma to be an active char in math.
+% \begin{macrocode}
+%<*package>
+\mathchardef\mathcomma\mathcode`\,
+\mathcode`\,="8000
+% \end{macrocode}
+% No we define the meaning of comma using the well-known trick with
+% upper case.
+% \begin{macrocode}
+\bgroup
+ \uccode`\~`\,%
+ \uppercase{%
+\egroup
+ \def~}{\futurelet\@let@token\NCC@comma}
+% \end{macrocode}
+% The smart comma compares the next char with a character of the
+% |\ordcommalist| in cycle. This cycle is a bit expansive,
+% but it is the payment for smartness.
+% \begin{macrocode}
+\newcommand\ordcommalist{0123456789}
+\def\NCC@comma{%
+ \let\@tempb\@empty
+ \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=%
+ \ordcommalist\do{%
+ \expandafter\ifx\@tempa\@let@token
+ \let\@tempb\mathord \@break@tfor
+ \fi
+ }%
+ \@tempb\mathcomma
+}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/ncccropbox.dtx b/Master/texmf-dist/source/latex/ncctools/ncccropbox.dtx
new file mode 100644
index 00000000000..d562379d492
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/ncccropbox.dtx
@@ -0,0 +1,166 @@
+% \iffalse
+%%
+%% File: ncccropbox.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{ncccropbox}
+%<package> [2004/11/24 v1.1 Crop Box Package (NCC)]
+%
+% \changes{v1.02}{2002/01/31}{This version is uploaded to CTAN}
+% \changes{v1.03}{2002/02/08}{The package is renamed to ncccropbox}
+% \changes{v1.1}{2004/11/24}{Documentation was prepared}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{ncccropbox}
+\GetFileInfo{ncccropbox.sty}
+\begin{document}
+\title{The \textsf{ncccropbox} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{ncccropbox.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \section{User Interface}
+%
+% \DescribeMacro{\cropbox}
+% The package implements the command
+% \begin{quote}
+% |\cropbox|\oarg{width}\oarg{height}\marg{content}
+% \end{quote}
+% preparing a horizontal box with crop-marks at its corners looking like angles.
+% The crop-box is aligned at the bottom and is lowered at the |\lineskip| value.
+% The optional \meta{width} and \meta{height} parameters specify the width and
+% height of the crop-box respectively. If some of them is omitted or is
+% empty, the width or height of the crop-box \meta{content} is used for calculation
+% the omitted dimension. In this case, the doubled value of the
+% \textit{crop-box separation\/} parameter is added to the natural dimension
+% of the box's \meta{content}. The \meta{content} is centered inside the crop-box.
+%
+% \DescribeMacro{\cropboxsep}
+% The |\cropboxsep|\marg{length} command specifies the separation value to be used
+% in calculation of crop-box dimensions when any of optional parameters is
+% omitted or empty. The default is |\cropboxsep{5pt}|.
+%
+% \DescribeMacro{\croplinewidth}
+% The |\croplinewidth|\marg{length} command specifies a width of crop-lines.
+% The default is |\croplinewidth{.4pt}|.
+%
+% \DescribeMacro{\croplinelength}
+% The |\croplinelength|\marg{length} command specifies a length and direction
+% of crop-lines: the absolute value of \meta{length} specifies
+% a length of crop-lines and the sign of \meta{length} specifies a direction.
+% If the \meta{length} is negative, the angles look outside the crop-box.
+% Otherwise, they look inside the crop-box.
+%
+% The following example shows how crop-boxes are docked together:
+% \begin{center}
+% \cropbox[30mm][10mm]{Box 1}\cropbox[30mm][10mm]{Box 2}\cropbox[30mm][10mm]{Box 3}\cropbox[30mm][10mm]{Box 4}\\
+% \cropbox[30mm][10mm]{Box 5}\cropbox[30mm][10mm]{Box 6}\cropbox[30mm][10mm]{Box 7}\cropbox[30mm][10mm]{Box 8}
+% \end{center}
+% It was prepared as follows:
+% \begin{quote}
+% |\begin{center}|\\
+% |\cropbox[30mm][10mm]{Box 1}\cropbox[30mm][10mm]{Box 2}%|\\
+% |\cropbox[30mm][10mm]{Box 3}\cropbox[30mm][10mm]{Box 4}\\|\\
+% |\cropbox[30mm][10mm]{Box 5}\cropbox[30mm][10mm]{Box 6}%|\\
+% |\cropbox[30mm][10mm]{Box 7}\cropbox[30mm][10mm]{Box 8}|\\
+% |\end{center}|
+% \end{quote}
+% You can see that crop-lines of neighbour boxes exactly coincide.
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% \begin{macro}{\croplinelength}
+% \begin{macro}{\croplinewidth}
+% \begin{macro}{\cropboxsep}
+% Styling macros:
+% \begin{macrocode}
+%<*package>
+\newcommand*{\croplinelength}[1]{\def\CRB@length{#1}}
+\newcommand*{\croplinewidth}[1]{\def\CRB@width{#1}}
+\newcommand*{\cropboxsep}[1]{\def\CRB@sep{#1}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\cropbox}
+% The |\cropbox| command:
+% \begin{macrocode}
+\newcommand*{\cropbox}[1][]{\@ifnextchar[{\CRB@box[#1]}{\CRB@box[#1][]}}
+\def\CRB@box[#1][#2]#3{%
+% \end{macrocode}
+% Calculate crop-box dimensions in |\@tempdima| and |\@tempdimb|:
+% \begin{macrocode}
+ \@begin@tempboxa\hbox{#3}%
+ \def\@tempa{#1}\ifx\@tempa\@empty
+ \@tempdima\width \advance\@tempdima 2\CRB@sep\relax
+ \else
+ \setlength\@tempdima{#1}%
+ \fi
+ \def\@tempa{#2}\ifx\@tempa\@empty
+ \@tempdimb\totalheight \advance\@tempdimb 2\CRB@sep\relax
+ \else
+ \setlength\@tempdimb{#2}%
+ \fi
+% \end{macrocode}
+% Prepare crop-marks in 0th box of zero width:
+% \begin{macrocode}
+ \setbox\z@\hb@xt@\z@{%
+ \linethickness{\CRB@width}%
+ \setlength\unitlength{\CRB@length}%
+ \ifdim\unitlength=\z@ \else
+ \ifdim\unitlength>\z@
+ \CRB@hcross\z@\z@\@ne\@ne
+ \CRB@hcross\@tempdima\z@\m@ne\@ne
+ \CRB@hcross\z@\@tempdimb\@ne\m@ne
+ \CRB@hcross\@tempdima\@tempdimb\m@ne\m@ne
+ \else \unitlength -\unitlength
+ \CRB@hcross\z@\z@\m@ne\m@ne
+ \CRB@hcross\@tempdima\z@\@ne\m@ne
+ \CRB@hcross\z@\@tempdimb\m@ne\@ne
+ \CRB@hcross\@tempdima\@tempdimb\@ne\@ne
+ \fi
+ \fi
+ }%
+% \end{macrocode}
+% Put crop-marks as a background for vertical box containing the
+% crop-box content. We decrease the height of vertical box on
+% the |\lineskip| to make the exact docking of vertically neighbour
+% crop-boxes.
+% \begin{macrocode}
+ \leavevmode \ht\z@\z@ \dp\z@\z@ \box\z@
+ \advance\@tempdimb -\lineskip
+ \vbox to\@tempdimb{\vss\vskip -\lineskip
+ \hb@xt@\@tempdima{\hss\unhbox\@tempboxa\hss}\vss\kern\z@
+ }%
+ \@end@tempboxa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CRB@hcross}
+% This command prepares a crop-mark.
+% \begin{macrocode}
+\def\CRB@hcross#1#2#3#4{%
+ \@killglue\raise#2\hb@xt@\z@{\kern#1\line(#3,0)\@ne\hss}\hss
+ \@killglue\raise#2\hb@xt@\z@{\kern#1\line(0,#4)\@ne\hss}\hss
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Initial settings:
+% \begin{macrocode}
+\croplinelength{10pt}
+\croplinewidth{.4pt}
+\cropboxsep{5pt}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/ncccropmark.dtx b/Master/texmf-dist/source/latex/ncctools/ncccropmark.dtx
new file mode 100644
index 00000000000..54e4d082ebc
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/ncccropmark.dtx
@@ -0,0 +1,155 @@
+% \iffalse
+%%
+%% File: ncccropmark.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{ncccropmark}
+%<package> [2004/11/29 v1.1 Cropmarks (NCC)]
+%
+% \changes{v1.02}{2002/01/31}{This version is uploaded to CTAN}
+% \changes{v1.03}{2002/02/08}{The package is renamed to ncccropbox}
+% \changes{v1.1}{2004/11/29}{Bug fix on misusing the bottom skip instead of top one}
+% \changes{v1.1}{2004/11/29}{Documentation was prepared}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{ncccropmark,watermark}
+\GetFileInfo{ncccropmark.sty}
+\begin{document}
+\title{The \textsf{ncccropmark} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{ncccropmark.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \watermark{\cropmark[f]{10mm}{10mm}{10mm}{10mm}{5mm}
+% \cropmark[f]{10mm}{10mm}{10mm}{10mm}{-5mm}}
+% \thiswatermark{\cropmark[f]{10mm}{10mm}{10mm}{10mm}{5mm}}
+%
+% \section{User Interface}
+%
+% \DescribeMacro{cropmark}
+% The package implements the command
+% \begin{quote}
+% |\cropmark|\oarg{fields}\marg{left}\marg{right}\marg{top}\marg{bottom}\marg{length}
+% \end{quote}
+% useful as a watermark. The command was desired for use together with the
+% |watermark| package. It must be called inside the picture environment
+% (a watermark content is prepared in such a way).
+%
+% The optional \meta{fields} parameter contains a combination of letters
+% |h| (header), |f| (footer), and |m| (marginal notes).
+% It determines the additional fields of paper area to be taken into account
+% in crop area when the crop-mark is typed out. If the optional parameter is omitted,
+% the crop area coincides with the text area only.
+%
+% Next four parameters mean padding values for crop-mark corners with respect to
+% the crop area and the last parameter is equal to crop lines length.
+% Its positive value means crop-mark corners looking on the crop area.
+% Otherwise, the corners look outside of the crop area.
+% To prepare crosses, you need to use the crop-mark twice with positive
+% and negative values.
+%
+% In two-side mode the left and right padding are swapped for
+% every even page.
+%
+% For example, |\watermark{\cropmark[f]{10mm}{10mm}{10mm}{10mm}{5mm}}|
+% means a crop-mark indented on 10mm in all directions from the crop area
+% containing the text area and the page footer. You can see the result
+% on this page. The crosses on the next page were prepared with
+% the following command:
+% \begin{quote}
+% |\watermark{\cropmark[f]{10mm}{10mm}{10mm}{10mm}{5mm}|\\
+% | \cropmark[f]{10mm}{10mm}{10mm}{10mm}{-5mm}}|
+% \end{quote}
+% \StopEventually{}
+%
+% \section{The Implementation}
+% This package requires the |ncccropbox| package to prepare a
+% crop-mark and the |tocenter| package to calculate crop-area
+% dimensions.
+% \begin{macrocode}
+%<*package>
+\RequirePackage{ncccropbox,tocenter}
+% \end{macrocode}
+%
+% \begin{macro}{\cropmark}
+% We suppose here that the |\cropmark| will be
+% used at the beginning of header. The |\NCC@pos| command
+% from the |tocenter| package parses the \meta{fields} parameter
+% and prepares |\NCC@h|\marg{register}, |\NCC@f|\marg{register},
+% and |\NCC@m|\marg{register} commands to adjust values of skip
+% registers. See the |tocenter| package for more details.
+% \begin{macrocode}
+\newcommand*{\cropmark}[6][]{\NCC@pos{#1}%
+% \end{macrocode}
+% At the first, we calculate the width of crop-box and the
+% left skip from the beginning of header.
+% The |\@tempswatrue| means reverse left and right paddings.
+% \begin{macrocode}
+ \@tempswafalse
+ \if@twoside \ifodd\c@page \else \@tempswatrue \fi\fi
+% \end{macrocode}
+% Set |\@tempdima| to the left padding and |\@tempdimb| to the right
+% padding.
+% \begin{macrocode}
+ \if@tempswa
+ \setlength{\@tempdima}{#3}%
+ \setlength{\@tempdimb}{#2}%
+ \else
+ \setlength{\@tempdima}{#2}%
+ \setlength{\@tempdimb}{#3}%
+ \fi
+% \end{macrocode}
+% Adjust values of |\@tempdima| and |\@tempdimb| with margin
+% widths:
+% \begin{macrocode}
+ \if@twocolumn
+ \NCC@m\@tempdima \NCC@m\@tempdimb
+ \else
+ \if@tempswa
+ \if@reversemargin \NCC@m\@tempdimb \else \NCC@m\@tempdima \fi
+ \else
+ \if@reversemargin \NCC@m\@tempdima \else \NCC@m\@tempdimb \fi
+ \fi
+ \fi
+% \end{macrocode}
+% Calculate the left skip in |\@tempskipa| and the crop-box width
+% in |\@tempdima|:
+% \begin{macrocode}
+ \@tempskipa -\@tempdima
+ \advance\@tempdima\@tempdimb
+ \advance\@tempdima\textwidth
+% \end{macrocode}
+% Now we calculate the height of crop-box in the |\@tempdimb| register
+% and the bottom skip in the |\@tempskipb| register:
+% \begin{macrocode}
+ \@tempdimb\headsep
+ \advance\@tempdimb\textheight
+ \NCC@f\@tempdimb
+ \addtolength{\@tempdimb}{#5}%
+ \@tempskipb -\@tempdimb
+ \advance\@tempdimb -\headsep
+ \NCC@h\@tempdimb
+ \addtolength{\@tempdimb}{#4}%
+% \end{macrocode}
+% All necessary calculations are done. Put the crop-box at
+% the relative position |\@tempskipa,\@tempskipb|:
+% \begin{macrocode}
+ \begingroup
+ \croplinelength{#6}%
+ \lineskip\z@
+ \@killglue\raise\@tempskipb
+ \hb@xt@\z@{\kern\@tempskipa
+ \cropbox[\@tempdima][\@tempdimb]{}\hss}\hss%
+ \endgroup
+}
+%</package>
+% \end{macrocode}
+% \end{macro}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccfancyhdr.dtx b/Master/texmf-dist/source/latex/ncctools/nccfancyhdr.dtx
new file mode 100644
index 00000000000..dab851e4811
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccfancyhdr.dtx
@@ -0,0 +1,1053 @@
+% \iffalse
+%%
+%% File: nccfancyhdr.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{nccfancyhdr}
+%<package> [2004/12/07 v1.1 Improved Fancy Header Package (NCC)]
+%
+% \changes{v1.00}{2002/02/01}{This version was uploaded to CTAN}
+% \changes{v1.01}{2002/02/07}{|\fancycenter| command added}
+% \changes{v1.01}{2002/02/07}{Header and footer struts are moved out of par-boxes}
+% \changes{v1.1}{2004/12/07}{The |\newpagestyle| command added}
+% \changes{v1.1}{2004/12/07}{The |\headrule| and |\footrule| commands added}
+% \changes{v1.1}{2004/12/07}{Add optional \meta{stretch} parameter in |\fancycenter|}
+% \changes{v1.1}{2004/12/07}{Remove |\fancycentersep| and |\fancycenterstretch| macros}
+% \changes{v1.1}{2004/12/07}{Add conditional testing of floats within |testfloats| option}
+% \changes{v1.1}{2004/12/07}{Documentation was prepared}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nccboxes}
+\usepackage[headings]{nccfancyhdr}
+\newpagestyle{lheadings}[headings]{%
+ \fancyhead[ce]{\nouppercase{\fancycenter{\thepage}{}{\slshape\leftmark}}}%
+ \fancyhead[co]{\nouppercase{\fancycenter{\slshape\rightmark}{}{\thepage}}}%
+}
+\pagestyle{lheadings}
+\addtolength{\headwidth}{\marginparsep}
+\addtolength{\headwidth}{0.6\marginparwidth}
+\renewcommand{\headrulewidth}{0.6pt}
+\makeatletter
+\renewcommand{\headrule}{%
+ \setlength\@tempdima{\headrulewidth}%
+ \hrule\@height\@tempdima\@width\headwidth
+ \vskip 2\@tempdima
+ \hrule\@height\@tempdima\@width\headwidth
+ \vskip -4\@tempdima
+}
+\makeatother
+\GetFileInfo{nccfancyhdr.sty}
+\begin{document}
+\title{The \textsf{nccfancyhdr} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccfancyhdr.dtx}
+\end{document}
+%</driver>
+% \fi
+% This package is originated on the |fancyhdr| package by Piet van Oostrum.
+% It provides almost the same functionality but implements it in more safe
+% and simple way.
+% The most important reason for re-implementation the |fancyhdr| was that
+% |fancy| page style breaks conventions on page styles definition:
+% avoiding global definitions in page styling commands. If this contract is
+% broken, a page style cannot be used locally as a parameter of the
+% |\thispagestyle| command. Other reasons for such re-implementation were
+% the following: some commands in |fancyhdr| do more than it is
+% necessary (e.g.\ the |fancy| page style redefines section marks),
+% incorrect vertical alignment in headers leads to raising headers a bit
+% (this produces a page overfull if header height is exactly the same as
+% a height of text in it), some features introduced in the |fancyhdr|
+% are unsafe (a special cycle |\@forc| is introduced with the |\def|
+% command), and the implementation of commands is frequently too
+% complicated. All these disadvantages of |fancyhdr| set off me to
+% prepare a new version of |fancyhdr| packaged named as the |nccfancyhdr|.
+%
+% \section{Using the Package}
+%
+% \thispagestyle{plain}
+% The package supports three-part headers and footers separated
+% from the text area with optional decorative lines. Using fancy headers
+% and footers you can easy customize page layout.
+%
+% The first and the most useful benefit of fancy page styles is
+% the possibility of decoration of headers and footers with a rule.
+% If you want to add
+% a rule to some of standard page styles (|empty|, |plain|, |myheadings|,
+% and |headings|), put their names in the list of
+% options of the |\usepackage| command:
+% \begin{quote}
+% |\usepackage|\oarg{style-list}|{nccfancyhdr}|
+% \end{quote}
+% For example, the command
+% \begin{quote}
+% |\usepackage[plain,headings]{nccfancyhdr}|
+% \end{quote}
+% loads the |nccfancyhdr| package and redefines the |plain| and |headings|
+% styles on the base of |fancy| page style. It also sets the last style
+% in the list (e.g.\ |headings| style) as a default page style.\pagebreak
+%
+% \section{Rule Control}
+%
+% \DescribeMacro{\headrulewidth}
+% \DescribeMacro{\footrulewidth}
+% The widths of decorative rules for header and footer are coded in the\linebreak
+% |\headrulewidth| and |\footrulewidth| commands respectively
+% (these commands were ported from the |fancyhdr| package).
+% The default values for these commands are |0.4pt| (standard head rule width)
+% and |0pt| (no foot rule).
+% To change defaults, you should redefine corresponding commands.
+% For example, to set a head rule of |0.6pt| width in this document,
+% we use the following command:
+% \begin{quote}
+% |\renewcommand{\headrulewidth}{0.6pt}|
+% \end{quote}
+%
+% \DescribeMacro{\headstrutheight}
+% \DescribeMacro{\footstrutheight}
+% A distance between rules and headers/footers is controlled with the\linebreak
+% |\headstrutheight| and |\footstrutheight| commands.
+% Here is a distinction with the |fancyhdr| package. The |fancyhdr| allows
+% control the distance between the decoration rule and the page foot only
+% in the |\footruleskip| command. Moreover, we use another technique to provide
+% separation between header/footer and its rule: we insert special struts
+% in headers and footers whose height and depth are calculated using the
+% values of the mentioned commands. The defaults for both |\headstrutheight|
+% and |\footstrutheight| are |0.3\normalbaselineskip|. You can redefine
+% them in just the same manner as rule width commands above.
+%
+% \DescribeMacro{\headrule}
+% \DescribeMacro{\footrule}
+% The decorative rules in the header and footer are prepared with the\linebreak
+% |\headrule| and |\footrule| commands. These commands work in vertical
+% mode. They put an |\hrule| and do a negative |\vskip| to compensate
+% the rule height (see the implementation section for more details).
+% You can redefine these rules to produce custom decoration lines. For example,
+% the double line in the header of this document is produced with the following
+% code:
+% \begin{quote}
+% |\makeatletter|\\
+% |\renewcommand{\headrule}{%|\\
+% | \setlength\@tempdima{\headrulewidth}%|\\
+% | \hrule\@height\@tempdima\@width\headwidth|\\
+% | \vskip 2\@tempdima|\\
+% | \hrule\@height\@tempdima\@width\headwidth|\\
+% | \vskip -4\@tempdima|\\
+% |}|\\
+% |\makeatother|
+% \end{quote}
+%
+% \DescribeMacro{\headwidth}
+% \DescribeMacro{\normalheaders}
+% \DescribeMacro{\extendedheaders}
+% The width of header and footer (and, of course, the widths of their rules)
+% is controlled with the |\headwidth| register. It is usually equal to the
+% |\textwidth| but can exceed it. In the last case, the headers and footers are
+% expanded on the marginal area. To simplify control of the |\headwidth|,
+% two service commands are introduced in the package. The |\normalheaders|
+% command sets the |\headwidth| to the |\textwidth|. The
+% |\extendedheaders| enlarged the headers and footers on the whole marginal area:
+% in two-column mode, header and footer are expanded to both margins and, in
+% one-column mode, header and footer are expanded to the
+% outer margin, but, if reverse margin mode is on, they are expanded to
+% the inner margin. In this document, the |\headwidth| is expanded to marginal
+% area as follows:
+% \begin{quote}
+% |\addtolength{\headwidth}{\marginparsep}|\\
+% |\addtolength{\headwidth}{0.6\marginparwidth}|
+% \end{quote}
+%
+% \section{Page Style Customization}
+%
+% To customize a page style of your document, you can do the following:
+% set the |\pagestyle{fancy}| in the preamble of the document
+% and specify values of header and footer marks with the following
+% commands:\vspace{-\baselineskip}
+% \begin{center}\catcode`|=12
+% \small
+% \renewcommand\cboxstyle{\footnotesize}
+% \begin{tabular}{|l|c|l|}\hline
+% \hfill\cbox{Command}\hfill\mbox{} &
+% \hfill\cbox{Default optional\\parameter}\hfill\mbox{} &
+% \hfill\cbox{Meaning}\hfill\mbox{}\\\hline
+% \Strut/.8/
+% \verb+\fancyhf+\oarg{pos-list}\marg{mark} &
+% \verb+[lh,ch,rh,lf,cf,rf]+ &
+% Set a mark for header/footer \\
+% \verb+\fancyhead+\oarg{pos-list}\marg{mark} &
+% \verb+[l,c,r]+ &
+% Set a mark for header \\
+% \verb+\fancyfoot+\oarg{pos-list}\marg{mark} &
+% \verb+[l,c,r]+ &
+% Set a mark for footer \\
+% \verb+\lhead+\oarg{even-mark}\marg{odd-mark} &
+% \oarg{odd-mark} &
+% Set the left mark of header\\
+% \verb+\chead+\oarg{even-mark}\marg{odd-mark} &
+% \oarg{odd-mark} &
+% Set the center mark of header\\
+% \verb+\rhead+\oarg{even-mark}\marg{odd-mark} &
+% \oarg{odd-mark} &
+% Set the right mark of header\\
+% \verb+\lfoot+\oarg{even-mark}\marg{odd-mark} &
+% \oarg{odd-mark} &
+% Set the left mark of footer\\
+% \verb+\cfoot+\oarg{even-mark}\marg{odd-mark} &
+% \oarg{odd-mark} &
+% Set the center mark of footer\\
+% \verb+\rfoot+\oarg{even-mark}\marg{odd-mark} &
+% \oarg{odd-mark} &
+% Set the right mark of footer\\\hline
+% \end{tabular}
+% \end{center}
+%
+% All these commands are ported from the |fancyhdr| package.
+%
+% \DescribeMacro{\fancyhf}
+% The |\fancyhf| command allows specify any mark of header or footer.
+% The \meta{pos-list} argument specifies marks to set.
+% A~mark position selector in the \meta{pos-list} argument consists
+% of up to three letters: header/footer selector (|h| or |f|),
+% horizontal position selector (|l| or |c| or |r|), odd/even page
+% selector (|o|~or~|e|). The odd/even page selector is optional.
+% If it is omitted, the command is applied to the corresponding mark
+% on both odd and even pages. For example, |\fancyhf[hco]{mark}|
+% sets the center mark of a header for odd pages.
+%
+% \textit{Note\/}: the even page selector has a sense for two-side mode only.
+% In one-side documents (e.g.\ reports), even page marks are ignored.
+%
+% \DescribeMacro{\fancyhead}
+% \DescribeMacro{\fancyfoot}
+% The |\fancyhead| and |\fancyfoot| commands allows specify any
+% mark of header and footer respectively.
+% A~mark position selector in the \meta{pos-list} argument consists
+% of up to two letters: horizontal position selector (|l| or |c| or |r|)
+% and odd/even page selector (|o|~or~|e|). The odd/even page selector
+% is also optional. For example, |\fancyhead[l]{mark}|
+% sets the left mark of a header for both odd and even pages.
+%
+% \textit{Note\/}: The command |\fancyhf{}| clears all marks of headers and footers.
+% The |\fancyhead{}| and |\fancyfoot{}| commands clear all marks in headers
+% and footers respectively.
+%
+% \DescribeMacro{\lhead}
+% \DescribeMacro{\chead}
+% \DescribeMacro{\rhead}
+% \DescribeMacro{\lfoot}
+% \DescribeMacro{\cfoot}
+% \DescribeMacro{\rfoot}
+% We also implement the old-style macros |\lhead|, |\chead|, |\rhead|,
+% |\lfoot|, |\cfoot|, and |\rfoot|. Their meaning is clear enough.
+% For example, the command |\rhead[even-mark]{odd-mark}| is equivalent
+% to the following commands:
+% \begin{quote}
+% |\fancyhead[le]{even-mark}|\\
+% |\fancyhead[lo]{odd-mark}|
+% \end{quote}
+% If an optional parameter of these commands is omitted, the same mark
+% is set for both odd and even pages. For example, the command
+% |\cfoot{mark}| is equivalent to the |\fancyfoot[c]{mark}|.
+%
+% \DescribeMacro{\nouppercase}
+% You can use the |\nouppercase|\marg{text} command within a mark
+% commands to ignore the |\uppercase| and |\MakeUppercase| commands
+% in its parameter. For example, the
+% |\rhead{\nouppercase{\rightmark}}| command ignores conversion the contents
+% of |\rightmark| to uppercase.
+%
+% \section{Fancy Centering}
+%
+% The marks in a fancy header and footer are prepared using |\parbox|
+% command. So, you can use multiline marks. In the header, they are
+% aligned to the bottom line, but, in the footer, they are aligned to
+% the top line. The maximum width of every mark is equal to the
+% |\headwidth|. This can lead to overlapping of neighbour marks.
+%
+% \DescribeMacro{\fancycenter}
+% If you want to prepare marks in more traditional way in a line
+% not exceeding the |\headwidth|, you can use
+% the following command in any mark command:
+% \begin{quote}
+% |\fancycenter|\oarg{distance}\oarg{stretch}\\
+% | |\marg{left-mark}\marg{center-mark}\marg{right-mark}
+% \end{quote}
+% This command works like
+% \begin{center}
+% |\hbox to\linewidth{|\marg{left-mark}|\hfil|\marg{center-mark}|\hfil|\marg{right-mark}|}|
+% \end{center}
+% but does this work more carefully trying to exactly center the central part of
+% the text if possible. The solution for exact centering
+% is applied if the width of \meta{center-mark} is less than
+% \begin{quote}
+% |\linewidth - 2*(|\meta{stretch}|*|\meta{distance}| +|\\
+% | max(width(|\meta{left-mark}|), width(|\meta{right-mark}|)))|.
+% \end{quote}
+% Otherwise the \meta{center-mark} will slightly migrate to a shorter item
+% (\meta{left-mark} or \meta{right-mark}), but at least \meta{distance}
+% space between all parts of line is provided.
+% The default values of \meta{distance} and \meta{stretch}
+% are |1em| and |3|.
+%
+% If the \meta{center-mark} is empty, the |\fancycenter| is equivalent to
+% the following command:
+% \begin{center}
+% |\hbox to\linewidth {|\marg{left-mark}|\hfil |\marg{right-mark}|}|
+% \end{center}
+%
+% \textit{Note\/}: The usage of |\fancycenter| command is not limited with the
+% argument of header/footer marks only. You can use it anywhere in your document.
+%
+% \section{Prepare Custom Page Styles}
+%
+% \DescribeMacro{\newpagestyle}
+% In the |nccfancyhdr| package, we recommend to set fancy marks within
+% definition of a custom page style. In this case,
+% you can easy select a custom style with the
+% |\pagestyle| or |\thispagestyle| command. To support this, the
+% |\newpagestyle| command is introduced:
+% \begin{quote}
+% |\newpagestyle|\marg{style-name}\oarg{base-style}\marg{definitions}
+% \end{quote}
+% It is allowed in the preamble only. The \meta{base-style} is a style
+% the new style will be based on. If the optional parameter is omitted, the
+% |fancy| style is used as the base style.
+% The |fancy| style works as the |empty| style, but support decorative
+% rules and extended headers/footers and allows fancy marks.
+% A desired page style works as follows:
+% at the first, the base style is applied; after that, the \meta{definitions}
+% customize the base style.
+%
+% \textit{Note\/}: You can use any existing \meta{base-style} in the
+% definition of a new style, but, if you apply fancy mark commands in the
+% \meta{definitions} parameter, the base style should be based on the
+% |fancy| style.
+%
+% For example, all pages of this document except the first one were prepared
+% with the custom page style as follows:
+% \begin{quote}
+% |\usepackage[headings]{nccfancyhdr}|\\
+% |\newpagestyle{lheadings}[headings]{%|\\
+% | \fancyhead[ce]{\nouppercase{%|\\
+% | \fancycenter{\thepage}{}{\slshape\leftmark}}}%|\\
+% | \fancyhead[co]{\nouppercase{%|\\
+% | \fancycenter{\slshape\rightmark}{}{\thepage}}}%|\\
+% |}|\\
+% |\pagestyle{lheadings}|
+% \end{quote}
+% As you can see from here, the fancy versions of |headings| and
+% |myheadings| styles use the center mark only and prepare it
+% with the help of the |\fancycenter| command.
+%
+% \section{How to Change a Page Style in Floatpages?}
+%
+% A floatpage is a page consisting of floats only. You cannot
+% directly change a page style for such a page, because it is prepared
+% in whole in the \LaTeX\ Output Routine.
+% We recommend to change a page style for floatpages with the help of the
+% |afterpage| package. Just add a command |\usepackage{afterpage}|
+% in the preamble and put the command:
+% \begin{quote}
+% |\afterpage{\thispagestyle|\marg{special-style}|}|
+% \end{quote}
+% anywhere in the page going before the floatpage.
+% The \meta{special-style} is a style you want to apply for
+% floatpages.
+%
+% \DescribeMacro{\iffloatpage}
+% \DescribeMacro{\iftopfloat}
+% \DescribeMacro{\ifbotfloat}
+% Another way for change a page style on pages with floats
+% consists in using the following conditional commands within marks of
+% a page style:
+% \begin{quote}
+% |\iffloatpage|\marg{true-clause}\marg{false-clause}\\
+% |\iftopfloat|\marg{true-clause}\marg{false-clause}\\
+% |\ifbotfloat|\marg{true-clause}\marg{false-clause}
+% \end{quote}
+% These commands were ported from the |fancyhdr| package.
+% The |\iffloatpage| command executes the \meta{true-clause} if
+% this is a floatpage. Otherwise, it executes the \meta{false-clause}.
+% Analogously, the |\iftopfloat| and |\ifbotfloat| test the
+% lists of top floats and bottom floats of the page to be nonempty.
+%
+% Whereas these commands are rare used, they are defined if the
+% package is loaded with the |testfloats| option.
+%
+% \section{Package Options}
+%
+% In conclusion, we enumerate all package options available:
+% \begin{center}\catcode`|=12
+% \small\tabcolsep=10pt
+% \renewcommand\cboxstyle{\footnotesize}
+% \begin{tabular}{|l|l|}\hline
+% \hfill\cbox{Option}\hfill\mbox{} &
+% \hfill\cbox{Meaning}\hfill\mbox{}\\\hline
+% \Strut/.8/
+% \texttt{empty} & redefine the \texttt{empty} page style to be fancy-based style \\
+% \texttt{plain} & redefine the \texttt{plain} page style to be fancy-based style \\
+% \texttt{headings} & redefine the \texttt{headings} page style to be fancy-based style \\
+% \texttt{myheadings} & redefine the \texttt{myheadings} page style to be fancy-based style \\
+% \texttt{testfloats} & define \verb+\iffloatpage+, \verb+\iftopfloat+,
+% and \verb+\ifbotfloat+ commands\\
+% \hline
+% \end{tabular}
+% \end{center}
+% The options are executed in the order they are specified in the list of options.
+% Every page
+% style redefinition option sets a redefined style to be the current page style.
+% Therefore, after loading of this package, the style redefined in the last order
+% will be the current page style.
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% \begin{macro}{\newpagestyle}
+% We start with the |\newpagestyle| command. It was introduced in
+% the version~1.1 of the package. It is available in the preamble only.
+% \begin{macrocode}
+%<*package>
+\newcommand*{\newpagestyle}[1]{%
+ \@ifnextchar[{\NCC@newpagestyle{#1}}{\NCC@newpagestyle{#1}[fancy]}%
+}
+\long\def\NCC@newpagestyle#1[#2]#3{%
+ \@ifundefined{ps@#2}{%
+ \PackageError{nccfancyhdr}
+ {\string\newpagestyle: Unknown base page style `#2'}{}%
+ }{}%
+ \edef\@tempa{\noexpand\newcommand \expandafter\noexpand
+ \csname ps@#1\endcsname}%
+ \expandafter\@tempa\expandafter{\csname ps@#2\endcsname #3}%
+}
+\@onlypreamble\newpagestyle
+\@onlypreamble\NCC@newpagestyle
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fancyhf}
+% \begin{macro}{\fancyhead}
+% \begin{macro}{\fancyfoot}
+% Now we define the new-style fancy marking commands. They are based
+% on the |\NCC@fancyhf| command.
+% \begin{macrocode}
+\newcommand*{\fancyhf}[1][lh,ch,rh,lf,cf,rf]{\NCC@fancyhf{}{#1}}
+\newcommand*{\fancyhead}[1][l,c,r]{\NCC@fancyhf h{#1}}
+\newcommand*{\fancyfoot}[1][l,c,r]{\NCC@fancyhf f{#1}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\lhead}
+% \begin{macro}{\chead}
+% \begin{macro}{\rhead}
+% \begin{macro}{\lfoot}
+% \begin{macro}{\cfoot}
+% \begin{macro}{\rfoot}
+% The old-style fancy-marking commands are based on the |\NCC@fancy|
+% command.
+% \begin{macrocode}
+\newcommand{\lhead}{\@dblarg{\NCC@fancy{lh}}}
+\newcommand{\chead}{\@dblarg{\NCC@fancy{ch}}}
+\newcommand{\rhead}{\@dblarg{\NCC@fancy{rh}}}
+\newcommand{\lfoot}{\@dblarg{\NCC@fancy{lf}}}
+\newcommand{\cfoot}{\@dblarg{\NCC@fancy{cf}}}
+\newcommand{\rfoot}{\@dblarg{\NCC@fancy{rf}}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fancy}
+% The |\NCC@fancy|\marg{selector}\oarg{even-mark}\marg{odd-mark}
+% command sets a pair of marks. A \meta{selector} consists of two
+% letters: (lcr) and (hf). We need not test the \meta{selector} on
+% correctness because this command is applied internally.
+% \begin{macrocode}
+\def\NCC@fancy#1[#2]#3{
+ \expandafter\def\csname NCC@f@e#1\endcsname{#2}%
+ \expandafter\def\csname NCC@f@o#1\endcsname{#3}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fancyhf}
+% The |\NCC@fancyhf|\marg{hf}\marg{pos-list}\marg{mark} command
+% parses the \meta{pos-list} by selectors and executes the
+% |\NCC@fancydef| for every selector. The \meta{hf} argument
+% contains the common part of all selectors added at their
+% beginning.
+% \begin{macrocode}
+\def\NCC@fancyhf#1#2#3{%
+ \@for\@tempa:=#2\do
+ {\edef\@tempa{\noexpand\NCC@fancydef{#1\@tempa}}\@tempa{#3}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fancydef}
+% The |\NCC@fancydef|\marg{selector}\marg{mark} command analyzes
+% the \meta{selector} and defines corresponding fancy mark.
+% It uses the |\NCC@fancyclass| command that prevents using many letters
+% of the same class in the \meta{selector}. For example, it will be an
+% error if more that one `l' or `c' or `r' letter appears in the
+% selector.
+% \begin{macrocode}
+\def\NCC@fancydef#1#2{%
+% \end{macrocode}
+% The |\NCC@hf|, |\NCC@lcr|, and |\NCC@oe| will contain a letter
+% of the corresponding class found in selector. Before the cycle,
+% they are set to |\relax|.
+% \begin{macrocode}
+ \let\NCC@hf\relax \let\NCC@lcr\relax \let\NCC@oe\relax
+ \@tfor \@nextchar:=#1\do
+% \end{macrocode}
+% Prepare in |\@tempa| a next letter in uppercase.
+% \begin{macrocode}
+ {\edef\@tempa{\noexpand\uppercase{\noexpand\def%
+ \noexpand\@tempa{\@nextchar}}}\@tempa
+% \end{macrocode}
+% Test the letter and specify corresponding class.
+% \begin{macrocode}
+ \if\@tempa H\NCC@fancyclass\NCC@hf{h}{#1}\else
+ \if\@tempa F\NCC@fancyclass\NCC@hf{f}{#1}\else
+ \if\@tempa L\NCC@fancyclass\NCC@lcr{l}{#1}\else
+ \if\@tempa C\NCC@fancyclass\NCC@lcr{c}{#1}\else
+ \if\@tempa R\NCC@fancyclass\NCC@lcr{r}{#1}\else
+ \if\@tempa O\NCC@fancyclass\NCC@oe{o}{#1}\else
+ \if\@tempa E\NCC@fancyclass\NCC@oe{e}{#1}\else
+ \NCC@fancyerror{Illegal char `\@nextchar' in argument `#1'}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ }%
+% \end{macrocode}
+% After cycle, we test that the |\NCC@hf| and |\NCC@lcr| classes
+% are specified. The |\NCC@oe| class is optional. So, we do not test it.
+% Finally, we define appropriate mark commands.
+% \begin{macrocode}
+ \ifx\NCC@hf\relax \NCC@fancyerror{No `h' or `f' specified}\else
+ \ifx\NCC@lcr\relax \NCC@fancyerror{No `l' or `c' or `r' specified}\else
+ \ifx\NCC@oe\relax
+ \expandafter\def\csname NCC@f@o\NCC@lcr\NCC@hf\endcsname{#2}%
+ \expandafter\def\csname NCC@f@e\NCC@lcr\NCC@hf\endcsname{#2}%
+ \else
+ \expandafter\def\csname NCC@f@\NCC@oe\NCC@lcr\NCC@hf\endcsname{#2}%
+ \fi
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fancyclass}
+% The |\NCC@fancyclass|\marg{command}\marg{letter}\marg{selector}
+% command tests the\linebreak \meta{command} to be |\relax| and defines
+% it with the \meta{letter} argument. If the command is already defined,
+% the error message is generated.
+% \begin{macrocode}
+\def\NCC@fancyclass#1#2#3{%
+ \ifx#1\relax
+ \def#1{#2}%
+ \else
+ \NCC@fancyerror{Misusing the char `\@nextchar' in argument `#3'}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fancyerror}
+% A handler of errors in fancy mark definitions.
+% \begin{macrocode}
+\def\NCC@fancyerror#1{%
+ \PackageError{nccfancyhdr}%
+ {Fancy mark definitions:\MessageBreak#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\headwidth}
+% \begin{macro}{\extendedheaders}
+% \begin{macro}{\normalheaders}
+% Now we allocate the |\headwidth| register and define
+% its control commands.
+% \begin{macrocode}
+\newdimen\headwidth
+\newcommand{\extendedheaders}{
+ \@tempdima\marginparwidth \advance\@tempdima\marginparsep
+ \@tempdimb\textwidth \advance\@tempdimb\@tempdima
+ \if@twocolumn \advance\@tempdimb\@tempdima \fi
+ \global\headwidth\@tempdimb
+}
+\newcommand{\normalheaders}{\global\headwidth\textwidth}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\headrulewidth}
+% \begin{macro}{\footrulewidth}
+% \begin{macro}{\headstrutheight}
+% \begin{macro}{\footstrutheight}
+% Now we specify parameters of decoration rules: widths and struts.
+% \begin{macrocode}
+\newcommand{\headrulewidth}{.4\p@}
+\newcommand{\footrulewidth}{\z@}
+\newcommand{\headstrutheight}{.3\normalbaselineskip}
+\newcommand{\footstrutheight}{.3\normalbaselineskip}
+% \end{macrocode}
+% \textit{Note\/}: Really, the head strut height is zero but its depth is equal
+% to the value of |\headstrutheight|. Moreover, the foot strut height
+% is a sum of |0.55\normalbaseskip| and the value of |\footstrutheight|.
+% But we prefer the universal notations for command names instead of strict one,
+% because users do not interested in implementation details.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\headrule}
+% The default implementation of the |\headrule|. It works in vertical mode.
+% At first it draws a rule and then it inserts a negative skip for compensation.
+% \begin{macrocode}
+\newcommand{\headrule}{%
+ \setlength\@tempdima{\headrulewidth}%
+ \hrule\@height\@tempdima\@width\headwidth
+ \vskip-\@tempdima
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\footrule}
+% The |\footrule| works in reverse order: at first it inserts a negative skip
+% and after that it draws a rule.
+% \begin{macrocode}
+\newcommand{\footrule}{%
+ \setlength\@tempdima{\footrulewidth}% Can use calc here
+ \vskip -\@tempdima
+ \hrule \@height\@tempdima \@width\headwidth
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fancyreset}
+% The |\NCC@fancyreset| command is used at the beginning
+% of fancy headers and footers. It resets font, removes
+% baseline stretch and locally defines the |\nouppercase| command.
+% In comparison with the |fancyhdr| package, we do not
+% call the |\restorecr| command because it is obsolete now.
+% We also redefine the |\uppercase| and |\MakeUppercase|
+% commands in more appropriate way than in |fancyhdr|.
+% \begin{macrocode}
+\def\NCC@fancyreset{\let\baselinestretch\@empty
+ \long\def\nouppercase##1{%
+ \begingroup
+ \long\def\uppercase####1{####1}%
+ \long\def\MakeUppercase####1{####1}%
+ ##1%
+ \endgroup
+ }%
+ \reset@font
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fancyhead}
+% The |\NCC@fancyhead|\marg{left-mark}\marg{center-mark}\marg{right-mark}
+% command prepares the fancy header. It differs from the implementation in
+% the |fancyhdr| at the following issue: the vertical box in this command
+% (|\@tempboxa|) is prepared as |\vtop| box, but in the |fancyhdr| package
+% it is prepared as |\vbox| box. As a consequence, in the |fancyhdr| version,
+% the base line of the vertical box goes at the rule and the header slightly
+% moves up.
+% \begin{macrocode}
+\def\NCC@fancyhead#1#2#3{%
+ \hb@xt@\headwidth{\NCC@fancyreset
+ \setbox\@tempboxa\vtop{%
+ \hbox{%
+% \end{macrocode}
+% Prepare the left mark:
+% \begin{macrocode}
+ \rlap{\parbox[b]\headwidth{\raggedright#1}}%
+% \end{macrocode}
+% Insert the strut:
+% \begin{macrocode}
+ \setlength\@tempdima{\headstrutheight}%
+ \vrule\@width\z@\@height\z@\@depth\@tempdima
+% \end{macrocode}
+% Prepare the center mark:
+% \begin{macrocode}
+ \parbox[b]\headwidth{\centering#2}%
+% \end{macrocode}
+% Prepare the right mark:
+% \begin{macrocode}
+ \llap{\parbox[b]\headwidth{\raggedleft#3}}%
+ }%
+% \end{macrocode}
+% Draw decoration rule:
+% \begin{macrocode}
+ \headrule
+ }%
+% \end{macrocode}
+% Compare the height of |\@tempboxa| with the |\headheaght|
+% and correct the last one if vertical overfull appears:
+% \begin{macrocode}
+ \NCC@fancytest\headheight
+% \end{macrocode}
+% Put the fancy header:
+% \begin{macrocode}
+ \box\@tempboxa
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fancyfoot}
+% The |\NCC@fancyfoot|\marg{left-mark}\marg{center-mark}\marg{right-mark}
+% command prepares the fancy footer. Its implementation is similar to
+% the |\NCC@fancyhead|.
+% \begin{macrocode}
+\def\NCC@fancyfoot#1#2#3{%
+ \hb@xt@\headwidth{\NCC@fancyreset
+ \setbox\@tempboxa\vbox{%
+ \footrule
+ \hbox{%
+ \rlap{\parbox[t]\headwidth{\raggedright#1}}%
+ \@tempdima .55\normalbaselineskip
+ \addtolength\@tempdima{\footstrutheight}%
+ \vrule\@width\z@\@height\@tempdima\@depth\z@
+ \parbox[t]\headwidth{\centering#2}%
+ \llap{\parbox[t]\headwidth{\raggedleft#3}}%
+ }%
+ }%
+ \NCC@fancytest\footskip
+ \box\@tempboxa
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fancytest}
+% The |\NCC@fancytest|\marg{register} command compares
+% a value of the \meta{register} with the height of |\@tempboxa|
+% and modifies the \meta{register} value if necessary.
+% \begin{macrocode}
+\def\NCC@fancytest#1{%
+ \ifdim\ht\@tempboxa>#1%
+ \PackageWarning{nccfancyhdr}%
+ {\string#1 is too small (\the#1):\MessageBreak
+ Make it at least \the\ht\@tempboxa.\MessageBreak
+ We now enlarge it for the rest of the document.\MessageBreak
+ This may cause the page layout to be inconsistent, however}%
+ \@tempdima#1\global\setlength{#1}{\ht\@tempboxa}%
+ \ht\@tempboxa\@tempdima
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@ihss}
+% \begin{macro}{\NCC@ohss}
+% The |\NCC@ihss| and |\NCC@ohss| hooks insert the |\hss| command
+% at the outer and/or inner sides of header/footer to provide the proper
+% enlargement it on margins.
+% \begin{macrocode}
+\def\NCC@ihss{\if@twocolumn\hss\else\if@reversemargin\hss\fi\fi}
+\def\NCC@ohss{\if@twocolumn\hss\else\if@reversemargin\else\hss\fi\fi}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\fancycenter}
+% |\fancycenter|\oarg{dist}\oarg{stretch}\marg{left-mark}\marg{center-mark}\marg{right-mark}
+% \begin{macrocode}
+\newcommand*{\fancycenter}[1][1em]{%
+ \@ifnextchar[{\NCC@fancycenter{#1}}{\NCC@fancycenter{#1}[3]}%
+}
+\def\NCC@fancycenter#1[#2]#3#4#5{%
+% \end{macrocode}
+% At first, we execute the case when the \meta{center-mark} is empty:
+% \begin{macrocode}
+ \def\@tempa{#4}\ifx\@tempa\@empty
+ \hb@xt@\linewidth{\color@begingroup{#3}\hfil {#5}\color@endgroup}%
+ \else
+% \end{macrocode}
+% All that we need to do is to calculate skips inserted before and after
+% \meta{center-mark}. We will calculate them in the |\@tempskipa|
+% and |\@tempskipb|. At first:
+% \begin{quote}
+% |\@tempdima:=|\meta{dist};\\
+% |\@tempdimb:=|\meta{dist}|*|\meta{stretch};\\
+% |\@tempdimc:=|\meta{dist}|*|\meta{stretch}|-|\meta{dist};\\
+% |\@tempskipa:=\@tempskipb:=\@tempdimb + 1fil - \@tempdimc|;
+% \end{quote}
+% \begin{macrocode}
+ \setlength\@tempdima{#1}%
+ \setlength{\@tempdimb}{#2\@tempdima}%
+ \@tempdimc \@tempdimb \advance\@tempdimc -\@tempdima
+ \setlength\@tempskipa{\@tempdimb \@plus 1fil \@minus \@tempdimc}%
+ \@tempskipb\@tempskipa
+% \end{macrocode}
+% At this point, the |\@tempskipa| and |\@tempskipb| registers
+% have the natural size \meta{dist}|*|\meta{stretch},
+% unlimited stretchability, and the minimum size \meta{dist}.
+% Now we decrease the minimum size of |\@tempskipa| to zero if
+% the \meta{left-mark} is empty:
+% \begin{macrocode}
+ \def\@tempa{#3}\ifx\@tempa\@empty
+ \addtolength\@tempskipa{\z@ \@minus \@tempdima}%
+ \fi
+% \end{macrocode}
+% Do the same things with the |\@tempskipb| register if the
+% \meta{right-mark} is empty:
+% \begin{macrocode}
+ \def\@tempa{#5}\ifx\@tempa\@empty % empty right
+ \addtolength\@tempskipb{\z@ \@minus \@tempdima}%
+ \fi
+% \end{macrocode}
+% Finally, we correct the left and right glues taking into
+% account the difference between lengthes of \meta{left-mark}
+% and \meta{right-mark}. We calculate what mark is shorter
+% and increase the natural size of corresponding register
+% on the difference between their lengthes.
+% \begin{macrocode}
+ \settowidth{\@tempdimb}{#3}%
+ \settowidth{\@tempdimc}{#5}%
+ \ifdim\@tempdimb>\@tempdimc
+ \advance\@tempdimb -\@tempdimc
+ \addtolength\@tempskipb{\@tempdimb \@minus \@tempdimb}%
+ \else
+ \advance\@tempdimc -\@tempdimb
+ \addtolength\@tempskipa{\@tempdimc \@minus \@tempdimc}%
+ \fi
+% \end{macrocode}
+% The |\@tempskipa| and |\@tempskipb| are calculated. Put the box.
+% \begin{macrocode}
+ \hb@xt@\linewidth{\color@begingroup{#3}\hskip \@tempskipa
+ {#4}\hskip \@tempskipb {#5}\color@endgroup}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% The rest of the package consists of games with styles and options.
+%
+% \begin{macro}{\ps@fancy}
+% We start from declaring the |fancy| page style. It extends the
+% |empty| page style. So, we simply call the empty style and then
+% redefine |\@oddhead|, |\@evenhead|, |\@oddfoot|, and |\@evenfoot|
+% to be fancy one. The |\NCC@ihss| and |\NCC@ohss| hooks provide
+% proper enlargement of headers/footers on margins. The |\fancyhf{}|
+% command at the end of macro clears all marks.
+% \begin{macrocode}
+\def\ps@fancy{\ps@empty
+ \def\@oddhead{%
+ \NCC@ihss \NCC@fancyhead\NCC@f@olh\NCC@f@och\NCC@f@orh \NCC@ohss}%
+ \def\@evenhead{%
+ \NCC@ohss \NCC@fancyhead\NCC@f@elh\NCC@f@ech\NCC@f@erh \NCC@ihss}%
+ \def\@oddfoot{%
+ \NCC@ihss \NCC@fancyfoot\NCC@f@olf\NCC@f@ocf\NCC@f@orf \NCC@ohss}%
+ \def\@evenfoot{%
+ \NCC@ohss \NCC@fancyfoot\NCC@f@elf\NCC@f@ecf\NCC@f@erf \NCC@ihss}%
+ \fancyhf{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Standard styles are redefined optionally.
+%
+% \begin{macro}{\ps@empty}
+% When we redefine the |empty| style, we must take into account
+% that it can be also redefined (as in |amsart| and |amsbook| classes).
+% So, we save its previous meaning in the |\NCC@psempty| macro and base the
+% |empty| style on the saved style.
+% \begin{macrocode}
+\DeclareOption{empty}{%
+ \let\NCC@psempty\ps@empty
+ \def\ps@empty{\NCC@psempty
+ \def\@oddhead{%
+ \NCC@ihss \NCC@fancyhead\NCC@f@olh\NCC@f@och\NCC@f@orh \NCC@ohss}%
+ \def\@evenhead{%
+ \NCC@ohss \NCC@fancyhead\NCC@f@elh\NCC@f@ech\NCC@f@erh \NCC@ihss}%
+ \def\@oddfoot{%
+ \NCC@ihss \NCC@fancyfoot\NCC@f@olf\NCC@f@ocf\NCC@f@orf \NCC@ohss}%
+ \def\@evenfoot{%
+ \NCC@ohss \NCC@fancyfoot\NCC@f@elf\NCC@f@ecf\NCC@f@erf \NCC@ihss}%
+ \fancyhf{}%
+ }%
+ \pagestyle{empty}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ps@plain}
+% The redefinition of the |plain| style is quite simple:
+% \begin{macrocode}
+\DeclareOption{plain}{%
+ \def\ps@plain{\ps@fancy \let\@mkboth\@gobbletwo
+ \fancyfoot[c]{\thepage}%
+ }%
+ \pagestyle{plain}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ps@myheadings}
+% The redefinition of the |myheadings| style is conditional.
+% We test the |\chapter| command on existence and redefine the
+% style in a bit different ways.
+% \begin{macrocode}
+\DeclareOption{myheadings}{%
+ \@ifundefined{chapter}{%
+ \def\ps@myheadings{\ps@fancy \let\@mkboth\@gobbletwo
+ \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
+ \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
+ \let\sectionmark\@gobble
+ \let\subsectionmark\@gobble
+ }%
+ }{\def\ps@myheadings{\ps@fancy \let\@mkboth\@gobbletwo
+ \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
+ \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
+ \let\chaptermark\@gobble
+ \let\sectionmark\@gobble
+ }%
+ }%
+ \pagestyle{myheadings}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ps@headings}
+% The redefinition of the |headings| style also differs for
+% book-like and article-like classes. It also differs for
+% one-side and two-side modes.
+% \begin{macrocode}
+\DeclareOption{headings}{%
+ \@ifundefined{chapter}{%
+ \if@twoside
+% \end{macrocode}
+% An article in two-side mode:
+% \begin{macrocode}
+ \def\ps@headings{\ps@fancy \let\@mkboth\markboth
+ \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
+ \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
+ \def\sectionmark##1{%
+ \markboth{\MakeUppercase{%
+ \ifnum \c@secnumdepth >\z@ \thesection\quad \fi##1}}{}}%
+ \def\subsectionmark##1{%
+ \markright{%
+ \ifnum \c@secnumdepth >\@ne \thesubsection\quad \fi##1}}%
+ }%
+ \else
+% \end{macrocode}
+% An article in one-side mode:
+% \begin{macrocode}
+ \def\ps@headings{\ps@fancy \let\@mkboth\markboth
+ \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
+ \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
+ \def\sectionmark##1{%
+ \markright {\MakeUppercase{%
+ \ifnum \c@secnumdepth >\z@ \thesection\quad \fi##1}}}%
+ \let\subsectionmark\@gobble % Not needed but inserted for safety
+ }%
+ \fi
+ }{\if@twoside
+% \end{macrocode}
+% A book in two-side mode:
+% \begin{macrocode}
+ \def\ps@headings{\ps@fancy \let\@mkboth\markboth
+ \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
+ \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
+ \def\chaptermark##1{%
+ \markboth{\MakeUppercase{%
+ \ifnum \c@secnumdepth >\m@ne \if@mainmatter
+ \@chapapp\ \thechapter. \ \fi\fi##1}}{}}%
+ \def\sectionmark##1{%
+ \markright {\MakeUppercase{%
+ \ifnum \c@secnumdepth >\z@ \thesection. \ \fi##1}}}%
+ }%
+ \else
+% \end{macrocode}
+% A book in one-side mode:
+% \begin{macrocode}
+ \def\ps@headings{\ps@fancy \let\@mkboth\markboth
+ \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
+ \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
+ \def\chaptermark##1{%
+ \markright{\MakeUppercase{%
+ \ifnum \c@secnumdepth >\m@ne \if@mainmatter
+ \@chapapp\ \thechapter. \ \fi\fi##1}}}%
+ \let\sectionmark\@gobble % Not needed but inserted for safety
+ }%
+ \fi
+ }%
+ \pagestyle{headings}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\iffloatpage}
+% \begin{macro}{\iftopfloat}
+% \begin{macro}{\ifbotfloat}
+% These macros are defined in the |testfloats| option.
+% They were ported from the |fancyhdr| and modified a bit
+% in more \LaTeX\ way. It is no warrantee that these macros
+% will proper work in all cases. They must be used inside
+% fancy mark commands.
+% \begin{macrocode}
+\DeclareOption{testfloats}{%
+ \let\NCC@fancymakecol\@makecol
+ \let\NCC@fancytoplist\@empty
+ \let\NCC@fancybotlist\@empty
+ \def\@makecol{%
+ \let\NCC@fancytoplist\@toplist
+ \let\NCC@fancybotlist\@botlist
+ \NCC@fancymakecol
+ }%
+ \newcommand\iftopfloat{%
+ \ifx\NCC@fancytoplist\@empty
+ \expandafter\@secondoftwo
+ \else
+ \expandafter\@firstoftwo
+ \fi
+ }%
+ \newcommand\ifbotfloat{%
+ \ifx\NCC@fancybotlist\@empty
+ \expandafter\@secondoftwo
+ \else
+ \expandafter\@firstoftwo
+ \fi
+ }%
+ \newcommand\iffloatpage{%
+ \if@fcolmade
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% Finally, we process the options in the order they are specified
+% in the options list and set the defaults.
+% \begin{macrocode}
+\ProcessOptions*
+\normalheaders
+\fancyhf{}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccfloats.dtx b/Master/texmf-dist/source/latex/ncctools/nccfloats.dtx
new file mode 100644
index 00000000000..b23f6debe6c
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccfloats.dtx
@@ -0,0 +1,497 @@
+% \iffalse
+%%
+%% File: nccfloats.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{nccfloats}
+%<package> [2004/12/05 v1.1 More Float Management (NCC)]
+%
+% \changes{v1.00}{2002/03/23}{This version is uploaded to CTAN}
+% \changes{v1.01}{2002/05/17}{Handling of side floats improved}
+% \changes{v1.1}{2004/12/05}{Width parameters can have units now}
+% \changes{v1.1}{2004/12/05}{Documentation was prepared}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{desclist,nccfloats}
+\GetFileInfo{nccfloats.sty}
+\begin{document}
+\title{The \textsf{nccfloats} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccfloats.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% The standard \LaTeX\ floating environments, namely |figure|
+% and |table|, allow user to place floating material in a
+% document. But they do not introduce a style in which this
+% material must be prepared. In this package, envelop commands are
+% developed which join a style with a float and more
+% features are introduced, namely
+% mini-figures, mini-tables, side-figures, and side-tables.
+%
+% \section{Basic Commands}
+%
+% \DescribeMacro{\FloatingStyle}
+% The |\FloatingStyle|\marg{style} command sets a style of
+% floats in the document. It affects on the material prepared with
+% commands described below. The default style is
+% \begin{quote}
+% |\FloatingStyle{\footnotesize\centering}|
+% \end{quote}
+% This command is available in the preamble only.
+%
+% \DescribeMacro{\minifig}
+% \DescribeMacro{\minitabl}
+% We start with the basic commands, namely |\minifig| and
+% |\minitabl|. They prepare a material in a minipage and allow
+% using the |\caption| command in the body. Their syntax is
+% similar to the |\parbox| command:
+% \begin{quote}
+% |\minifig |\oarg{pos}\oarg{height}\oarg{inner-pos}\marg{width}\marg{body}\\
+% |\minitabl|\oarg{pos}\oarg{height}\oarg{inner-pos}\marg{width}\marg{body}
+% \end{quote}
+% The \meta{pos} is a vertical alignment parameter for
+% minipage (|t|, |b|, or |c|) with respect to
+% surrounding text; the \meta{height} is a minipage height
+% required; the \meta{inner-pos} is a vertical alignment
+% of text inside the minipage (|t|, |b|, |c|, or |s|);
+% and the \meta{width} is the minipage width.
+% The \meta{body} is prepared in the style specified by the
+% |\FloatingStyle| command and can contain the |\caption| command inside.
+%
+% All other floating extension commands are based on
+% these two commands.
+%
+% \section{Side Figures and Tables}
+%
+% For small figures and tables, it is preferable to insert them
+% inside a text instead of using floating mechanism. The
+% typographic rules usually require an illustrative material to
+% occupy an outer side of page. In two-side mode, this means
+% figure and tables should be on the right side if a page number is
+% odd and on the left side if page number is even. In one-side
+% mode, figures and tables must occupy the right side of page.
+%
+% \DescribeMacro{\sidefig}
+% \DescribeMacro{\sidetabl}
+% The following commands support such a placement:
+% \begin{quote}
+% |\sidefig|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{figure}\marg{text}\\
+% |\sidefig*|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{figure}\marg{text}\\
+% |\sidetabl|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{table}\marg{text}\\
+% |\sidetabl*|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{table}\marg{text}
+% \end{quote}
+% For simplicity, we further use the term \textit{minifloat\/} for the
+% small illustrating material (figure or table), however
+% taking into account that it is not a float at all. It is inserted in
+% the main flow next to a paragraph box specified in the last
+% parameter of above described commands.
+%
+% The no-star forms of above described commands place a minifloat
+% next to the specified text on the outer side of page (to the
+% right for odd page and to the left for even page). In two-column
+% or one-side mode, minifloat is always posed to the right. The
+% star-forms provide the reverse placement. By default, minifloat
+% is vertically centered with respect to the text and the
+% |\strut| command is inserted at the beginning and at the end
+% of the \meta{text} to provide normal baseline
+% distances of the first and last lines of the text from
+% surrounding text lines.
+%
+% All parameters in square and round brackets are optional and mean
+% the following:
+% \begin{desclist}{}{}[\meta{pos}]
+% \item[\meta{pos}] specifies minifloat alignment (|t|,
+% |b|, or |c|; default is |c|) with respect to text
+% box and can contain additional chars controlling the text body
+% preparation: |j| means the last line of the text to be
+% justified to the right and |n| means suppressing of struts
+% insertion (they should be inserted manually if necessary);
+%
+% \item[$w_1$] is the width of minifloat; and
+%
+% \item[$w_2$] is the width of the text box.
+% \end{desclist}
+%
+% You can omit units in the width parameters. In this case,
+% the width value is considered as a multiple of |\unitlength|
+% (similarly to the use of length dimensions in the picture environment).
+%
+% If both width parameters are absent, the widths are calculated as\linebreak
+% |(\linewidth-1.5em)/2|. If $w_2$ is absent, the text body
+% width is calculated as |\linewidth-|$w_1$|-1.5em|.
+%
+% The placement of side-floats in the document consists in the following
+% steps:
+% \begin{enumerate}
+% \item Decide where you want to insert a side-float;
+% \item Insert a |\sidefig| or |\sidetabl| command after a word that finishes
+% the line before the future side-float position;
+% \item Specify a width of float in its parameter and set the top alignment
+% as the \meta{pos} parameter (e.g.\ |\sidefig[t](|$w_1$|)|);
+% \item Prepare the side-float in the first mandatory parameter of the command
+% (e.g.\ |\sidefig[t](|$w_1$|)|\marg{figure});
+% \item Enclose enough text going after the command in braces;
+% \item Translate the document;
+% \item Find what part of the text is redundant in the \meta{text} parameter;
+% \item Move it after the close brace;
+% \item If the same paragraph continues after the close brace, add the |j|
+% letter to the \meta{pos} parameter. Also change the top alignment
+% to the centered alignment;
+% \item Translate the document once more;
+% \item If the side-float has a wrong placement (this can appear when paragraph
+% with a side-float begins at the end of page), insert the star after
+% the side-float command.
+% \end{enumerate}
+%
+% \DescribeMacro{\ifleftsidefloat}
+% While preparing a side-float, it is sometimes necessary to
+% provide conditional placement depending on the side a minifloat
+% is posed. The command
+% \begin{quote}
+% |\ifleftsidefloat|\marg{left-clause}\marg{right-clause}
+% \end{quote}
+% provides this. It is useful in parameters of |\sidefig| or
+% |\sidetabl| and processes \meta{left-clause} if the
+% minifloat is posed to the left and \meta{right-clause}
+% otherwise.
+%
+% Side-floats can be also used within floating environments to pos
+% a caption near a figure or table.
+%
+% \section{Floating Figures and Tables}
+%
+% \DescribeMacro{\fig}
+% \DescribeMacro{\tabl}
+% The following commands envelop floating
+% environments:
+% \begin{quote}
+% |\fig|\oarg{placement}|(|$w$|)|\marg{body}\\
+% |\fig*|\oarg{placement}|(|$w$|)|\marg{body}\\
+% |\tabl|\oarg{placement}|(|$w$|)|\marg{body}\\
+% |\tabl*|\oarg{placement}|(|$w$|)|\marg{body}
+% \end{quote}
+% The \meta{placement} is a float placement parameter
+% describing places where a float can appear. The default value is
+% |ht| (here or at the top of page).
+% The optional $w$ parameter defines a
+% width of box occupied by the float (the width of nested
+% |\minifig| or |\minitabl|). If it
+% is omitted, the float has the maximum width equal to the
+% |\linewidth|.
+%
+% The |\fig| and |\tabl| commands envelop the |figure|
+% and |table| environments respectively. Their star-forms
+% envelop corresponding starred |figure*| or |table*| environments.
+%
+% \section{Two Floating Figures or Tables Side by Side}
+%
+% \DescribeMacro{\figs}
+% \DescribeMacro{\tabls}
+% The following commands place two figures or tables side by side.
+% \begin{quote}
+% |\figs|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}\\
+% |\figs*|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}\\
+% |\tabls|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}\\
+% |\tabls*|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}
+% \end{quote}
+% The \meta{body1} is a body of the left figure or table and
+% the \meta{body2} is a body of the right figure or table.
+% Other parameters are optional. The meaning and default value of
+% the \meta{placement} parameter is the same as described
+% above. The $w_1$ and $w_2$ parameters are
+% widths of left and right boxes. If
+% they both are omitted, the left and right boxes will have the
+% width equal to |(\linewidth-1em)/2|. If $w_2$
+% is omitted, the right box will occupy the rest of horizontal space
+% minus |1em|. If both parameters are specified, the rest
+% space is inserted between boxes. If the total width of left and
+% right floats exceeds the |\linewidth|, the floats will overlap
+% at the middle (a negative horizontal space is inserted between them).
+%
+% In the |\tabls| command, boxes of the left and right bodies are
+% top-aligned, but, in the |\figs| command, the bottom alignment is
+% used. The star-forms of this commands are based on the corresponding
+% starred |figure*| or |table*| environments.
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% The package uses some commands of the |nccboxes| package.
+% Load it here:
+% \begin{macrocode}
+%<*package>
+\RequirePackage{nccboxes}[2002/03/20]
+% \end{macrocode}
+%
+% \begin{macro}{\FloatStyle}
+% \begin{macro}{\minifig}
+% \begin{macro}{\minitabl}
+% At the first, we define the basic commands.
+% \begin{macrocode}
+\newcommand*{\FloatStyle}[1]{\def\NCC@fltstyle{#1}}
+\@onlypreamble\FloatStyle
+\newcommand{\minifig}{\begingroup\def\@captype{figure}\NCC@minifloat}
+\newcommand{\minitabl}{\begingroup\def\@captype{table}\NCC@minifloat}
+\newcommand*\NCC@minifloat[1][c]{%
+ \@ifnextchar[{\NCC@mflt{#1}}{\NCC@@mflt{#1}\relax[s]}}
+\def\NCC@mflt#1[#2]{%
+ \@ifnextchar[{\NCC@@mflt{#1}{#2}}{\NCC@mflt{#1}{#2}[#1]}}
+\long\def\NCC@@mflt#1#2[#3]#4#5{%
+ \@iiiminipage{#1}{#2}[#3]{#4}\normalfont
+ \NCC@fltstyle #5\endminipage\endgroup
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\NCC@pair}
+% The |\NCC@pair|\marg{c1}\marg{c2}\marg{def-dist}\marg{def-place}|*|\oarg{place}|(|$w_1$|)(|$w_2$|)|
+% command executes \meta{c1}\marg{place}|{|$w_1$|}{|$w_2$|}| if star is absent or
+% \meta{c2}\marg{place}|{|$w_1$|}{|$w_2$|}| if star presents.
+% Four first parameters are mandatory. Others a optional.
+% The \meta{def-dist} parameter contains a default distance
+% value. It is saved in the |\@tempdimc| register.
+% The \meta{def-place} parameter contains the default value for
+% the \meta{place} parameter. If the last one is omitted,
+% the \meta{def-place} is used instead.
+% \begin{macrocode}
+\def\NCC@pair#1#2#3#4{\setlength\@tempdimc{#3}%
+ \@ifstar{\NCC@pair@{#2}{#4}}{\NCC@pair@{#1}{#4}}}
+\def\NCC@pair@#1#2{\@ifnextchar[{\NCC@pair@@{#1}}{\NCC@pair@@{#1}[#2]}}
+\def\NCC@pair@@#1[#2]{\def\@tempa{#1{#2}}%
+ \@ifnextchar({\NCC@pair@@@}{\NCC@@pair()()}}
+\def\NCC@pair@@@(#1){\@ifnextchar({\NCC@@pair(#1)}{\NCC@@pair(#1)()}}
+\def\NCC@@pair(#1)(#2){\@tempa{#1}{#2}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@setwidth}
+% The |\NCC@setwidth|\marg{register}\marg{width} command sets
+% the given \meta{width} to the dimen \meta{register}. If units
+% in \meta{width} are omitted, the |\unitlength| unit is used.
+% In other words, if \meta{width} is a real number, it is considered
+% as a multiple of |\unitlength|.
+% \begin{macrocode}
+\def\NCC@setwidth#1#2{%
+ \afterassignment\NCC@setwidth@#1#2\unitlength\relax
+}
+\def\NCC@setwidth@#1\relax{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@wcalc}
+% The |\NCC@wcalc{|$w_1$|}{|$w_2$|}| calculates widths
+% of left and right boxes in the |\@tempdima| and |\@tempdimb|
+% registers. The distance between boxes must be specified in
+% |\@tempdimc| register before the call. The algorithm:
+% \begin{itemize}
+% \item If $w_1$ is empty, |\@tempdima:=(\linewidth-\@tempdimc)/2|,
+% otherwise, |\@tempdima:=|$w_1$;
+% \item If $w_2$ is empty, |\@tempdimb:=\linewidth-\@tempdima-\@tempdimc|,
+% otherwise, |\@tempdimb:=|$w_2$;
+% \item If $w_2$ is nonempty,
+% |\@tempdimc:=\linewidth-\@tempdima-\@tempdimb|.
+% \end{itemize}
+% \begin{macrocode}
+\def\NCC@wcalc#1#2{%
+ \if!#1!\@tempdima .5\linewidth \advance\@tempdima -.5\@tempdimc
+ \else \NCC@setwidth\@tempdima{#1}%
+ \fi
+ \if!#2!\@tempdimb \linewidth \advance\@tempdimb -\@tempdima
+ \advance\@tempdimb -\@tempdimc
+ \else \NCC@setwidth\@tempdimb{#2}%
+ \@tempdimc \linewidth \advance\@tempdimc -\@tempdima
+ \advance\@tempdimc -\@tempdimb
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifleftsidefloat}
+% This command is used in parameters of |\sidefig| or |\sidetabl|.
+% \begin{macrocode}
+\newif\ifNCC@smfltleft
+\newcommand{\ifleftsidefloat}{%
+ \ifNCC@smfltleft
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sidefig}
+% \begin{macro}{\sidetabl}
+% The implementation of these commands is based
+% on the |\NCC@pair| command that parses all optional
+% parameters. Finally the |\NCC@smflt| command is
+% executed.
+% \begin{macrocode}
+\newcommand{\sidefig}{\NCC@sidemfloat{\minifig}}
+\newcommand{\sidetabl}{\NCC@sidemfloat{\minitabl}}
+\def\NCC@sidemfloat#1{%
+ \NCC@smfltleftfalse
+ \if@twocolumn \else
+ \if@twoside
+ \ifodd\c@page \else \NCC@smfltlefttrue \fi
+ \fi
+ \fi
+ \NCC@pair{\NCC@smflt{#1}}%
+ {\ifNCC@smfltleft \NCC@smfltleftfalse \else \NCC@smfltlefttrue\fi
+ \NCC@smflt{#1}}%
+ {1.5em}{}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\NCC@smflt}
+% The |\NCC@smflt|\marg{command}\marg{pos}|{|$w_1$|}{|$w_2$|}|\marg{minifloat}\marg{text}
+% prepares a side-float. The \meta{command} parameter contains
+% a |\minifig| or |\minitabl| command. The \meta{pos} parameter
+% specifies vertical alignment and additional flags. The
+% $w_1$ and $w_2$ parameters (if present) specify widthes of
+% \meta{minifloat} and \meta{text} boxes. The |\@tempdimc| register
+% contains the default distance between the minifloat and text.
+% \begin{macrocode}
+\long\def\NCC@smflt#1#2#3#4#5#6{%
+% \end{macrocode}
+% Parse the \meta{pos} parameter. Create a |\NCC@|\meta{letter}
+% command with empty content for every \meta{letter} from the \meta{pos}.
+% \begin{macrocode}
+ \let\NCC@t\relax \let\NCC@b\relax \let\NCC@j\relax \let\NCC@n\strut
+ \@tfor\@tempa :=#2\do {%
+ \expandafter\let\csname NCC@\@tempa\endcsname\@empty}%
+% \end{macrocode}
+% Define the vertical alignment letter in the |\NCC@c| command.
+% \begin{macrocode}
+ \ifx\NCC@t\@empty \def\NCC@c{t}\else
+ \ifx\NCC@b\@empty \def\NCC@c{b}\else
+ \def\NCC@c{c}%
+ \fi
+ \fi
+% \end{macrocode}
+% Define a justification hook in the |\NCC@j| command.
+% \begin{macrocode}
+ \ifx\NCC@j\@empty \def\NCC@j{\parfillskip\z@skip}\fi
+% \end{macrocode}
+% Define the text starting hook in the |\NCC@t| command.
+% It will contain the |\parindent| setting command and
+% the optional |\noindent| command.
+% \begin{macrocode}
+ \edef\NCC@t{\parindent\the\parindent\ifvmode\else\noindent\fi}%
+% \end{macrocode}
+% Complete the current paragraph and leave the horizontal mode.
+% \begin{macrocode}
+ \ifvmode\else
+ \unskip{\parfillskip\rightskip\par}\vskip -\parskip
+ \fi
+% \end{macrocode}
+% Prepare the side-float in |\@tempboxa|:
+% \begin{macrocode}
+ \setbox\@tempboxa\vbox{\hsize\linewidth\noindent
+% \end{macrocode}
+% Calculate widthes of left and right boxes and distance
+% between them in |\@tempdima|, |\@tempdimb|, and |\@tempdimc|.
+% \begin{macrocode}
+ \NCC@wcalc{#3}{#4}%
+% \end{macrocode}
+% Conditionally put a side-float to the left:
+% \begin{macrocode}
+ \ifNCC@smfltleft
+ \jparbox{\Strut}[\NCC@c]\@tempdima{#1\@tempdima{#5}}%
+ \nobreak\hskip\@tempdimc
+ \fi
+% \end{macrocode}
+% Put a text box:
+% \begin{macrocode}
+ \jparbox{\NCC@n\Strut}[\NCC@c]\@tempdimb{%
+ \everypar{\NCC@n\everypar{}}\NCC@t#6%
+ \ifvmode \else \unskip\NCC@n\NCC@j\fi}%
+% \end{macrocode}
+% Conditionally put a side-float to the right:
+% \begin{macrocode}
+ \ifNCC@smfltleft \else
+ \nobreak\hskip\@tempdimc
+ \jparbox{\Strut}[\NCC@c]\@tempdima{#1\@tempdima{#5}}%
+ \fi
+ }%
+% \end{macrocode}
+% Games with height and depth the |\@temboxa| allow us
+% produce right line spacing with surrounding text.
+% \begin{macrocode}
+ \@tempdima\dp\@tempboxa \advance\@tempdima\lineskip
+ \dp\@tempboxa\@tempdima
+ \@tempdima\ht\@tempboxa \advance\@tempdima -\ht\strutbox
+ \noindent \raise-\@tempdima\box\@tempboxa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fig}
+% \begin{macro}{\tabl}
+% The implementation of these commands is quite simple:
+% \begin{macrocode}
+\newcommand{\fig}{\NCC@float{figure}}
+\newcommand{\tabl}{\NCC@float{table}}
+\def\NCC@float#1{\@ifstar{\NCC@flt{#1*}}{\NCC@flt{#1}}}
+\def\NCC@flt#1{\@ifnextchar[{\NCC@flt@{#1}}{\NCC@flt@{#1}[ht]}}
+\def\NCC@flt@#1[#2]{\begin{#1}[#2]\centering
+ \@ifnextchar({\NCC@@flt{#1}}{\NCC@@flt{#1}()}}
+\long\def\NCC@@flt#1(#2)#3{%
+ \if!#2!\@tempdima\linewidth \else \NCC@setwidth\@tempdima{#2}\fi
+ \begingroup\NCC@minifloat[c]\@tempdima{#3}%
+ \end{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\figs}
+% \begin{macro}{\tabls}
+% The implementation of these commands is based
+% on the |\NCC@pair| command that parses all optional
+% parameters. Finally the |\NCC@flts| command is
+% executed.
+% \begin{macrocode}
+\newcommand{\figs}{\NCC@floats{figure}b}
+\newcommand{\tabls}{\NCC@floats{table}t}
+\def\NCC@floats#1#2{%
+ \NCC@pair{\NCC@@flts{#1}{#2}}{\NCC@@flts{#1*}{#2}}{1em}{ht}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\NCC@flts}
+% The |\NCC@flts|\marg{env}\marg{pos}\marg{placement}|{|$w_1$|}{|$w_2$|}|\marg{body1}\marg{body2}
+% command prepares a pair of floats within \meta{env} environment.
+% The \meta{pos} contains relative alignment of floats.
+% The $w_1$ and $w_2$ parameters (if present) specify widthes of
+% floats. The |\@tempdimc| register contains the default distance
+% between floats.
+% \begin{macrocode}
+\long\def\NCC@@flts#1#2#3#4#5#6#7{%
+ \begin{#1}[#3]\NCC@wcalc{#4}{#5}%
+ \begingroup\NCC@minifloat[#2]\@tempdima{#6}%
+ \nobreak\hskip\@tempdimc
+ \begingroup\NCC@minifloat[#2]\@tempdimb{#7}%
+ \end{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Defaults:
+% \begin{macrocode}
+\FloatStyle{\footnotesize\centering}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccfoots.dtx b/Master/texmf-dist/source/latex/ncctools/nccfoots.dtx
new file mode 100644
index 00000000000..29e2d82d251
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccfoots.dtx
@@ -0,0 +1,94 @@
+% \iffalse
+%%
+%% File: nccfoots.dtx Copyright (C) 1998-2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{nccfoots}
+%<package> [2005/02/03 v1.2 NCC Footnotes Package (NCC)]
+%
+% \changes{v1.0}{1998/12/18}{Initial version}
+% \changes{v1.1}{2004/11/23}{Minor corrections of the documentation}
+% \changes{v1.2}{2005/02/03}{\NCC@makemark rename to \NCC@makefnmark}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nccfoots}
+\GetFileInfo{nccfoots.sty}
+\begin{document}
+\title{The \textsf{nccfoots} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccfoots.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% The package implements commands for generating footnotes marked by
+% hands.
+%
+% \section{User Interface}
+%
+% \DescribeMacro\Footnotemark
+% \DescribeMacro\Footnotetext
+% \DescribeMacro\Footnote
+% These commands are acompany to the ordinary \LaTeX's footnote mark
+% command. They allow user to mark footnotes by hands. Their syntax is
+% the following:
+% \begin{quote}
+% |\Footnotemark|\marg{marker}\\
+% |\Footnotetext|\marg{marker}\marg{inserted text}\\
+% |\Footnote|\marg{marker}\marg{inserted text}
+% \end{quote}
+% When \meta{marker} is empty the previous marker will be used. Hence,
+% |\Footnote| command is equal to
+% \begin{quote}
+% |\Footnotemark|\marg{marker}|\Footnotetext{}|\marg{inserted text}
+% \end{quote}
+%
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% \begin{macro}{\NCC@makefnmark}
+% We begin with the internal command |\NCC@makemark| which tests the
+% footnote marker to be empty and globally redefines \LaTeX{}
+% internal command |\@thefnmark| to be equal to this marker.
+% We use exactly the same expansion method as in \LaTeXe{}.
+% We also initialize |\@thefnmark| command to avoid error when the
+% first marking command has an empty marker.
+% \begin{macrocode}
+%<*package>
+\def\NCC@makefnmark#1{\def\@tempa{#1}%
+ \ifx\@tempa\@empty \else
+ \begingroup
+ \unrestored@protected@xdef\@thefnmark{#1}%
+ \endgroup
+ \fi
+}
+\let\@thefnmark\@empty
+% \end{macrocode}
+% \textbf{Note}. If you use an automatic enumeration and produce
+% marker by |\the|\meta{counter} the internal command producing the
+% shape of number have to be \emph{robust}. All standard shaping
+% commands like |\arabic|, |\roman|, etc., are robust. Take it
+% into account if you want design your own shape.
+% \end{macro}
+%
+% \begin{macro}{\Footnote}
+% \begin{macro}{\Footnotemark}
+% \begin{macro}{\Footnotetext}
+% Finally, we add the handle style footnote commands which are
+% companions to the respective standard ones.
+% \begin{macrocode}
+\newcommand*{\Footnote}[1]{\Footnotemark{#1}\@footnotetext}
+\newcommand*{\Footnotemark}[1]{\NCC@makefnmark{#1}\@footnotemark}
+\newcommand*{\Footnotetext}[1]{\NCC@makefnmark{#1}\@footnotetext}
+%</package>
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccmath.dtx b/Master/texmf-dist/source/latex/ncctools/nccmath.dtx
new file mode 100644
index 00000000000..78512699c7d
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccmath.dtx
@@ -0,0 +1,1163 @@
+% \iffalse
+%%
+%% File: nccmath.dtx Copyright (C) 2002--2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+%<package>\ProvidesPackage{nccmath}
+%<package> [2005/02/21 v1.2 Additional Math Commands (NCC)]
+%
+% \changes{v1.01}{2002/01/20}{This version is uploaded to CTAN}
+% \changes{v1.02}{2002/02/19}{|\Eq|, |\Eqs|, and |\Eqalign| are removed}
+% \changes{v1.03}{2002/03/16}{|\useshortskip| command added}
+% \changes{v1.1}{2004/12/08}{Do |fleqn| and |ceqn| working with all display equations}
+% \changes{v1.1}{2004/12/08}{Documentation was prepared}
+% \changes{v1.2}{2005/02/13}{Introduce |\medmath|, |\mfrac|, |\mbinom|, |mmatrix|}
+% \changes{v1.2}{2005/02/14}{Introduce |\medop|, |\medint|, |\medintkern|, |medsize|}
+% \changes{v1.2}{2005/02/15}{Introduce |mediummath|}
+% \changes{v1.2}{2005/02/16}{Remove redefinition of equations tag}
+% \changes{v1.2}{2005/02/21}{Avoid conflicts with the |array| package}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nccmath,desclist}
+\GetFileInfo{nccmath.sty}
+\newcommand*\com[1]{{\tt\symbol{"5C}#1}}
+
+\begin{document}
+\title{The \textsf{nccmath} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccmath.dtx}
+\end{document}
+%</driver>
+% \fi
+% The package extends the |amsmath| package adding some math
+% commands from NCC-\LaTeX. It also improves spacing control
+% before display equations and fixes a bug of ignoring
+% the |\displaybreak| in the |amsmath| version of the
+% |equation| environment. All options are passed
+% to the |amsmath| package.
+%
+% \section{Improvement to the amsmath}
+%
+% \DescribeMacro{eqnarray}
+% In the |amsmath| package, the |eqnarray| environment leaves
+% unchanged because alternative \AmS\ environments exist. We
+% redefine the |eqnarray| to work in the \AmS\ style. The
+% following improvements are done in it: an equation tag is
+% prepared by the same manner as in \AmS\ display formulas
+% (|\tag| and |\tag*| are allowed); the |\displaybreak|
+% command is allowed; the intercolumn distance is reduced to the
+% distance between ordinary and relational math symbols; and the
+% center field is prepared in the |\displaystyle| (the original
+% version uses |\textstyle| here).
+%
+% \DescribeMacro{\intertext}
+% The |\intertext| command is improved here. It now has an optional
+% parameter:
+% \begin{quote}
+% |\intertext|\oarg{distance}\marg{text}
+% \end{quote}
+% The \meta{distance} parameter specifies a vertical space inserted
+% before and after the text. If it is omitted, standard \TeX's
+% skips are inserted.
+%
+% The following changes are made in display equations:
+% \begin{itemize}
+% \item The |\displaybreak| command now works within the |equation|
+% environment (it is ignored in the |amsmath|);
+% \item The \AmS\ and \LaTeX\ display equations prepared in the
+% vertical mode do not produce now an empty extra line before.
+% Moreover, if a minipage starts from a display formula,
+% the vertical skip before is suppressed.
+% \end{itemize}
+%
+% \section{Extra Macros}
+%
+% \DescribeMacro{fleqn}
+% \DescribeMacro{ceqn}
+% The following environments allow change the horizontal alignment
+% of formulas inside them:
+% \begin{quote}
+% |\begin{fleqn}|\oarg{margin} \ldots\ |\end{fleqn}|\\
+% |\begin{ceqn}| \ldots\ |\end{ceqn}|
+% \end{quote}
+% The |fleqn| environment prepares inner display equations in
+% the flush left style. The \meta{margin} parameter specifies
+% the left margin value. If it is omitted, zero value is used.
+% The |ceqn| environment prepares inner display equations in the
+% centered style. They have no effect on formulas prepared with the
+% low-level \TeX\ command~|$$|.
+%
+% \DescribeMacro{darray}
+% The |darray| environment produces an array of formulas in the
+% |\displaystyle|. The distance between formulas is enlarged in
+% just the same manner as in other multiline display equations. The
+% |darray| environment has the same syntax as the |array|:
+% \begin{quote}
+% |\begin{darray}|\oarg{pos}\marg{columns}\\
+% \meta{body}\\
+% |\end{darray}|
+% \end{quote}
+% The \meta{pos} argument describes the vertical alignment of
+% the array box (|t|, |b|, or |c|; default is |c|). The
+% use of column specifications in the \meta{columns} argument
+% is restricted in comparison with |array|: it can contain
+% the |l|, |c|, and |r| specifiers, |*| and |@| commands.
+% The intercolumn separation is smaller than in the |array|:
+% it is reduced to the distance between ordinary and relational
+% math symbols. As in the |amsmath| package, the thin skip is
+% inserted before |darray|. Skips before the first and after
+% the last column of |darray| are not inserted.
+% To insert them manually, use |@{...}| in the \meta{columns}
+% argument.
+%
+% The |darray| environment is implemented independently on the
+% |array| environment to avoid conflicts with the |array| package.
+%
+% \DescribeMacro{\useshortskip}
+% In \TeX, two types of skips above display formulas are used: the
+% normal skip defined in the |\abovedisplayskip| register and the
+% short skip defined in the |\abovedisplayshortskip| register.
+% When a display formula is typed out, \TeX\ decides what skip to
+% insert depending on the width of formula, its style (centered or
+% flushed left, numbered left or right), and the width of the rest
+% of text in the last line of the previous paragraph. But this
+% algorithm works for ordinary formulas only. It does not work in
+% multiline formulas prepared with |\halign| command. So, a
+% manual replacement of the normal skip to the short skip is required
+% in some cases. To provides this, the |\useshortskip| command is
+% introduced. It forces the use of short skip in the next
+% display formula but it has no effect on formulas prepared with the
+% low-level \TeX\ command |$$|.
+%
+% \DescribeMacro{\nr}
+% The vertical distance between lines of miltiline equations
+% is frequently smaller than necessary. To increase it, the
+% extra distance can be used as the optional parameter of the
+% |\\|\oarg{dist} command.
+% In most cases, it is enough to increase the distance on |0.5ex|.
+% We introduce the |\nr| command here that is equivalent to the
+% |\\[0.5ex]|. Its full sintax is just the same as for the |\\| command:
+% \begin{quote}
+% |\nr*|\oarg{dist}
+% \end{quote}
+% This command can be used everywhere the command |\\| is allowed.
+%
+% \DescribeMacro{\mrel}
+% The |\mrel|\marg{column} command composes a new math relation symbol
+% from a one-column stack of math formulas described in the \meta{column}
+% parameter. For example, the command |$\mrel{<\\[-.7ex]>}$| produces
+% $\mrel{<\\[-.7ex]>}$.
+%
+% \DescribeMacro{\underrel}
+% The |\underrel|\marg{base}\marg{bottom} command is a twin to
+% the |\overrel| command. For example, the command
+% |$A\underrel{\longrightarrow}{x\to 0}B$| produces
+% $A\underrel{\longrightarrow}{x\to 0}B$.
+%
+% \section{Medium-Size Math Commands}
+%
+% Since version 1.2, a collection of medium-size math commands is
+% introduced.
+%
+% \DescribeMacro{\medmath}
+% The |\medmath|\marg{formula} command decreases a size of formula
+% in 1.2 times and prepares it in the display style. An example:
+% \begin{quote}
+% |$\medmath{\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}}$|\\
+% |\quad $\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}$|
+% \end{quote}
+% It produces:
+% \begin{quote}
+% $\medmath{\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}}$
+% \quad $\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}$
+% \end{quote}
+%
+% \DescribeMacro{\medop}
+% The |\medop|\marg{operator} command prepares a medium-size operator
+% with the required preference for limits. It can be use with |\sum| and
+% others variable-size commands except integrals. An example:
+% \begin{quote}
+% |$\sum_{i=1}^n \medop\sum_{i=1}^n \displaystyle|\\
+% |\sum\nolimits_{i=1}^n$\quad $\sum\limits_{i=1}^n|\\
+% |\displaystyle \medop\sum_{i=1}^n \sum_{i=1}^n$|
+% \end{quote}
+% It produces:
+% \begin{quote}
+% $\sum_{i=1}^n \medop\sum_{i=1}^n \displaystyle \sum\nolimits_{i=1}^n$
+% \quad$\sum\limits_{i=1}^n \displaystyle \medop\sum_{i=1}^n \sum_{i=1}^n$
+% \end{quote}
+%
+% \DescribeMacro{\medint}
+% The |\medint|\marg{operator} command prepares a medium-size integral
+% with required preference for limits. It can be use with |\int|-family
+% of commands and |\oint| command. An example:
+% \begin{quote}
+% |$\int_a^b \medint\int_a^b \displaystyle\int_a^b$\quad|\\
+% |$\int\limits_a^b \medint\int_a^b\limits \displaystyle|\\
+% |\int_a\limits^b$\quad $\iint_a^b \medint\iiint_a^b|\\
+% |\displaystyle\iiiint_a^b$\quad $\iint\limits_X^Y|\\
+% |\medint\iiint_X\limits^Y \displaystyle \iiiint_X^Y\limits$|\\
+% |\quad $\medint\idotsint_X\limits \medint\oint_X^Y$|
+% \end{quote}
+% It produces:
+% \begin{quote}
+% $\int_a^b \medint\int_a^b \displaystyle\int_a^b$\quad
+% $\int\limits_a^b \medint\int_a^b\limits \displaystyle
+% \int_a\limits^b$\quad $\iint_a^b \medint\iiint_a^b
+% \displaystyle\iiiint_a^b$\quad $\iint\limits_X^Y
+% \medint\iiint_X\limits^Y \displaystyle \iiiint_X^Y\limits$
+% \quad $\medint\idotsint_X\limits \medint\oint_X^Y$
+% \end{quote}
+% By the way, the original limits recognizing in |amsmath|
+% multi-integrals is very restrictive: it allows only one |\limits|-like
+% command right after the multi-integral. In this package, the
+% recognizing is improved to work as \TeX's one.
+%
+% \DescribeMacro{\medintcorr}
+% The |\medintcorr|\marg{length} command specifies the value of
+% italic correction for medium integrals. It controls a positioning indices
+% in medium integrals and in multi-integrals. Its default value is |0.5em|.
+%
+% \DescribeMacro{\mfrac}
+% \DescribeMacro{\mbinom}
+% Based on the medium size formulas, the |\mfrac| and |\mbinom| commands
+% are introduced. They are similar to |\frac| and |\binom|. An example:
+% \begin{quote}
+% |$\frac {x+y}{a-b} \mfrac {x+y}{a-b} \dfrac {x+y}{a-b}$\quad|\\
+% |$\binom {n}{k} \mbinom {n}{k} \dbinom {n}{k}$|
+% \end{quote}
+% It produces:
+% \begin{quote}
+% $\frac {x+y}{a-b} \mfrac {x+y}{a-b} \dfrac {x+y}{a-b}$\quad
+% $\binom {n}{k} \mbinom {n}{k} \dbinom {n}{k}$
+% \end{quote}
+%
+% \DescribeMacro{medsize}
+% \DescribeMacro{mmatrix}
+% The |medsize| environment is introduced to prepare formulas and arrays
+% in the medium size. It reduces the |\arraycolsep| value by 0.8~times. Basing
+% on it, the |mmatrix| environment is introduced. It is specified as
+% follows:
+% \begin{quote}
+% |\begin{mmatrix} ... \end{mmatrix}|\quad $\equiv$\quad\\
+% |\begin{medsize}\begin{matrix} ... \end{matrix}\end{medsize}|
+% \end{quote}
+% An example:
+% \begin{quote}
+% |$\bigl(\begin{smallmatrix} a&b\\c&d\end{smallmatrix}\bigr)$|\\
+% |$\Bigl(\begin{mmatrix} a&b\\c&d\end{mmatrix}\Bigr)$|\\
+% |$\begin{pmatrix}a&b\\c&d\end{pmatrix}$|
+% \end{quote}
+% It produces:
+% \begin{quote}
+% $\bigl(\begin{smallmatrix} a&b\\c&d\end{smallmatrix}\bigr)$
+% $\Bigl(\begin{mmatrix} a&b\\c&d\end{mmatrix}\Bigr)$
+% $\begin{pmatrix}a&b\\c&d\end{pmatrix}$
+% \end{quote}
+%
+% \DescribeMacro{mediummath}
+% Finally, the |mediummath| option allows prepare all variable-size
+% math elements in medium size. It redefines |\frac|, |\binom| and
+% all math operators to the medium size. For |\frac| and |\binom|,
+% the medium size is applied in the display and text styles.
+% The |\dfrac|, |\tfrac|, |\dbinom|, and |\tbinom| commands have
+% the old meaning.
+%
+% \section{NCC-\LaTeX\ Equivalents to Display Formulas}
+%
+% The following NCC-\LaTeX\ equivalents are provided with
+% this package:
+% \begin{desclist}{}{\hfill\enskip=}[\com{eqalign*}\marg{formulas}]
+% \raggedright
+% \item[\com{eq}\marg{formula}]
+% |\begin{equation}| \meta{formula} |\end{equation}|.
+%
+% \item[\com{eq*}\marg{formula}]
+% |\begin{equation*}| \meta{formula} |\end{equation*}|.
+%
+% \item[\com{eqs}\marg{formulas}]
+% |\begin{eqnarray}| \meta{formulas} |\end{eqnarray}|.
+%
+% \item[\com{eqs*}\marg{formulas}]
+% |\begin{eqnarray*}| \meta{formulas} |\end{eqnarray*}|.
+%
+% \item[\com{eqalign}\marg{formulas}]
+% |\begin{equation} \begin{darray}{rcl}| \meta{formulas}
+% |\end{darray} \end{equation}|.
+%
+% \item[\com{eqalign*}\marg{formulas}]
+% |\begin{equation*} \begin{darray}{rcl}| \meta{formulas}
+% |\end{darray} \end{equation*}|.
+% \end{desclist}
+%
+% The |\eqs| and |\eqs*| commands have an optional parameter
+% specifying a distance between columns. For example, in the command
+% \begin{quote}
+% \verb+\eqs[0mm]{&& -\Delta u = f, \\ && u|_\Gamma = 0,}+
+% \end{quote}
+% the intercolumn distance is removed because only the 3rd column is
+% used. The |eqnarray| environment has no optional parameter.
+%
+% The |\eqalign| and |\eqalign*| commands also have an optional
+% parameter. Its meaning is the column specification
+% parameter: |\eqalign|\marg{formulas} |=|
+% |\eqalign[rcl]|\marg{formulas}.
+%
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% At first we load the |amsmath| package and pass all options to it
+% except the |mediummath| option.
+% \begin{macrocode}
+%<*package>
+\DeclareOption{mediummath}{\newcommand\NCC@op{}}
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsmath}}
+\ProcessOptions\relax
+\RequirePackage{amsmath}[2000/07/18]
+% \end{macrocode}
+%
+% \subsection{Kernel}
+%
+% \begin{macro}{\NCC@cr}
+% Simplified version of |\\| used in some commands here.
+% The low level command |\NCC@cr@@@|\marg{skip} is defined
+% if necessary to |\NCC@aligncr| or to something else.
+% The |\new@ifnextchar| commands from the \AmS\ does the
+% same as |\@ifnextchar|, but disallows spaces before the
+% tested symbol.
+% \begin{macrocode}
+\newif\ifNCC@star
+\def\NCC@cr{\relax\iffalse{\fi\ifnum0=`}\fi
+ \@ifstar{\global\NCC@startrue\NCC@cr@}{\global\NCC@starfalse\NCC@cr@}%
+}
+\def\NCC@cr@{\new@ifnextchar[\NCC@cr@@{\NCC@cr@@[\z@]}}
+\def\NCC@cr@@[#1]{\ifnum0=`{\fi \iffalse}\fi\NCC@cr@@@{#1}}
+\def\NCC@aligncr#1{\cr\noalign{\vskip #1\relax}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@default@cr}
+% This command sets defaults for the |\\| command.
+% \begin{macrocode}
+\def\NCC@default@cr{\let\\\NCC@cr \let\NCC@cr@@@\NCC@aligncr}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\nr}
+% The |\nr| command has just the same syntax as |\\|
+% but adds 0.5ex extra vertical space between lines.
+% It can work anywhere the |\\| command is allowed.
+% We temporary change in it the value of |\NCC@cr@@@| to
+% |\NCC@nr| and restore it later.
+% \begin{macrocode}
+\newcommand{\nr}{%
+ \let\NCC@temp\NCC@cr@@@
+ \let\NCC@cr@@@\NCC@nr
+ \NCC@cr
+}
+\def\NCC@nr#1{%
+ \let\NCC@cr@@@\NCC@temp
+ \setlength\@tempskipa{#1}\advance\@tempskipa .5ex
+ \ifNCC@star
+ \edef\@tempa{\noexpand\\*[\the\@tempskipa]}%
+ \else
+ \edef\@tempa{\noexpand\\[\the\@tempskipa]}%
+ \fi
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Additional Math Commands}
+%
+% \begin{macro}{\mrel}
+% The |\mrel|\marg{column} command composes a new math relation and
+% vertically centers it with respect to the math line.
+% \begin{macrocode}
+\newcommand{\mrel}{\mathpalette\NCC@rel}
+\def\NCC@rel#1#2{\mathrel{\vcenter{\NCC@default@cr
+ \offinterlineskip \ialign{\hfil$\m@th#1##$\hfil\cr#2\crcr}}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\underrel}
+% The |\underrel|\marg{base}\marg{bottom} command is a twin to
+% |\overrel|.
+% \begin{macrocode}
+\newcommand{\underrel}[2]{\mathrel{\mathop{#1}\limits_{#2}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Medium-Size Math Commands}
+%
+% \begin{macro}{\NCC@select@msize}
+% The |\NCC@select@msize| command prepares dimensions for medium-size math:
+% \begin{itemize}
+% \item In |\NCC@fracrulewidth| --- a rule width in fractions;
+% \item In |@tempdima| --- a raising value; and
+% \item In |@tempdimb| --- a font size to be used in medium fractions
+% and matrices.
+% \end{itemize}
+% \begin{macrocode}
+\newdimen\NCC@fracrulewidth
+\def\NCC@select@msize{\relax
+% \end{macrocode}
+% |\@tempdima| contains the current font size
+% \begin{macrocode}
+ \@tempdima \f@size\p@
+% \end{macrocode}
+% Calculate in |\@tempdimb| a text font size in medium fraction
+% \begin{macrocode}
+ \ifdim\@tempdima>11.5\p@
+ \@tempdimb .83\@tempdima
+ \else
+ \@tempdimb .8\@tempdima
+ \ifdim\@tempdimb<5\p@ \@tempdimb 5\p@\fi
+ \fi
+% \end{macrocode}
+% Calculate in |\NCC@fracrulewidth| the rule width and in
+% |\@tempdima| --- the raising value
+% \begin{macrocode}
+ \NCC@fracrulewidth .04\@tempdima
+ \@tempdima 1.25\NCC@fracrulewidth
+ \ifdim\NCC@fracrulewidth>.45\p@ \else
+ \ifdim\NCC@fracrulewidth>.34\p@ \NCC@fracrulewidth .4\p@
+ \else \NCC@fracrulewidth .3\p@
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@innerfrac}
+% \begin{macro}{\NCC@innerbinom}
+% The |\NCC@innerfrac|\marg{style} prepares a fraction with a
+% special width in the given style:
+% \begin{macrocode}
+\def\NCC@innerfrac#1{\genfrac{}{}\NCC@fracrulewidth{#1}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\NCC@prepare@msize}
+% Select a font by rounding its pt-size to the nearest integer
+% and redefine fractions to have the given rule width. The |\binom|
+% command is redefined also to its original value because it can be
+% changed when the |mediummath| option is applied.
+% \begin{macrocode}
+\def\NCC@prepare@msize{%
+ \@tempdima 1.2\@tempdimb
+ \advance\@tempdimb .5\p@
+ \edef\@tempa{\strip@pt\@tempdimb}%
+ \expandafter\NCC@floor\expandafter\@tempa\@tempa.\@nil
+ \fontsize\@tempa\@tempdima\selectfont
+ \def\frac{\protect\NCC@innerfrac{}}%
+ \def\dfrac{\NCC@innerfrac\z@}%
+ \def\tfrac{\NCC@innerfrac\@ne}%
+ \def\binom{\protect\genfrac()\z@{}}%
+}
+\def\NCC@floor#1#2.#3\@nil{\def#1{#2}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@op@prepare}
+% |\NCC@op@prepare|\marg{integral}
+% command prepares an integral. It looks forward, extracts indices
+% and limits-change commands, and puts the integral with required kerning
+% of indices. The |\NCC@op@print| driver is a command to print the integral.
+% Its default value is |\NCC@op@printm|. The driver uses the following hooks:
+% |\NCC@op| contains an integral command, |\NCC@op@lim| contains
+% the selected limits-style, |\NCC@op@sb| contains a subscript,
+% |\NCC@op@sp| contains a superscript, |NCC@op@kern| contains the
+% kerning value for medium-size integrals. If subscript or superscript
+% is omitted, the corresponding hook is equal to |\relax|.
+% \begin{macrocode}
+\DeclareRobustCommand*\NCC@op@prepare[1]{%
+ \def\NCC@op{#1}%
+ \let\NCC@op@print\NCC@op@printm
+ \NCC@op@prepare@
+}
+\def\NCC@op@prepare@{%
+ \let\NCC@op@lim\ilimits@
+ \let\NCC@op@sp\relax
+ \let\NCC@op@sb\relax
+ \NCC@op@next
+}
+\def\NCC@op@next{\futurelet\@let@token\NCC@op@getnext}
+% \end{macrocode}
+% Test the next token and get it if necessary:
+% \begin{macrocode}
+\def\NCC@op@getnext{%
+ \let\@tempa\NCC@op@skip
+ \ifx\@let@token\limits
+ \let\NCC@op@lim\limits \else
+ \ifx\@let@token\nolimits
+ \let\NCC@op@lim\nolimits \else
+ \ifx\@let@token\displaylimits
+ \let\NCC@op@lim\displaylimits \else
+ \ifx\@let@token\sp
+ \NCC@op@test\NCC@op@sp
+ \def\@tempa{\NCC@op@get\NCC@op@sp}\else
+ \ifx\@let@token\sb
+ \NCC@op@test\NCC@op@sb
+ \def\@tempa{\NCC@op@get\NCC@op@sb}\else
+ \ifx\@let@token\@sptoken
+ \let\@tempa\NCC@op@skipsp \else
+ \let\@tempa\NCC@op@print
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \@tempa
+}
+% \end{macrocode}
+% Skip |\limits|-like token:
+% \begin{macrocode}
+\def\NCC@op@skip#1{\NCC@op@next}
+% \end{macrocode}
+% Skip a space token. A space token is skipped within |\@ifnextchar|
+% before comparing it with the first parameter. So, it does not important
+% what char to test for:
+% \begin{macrocode}
+\def\NCC@op@skipsp{%
+ \@ifnextchar0{\NCC@op@next}{\NCC@op@next}%
+}
+% \end{macrocode}
+% Test subscript or superscript to be already defined:
+% \begin{macrocode}
+\def\NCC@op@test#1{%
+ \ifx#1\relax \else
+ \PackageError{nccmath}{Double index in math operator}{}
+ \fi
+}
+% \end{macrocode}
+% Get a subscript or superscript:
+% \begin{macrocode}
+\def\NCC@op@get#1#2#3{\def#1{#3}\NCC@op@next}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@op@printm}
+% Driver for printing the medium-size integral with indices:
+% \begin{macrocode}
+\def\NCC@op@printm{%
+ \ifx\NCC@op@lim\nolimits \NCC@op@printm@\@ne \else
+ \ifx\NCC@op@lim\limits \NCC@op@printm@\z@ \else
+ \mathchoice{\displaystyle\NCC@op@printm@\z@}%
+ {\textstyle\NCC@op@printm@\@ne}%
+ {\scriptstyle\NCC@op@printm@\@ne}%
+ {\scriptscriptstyle\NCC@op@printm@\@ne}%
+ \fi
+ \fi
+}
+\def\NCC@op@printm@{\NCC@op@print@\NCC@op\NCC@op@kern}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@op@print@}
+% |\NCC@op@print@|\marg{integral}\marg{kern}\marg{level} command
+% prints an \meta{integral} using the specified \meta{kern} in indices.
+% If \meta{level} = 0 use |\limits| else use |\nolimits|.
+% \begin{macrocode}
+\def\NCC@op@print@#1#2#3{\mathop{#1}%
+ \setlength\@tempdima{#2}%
+ \@tempswatrue
+ \ifx\NCC@op@sb\relax \else \ifnum#3>\z@ \@tempswafalse \fi \fi
+ \ifx\NCC@op@sp\relax \else \ifnum#3>\z@ \@tempswafalse \fi \fi
+ \edef\@tempa{%
+ \ifnum#3=\z@ \noexpand\limits \else \noexpand\nolimits \fi
+ \ifx\NCC@op@sb\relax \else
+ \noexpand\sb{%
+ \ifnum#3=\z@ \kern -\@tempdima\else \kern -.8\@tempdima \fi
+ \noexpand\NCC@op@sb}%
+ \fi
+ \ifx\NCC@op@sp\relax \else
+ \noexpand\sp{\ifnum#3=\z@ \kern \@tempdima\fi
+ \noexpand\NCC@op@sp}%
+ \fi
+ \if@tempswa \kern -.2\@tempdima \fi
+ }%
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\medmath}
+% The |\medmath|\marg{formula} prepares a medium-size formula
+% in display style:
+% \begin{macrocode}
+\DeclareRobustCommand*\medmath[1]{\NCC@select@msize
+ \mathord{\raise\@tempdima\hbox{\NCC@prepare@msize
+ $\displaystyle#1$}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\medop}
+% The |\medop|\marg{operator} prepares an operator in the medium size:
+% \begin{macrocode}
+\newcommand*\medop[1]{\DOTSB\mathop{\medmath{#1}}\slimits@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\medintcorr}
+% The |\medintcorr|\marg{length} specifies an italic correction
+% for a medium integral:
+% \begin{macrocode}
+\newcommand*\medintcorr[1]{\def\NCC@op@kern{#1}}
+\medintcorr{.5em}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\medint}
+% The |\medint|\marg{integral} command prepares a medium integral:
+% \begin{macrocode}
+\newcommand*\medint[1]{\DOTSI\NCC@op@prepare{\medmath{#1}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\mfac}
+% The |\mfrac|\marg{numerator}\marg{denominator} prepares
+% a medium-size fraction:
+% \begin{macrocode}
+\DeclareRobustCommand*\mfrac[2]{\medmath{\frac{#1}{#2}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\mbinom}
+% The |\mbinom|\marg{numerator}\marg{denominator} prepares
+% a medium-size binomial expression:
+% \begin{macrocode}
+\DeclareRobustCommand*\mbinom[2]{%
+ \Bigl(\medmath{\genfrac{}{}{\z@}{}{#1}{#2}}\Bigr)%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{medsize}
+% The |medsize| environment is useful for preparing medium-size arrays:
+% \begin{macrocode}
+\newenvironment{medsize}{\NCC@select@msize
+ \mathord\bgroup
+ \raise\@tempdima\hbox\bgroup\NCC@prepare@msize
+ \arraycolsep .8\arraycolsep $}{$\egroup\egroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{mmatrix}
+% The |mmatrix| environment prepares a medium-size matrix:
+% \begin{macrocode}
+\newenvironment{mmatrix}{\medsize\begin{matrix}}{\end{matrix}\endmedsize}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Patches to amsmath}
+%
+% \begin{macro}{\MultiIntegral}
+% Improve the |\MultiIntegral| kerning method on the base of
+% |\NCC@op@prepare@| hook. The original method from |amsmath| works
+% bad if a multi-integral is an argument of the |\medint| command.
+% \begin{macrocode}
+\renewcommand*{\MultiIntegral}[1]{%
+ \edef\NCC@op{\noexpand\intop
+ \ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi
+ \ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi
+ \ifnum#1>\thr@@\noexpand\intop\noexpand\intkern@\fi
+ \noexpand\intop
+ }%
+ \let\NCC@op@print\NCC@op@printd
+ \NCC@op@prepare@
+}
+\def\NCC@op@printd{%
+ \setlength\@tempdima{\NCC@op@kern}%
+ \ifx\NCC@op@lim\nolimits \@tempcnta\@ne \else
+ \ifx\NCC@op@lim\limits \@tempcnta\z@ \else
+ \@tempcnta\m@ne
+ \fi
+ \fi
+ \mathchoice{\NCC@op@printd@{\displaystyle}{1.2\@tempdima}}%
+ {\NCC@op@printd@{\textstyle}{.8\@tempdima}}%
+ {\NCC@op@printd@{\scriptstyle}{.8\@tempdima}}%
+ {\NCC@op@printd@{\scriptscriptstyle}{.8\@tempdima}}%
+}
+\def\NCC@op@printd@#1#2{#1%
+ \ifnum\@tempcnta>\m@ne
+ \NCC@op@print@{\hbox{$#1\NCC@op$}}{#2}\@tempcnta
+ \else
+ \ifx#1\displaystyle
+ \NCC@op@print@{\hbox{$#1\NCC@op$}}{#2}\z@
+ \else
+ \NCC@op@print@{\hbox{$#1\NCC@op$}}{#2}\@ne
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\endmathdisplay@a}
+% Fix the bug in the |\endmathdisplay@a| command
+% from the |amsmath| package. The |\displaybreak| has no effect in
+% it if a tag is specified. This is because the change
+% of |\postdisplaypenalty| is done after the |\eqno| command.
+% But the rest of display formula after |\eqno| up to the |$$|
+% command belongs to the tag. It is prepared in the horizontal mode
+% and the mentioned penalty is ignored. Fixed version of
+% this command at first changes the |\postdisplaypenalty| and
+% after that prints a tag.
+%
+% To be sure, that the required command does not fixed yet,
+% we prepare its bug version in the |\@tempa| command
+% \begin{macrocode}
+\def\@tempa{%
+ \if@eqnsw \gdef\df@tag{\tagform@\theequation}\fi
+ \if@fleqn \@xp\endmathdisplay@fleqn
+ \else \ifx\df@tag\@empty \else \veqno \alt@tag \df@tag \fi
+ \ifx\df@label\@empty \else \@xp\ltx@label\@xp{\df@label}\fi
+ \fi
+ \ifnum\dspbrk@lvl>\m@ne
+ \postdisplaypenalty -\@getpen\dspbrk@lvl
+ \global\dspbrk@lvl\m@ne
+ \fi
+}
+% \end{macrocode}
+% and compare it with the current value of |\endmathdisplay@a|.
+% If they are identic, we fix the last command. Otherwise,
+% print a warning and do nothing.
+% \begin{macrocode}
+\ifx\@tempa\endmathdisplay@a
+ \def\endmathdisplay@a{%
+ \ifnum\dspbrk@lvl>\m@ne
+ \postdisplaypenalty -\@getpen\dspbrk@lvl
+ \global\dspbrk@lvl\m@ne
+ \fi
+ \if@eqnsw \gdef\df@tag{\tagform@\theequation}\fi
+ \if@fleqn \@xp\endmathdisplay@fleqn
+ \else \ifx\df@tag\@empty \else \veqno \alt@tag \df@tag \fi
+ \ifx\df@label\@empty \else \@xp\ltx@label\@xp{\df@label}\fi
+ \fi
+ }
+\else
+ \PackageWarning{nccmath}%
+ {The \string\endmathdisplay@a\ command differs from\MessageBreak
+ waited value in this version of amsmath package.\MessageBreak
+ We don't fix it!}
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\intertext}
+% Redefine \AmS's |\intertext|\marg{text} to
+% |\intertext|\oarg{skip}\marg{text}. Optional \meta{skip} means
+% the vertical space inserted below and after the text. If it is
+% omitted, the default |\belowdisplayskip| and |\abovedisplayskip|
+% spaces are inserted.
+%
+% We need to redefine its default value used out of display
+% equations:
+% \begin{macrocode}
+\renewcommand*{\intertext}[1][]{\@amsmath@err{\Invalid@@\intertext}\@eha}
+% \end{macrocode}
+% and also must redefine the |\intertext@| hook that changes the
+% value of |\intertext| within display equations. Its new
+% definition differs from the original one in the conditional
+% inserting of skips before and after the text.
+% The optional parameter is scanned inside the |\noalign|
+% command. We use the ordinary trick with the |\ifnum0| to
+% close the open brace in the next macro.
+% \begin{macrocode}
+\def\intertext@{%
+ \def\intertext{%
+ \ifvmode\else\\\@empty\fi
+ \noalign{\ifnum0=`}\fi
+ \@ifnextchar[{\NCC@intertext}{\NCC@intertext[]}%
+ }%
+}
+\def\NCC@intertext[#1]#2{%
+ \penalty\postdisplaypenalty
+ \@ifempty{#1}{\vskip\belowdisplayskip}{\vskip#1\relax}%
+ \vbox{\normalbaselines
+ \ifdim\linewidth=\columnwidth
+ \else \parshape\@ne \@totalleftmargin \linewidth
+ \fi
+ \noindent#2\par}%
+ \penalty\predisplaypenalty
+ \@ifempty{#1}{\vskip\abovedisplayskip}{\vskip#1\relax}%
+ \ifnum0=`{\fi}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\useshortskip}
+% The |\useshortskip| command changes an above skip for nearest
+% display formula to |\abovedisplayshortskip|. Really, it
+% sets the value of inner if-macro to true and the
+% actual changes are applied in the |\NCC@ignorepar| hook.
+% \begin{macrocode}
+\newif\ifNCC@shortskip \NCC@shortskipfalse
+\newcommand{\useshortskip}{\global\NCC@shortskiptrue}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@ignorepar}
+% This command removes extra vertical space before display formula
+% if it starts from a new paragraph and changes the before-skip
+% to |\abovedisplayshortskip| if the |\useshortskip|
+% command was applied.
+% \begin{macrocode}
+\def\NCC@ignorepar{\relax
+ \ifNCC@shortskip
+ \abovedisplayskip\abovedisplayshortskip
+ \global\NCC@shortskipfalse
+ \fi
+ \ifmmode \else \ifvmode
+% \end{macrocode}
+% If a display equation starts in the vertical mode, we
+% insert the vertical space with the |\addvspace| (this
+% space will be ignored at the beginning of minipage)
+% and set above display skips to zero. The below display
+% skips are made equal. Then we put the |\noindent|
+% command that prevents insertion an empty paragraph.
+% \begin{macrocode}
+ \addvspace{\abovedisplayskip}%
+ \abovedisplayskip\z@skip
+ \abovedisplayshortskip\z@skip
+ \belowdisplayshortskip\belowdisplayskip
+ \noindent
+ \fi\fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Now we insert the |\NCC@ignorepar| command at the
+% beginning of all \LaTeX\ and \AmS-\LaTeX\ display equations
+% except |eqnarray|. We need to correct four \AmS\ commands only:
+% \begin{macrocode}
+\let\NCC@startgather\start@gather
+\let\NCC@startalign\start@align
+\let\NCC@startmultline\start@multline
+\let\NCC@startdisplay\mathdisplay
+\def\start@gather{\NCC@ignorepar\NCC@startgather}
+\def\start@align{\ifingather@\else\NCC@ignorepar\fi\NCC@startalign}
+\def\start@multline{\NCC@ignorepar\NCC@startmultline}
+\def\mathdisplay{\NCC@ignorepar\NCC@startdisplay}
+% \end{macrocode}
+%
+% \subsection{The darray Environment}
+%
+% \begin{macro}{darray}
+% The implementation of |darray| is a hybrid of the
+% |\start@aligned| command from the |amsmath| package
+% and the |\array| command.
+% \begin{macrocode}
+\newenvironment{darray}[2][c]{%
+ \null\,%
+ \if #1t\vtop \else \if#1b \vbox \else \vcenter \fi \fi
+ \bgroup
+ \NCC@default@cr
+ \spread@equation
+ \NCC@mkpream{#2}%
+ \edef\@preamble{\ialign \bgroup \strut@ \@preamble \tabskip\z@skip \cr}%
+ \let\par\@empty \let\@sharp##%
+ \set@typeset@protect
+ \tabskip\z@skip
+ \@preamble
+}{%
+ \crcr\egroup\egroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@mkpream}
+% The |darray| environment
+% is independent from |array| to avoid conflicts with
+% packages customizing the |array| environment. So,
+% we need to implement an independent preamble maker.
+%
+% The following classes can appear in the preamble:
+% \begin{quote}
+% 0\enskip |lcr|\\
+% 1\enskip |@|-argument\\
+% 2\enskip |@|
+% \end{quote}
+% The implementation of preamble maker is very similar to the
+% \LaTeX's version.
+% \begin{macrocode}
+\def\NCC@mkpream#1{%
+ \@lastchclass\@ne \@firstamptrue
+% \end{macrocode}
+% Specify the default distance between columns in
+% the |\alignsep@| register from |amsmath|.
+% \begin{macrocode}
+ \settowidth\alignsep@{$\m@th\mskip\thickmuskip$}%
+ \let\@sharp\relax
+ \let\@preamble\@empty
+% \end{macrocode}
+% The |\@xexpast| command expands the argument replacing
+% all instances of\linebreak |*|\marg{N}\marg{string}
+% by \meta{N} copies of \meta{string}. The result is saved in
+% the |\reserved@a| macro. But this command is let to |\relax|
+% in the |array| package. So, we use its original definition prepared
+% in the |\NCC@xexpast| macro to avoid conflicts with other
+% packages.
+% \begin{macrocode}
+ \let\protect\@unexpandable@protect
+ \NCC@xexpast #1*0x\@@
+% \end{macrocode}
+% Now we make the preamble collecting it in the |\@preamble| hook.
+% The code is very similar to the \LaTeX's |\@mkpream| command.
+% \begin{macrocode}
+ \expandafter \@tfor \expandafter \@nextchar
+ \expandafter :\expandafter =\reserved@a \do
+ {\@chclass
+ \ifnum \@lastchclass=\tw@ \@ne \else
+ \z@
+ \edef\@nextchar{\expandafter\string\@nextchar}%
+ \if \@nextchar @\@chclass \tw@ \else
+ \@chnum
+ \if \@nextchar c\z@ \else
+ \if \@nextchar l\@ne \else
+ \if \@nextchar r\tw@ \else
+ \z@ \@preamerr \z@
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \ifcase \@chclass
+ \ifnum \@lastchclass=\z@ \@addtopreamble{\hskip \alignsep@}\fi
+ \@addamp
+ \@addtopreamble{%
+ \ifcase \@chnum \hfil$\displaystyle{\@sharp}$\hfil
+ \or $\displaystyle{\@sharp}$\hfil
+ \or \hfil$\displaystyle{\@sharp}$%
+ \fi
+ }%
+ \or
+ \@addtopreamble{$\@nextchar$}%
+ \fi
+ \@lastchclass\@chclass
+ }%
+ \ifnum\@lastchclass=\tw@ \@preamerr\@ne \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@xexpast}
+% The standard \LaTeX's |\@xexpast| macro is saved here:
+% \begin{macrocode}
+\def\NCC@xexpast#1*#2#3#4\@@{%
+ \edef\reserved@a{#1}%
+ \@tempcnta#2\relax
+ \ifnum\@tempcnta>\z@
+ \@whilenum\@tempcnta>\z@\do
+ {\edef\reserved@a{\reserved@a#3}\advance\@tempcnta \m@ne}%
+ \let\reserved@b\NCC@xexpast
+ \else
+ \let\reserved@b\NCC@xexnoop
+ \fi
+ \expandafter\reserved@b\reserved@a #4\@@
+}
+\def\NCC@xexnoop #1\@@{}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{NCC Equations}
+%
+% \begin{macro}{fleqn}
+% \begin{macro}{ceqn}
+% The implementation of these environments is streightforward:
+% change the |\if@fleqn| flag and the |\@mathmargin| value:
+% \begin{macrocode}
+\newenvironment*{fleqn}[1][\z@]{\@fleqntrue
+ \setlength\@mathmargin{#1}\ignorespaces
+}{%
+ \ignorespacesafterend
+}
+\newenvironment{ceqn}{\@fleqnfalse
+ \@mathmargin\@centering \ignorespaces
+}{%
+ \ignorespacesafterend
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\eq}
+% The implementation of the NCC-\LaTeX's |\eq| command
+% is quite simple:
+% \begin{macrocode}
+\newcommand{\eq}{\@ifstar{\NCC@eqx}{\NCC@eq}}
+\def\NCC@eqx#1{\begin{equation*}#1\end{equation*}}
+\def\NCC@eq#1{\begin{equation}#1\end{equation}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\eqalign}
+% The |\eqalign| command is based on the |equation|
+% and |darray| environments:
+% \begin{macrocode}
+\newcommand{\eqalign}{%
+ \@ifstar{\let\@tempa\NCC@eqx \NCC@eqa}%
+ {\let\@tempa\NCC@eq \NCC@eqa}%
+}
+\newcommand*{\NCC@eqa}[2][rcl]{%
+ \@tempa{\begin{darray}{#1}#2\end{darray}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\eqs}
+% \begin{macro}{eqnarray}
+% The difference between the |\eqs| command and the |eqnarray|
+% environment consists in optional length parameters allowed
+% in |\eqs|. All these commands are based on |\NCC@beqs| and
+% |\NCC@eeqs| macros.
+% \begin{macrocode}
+\newcommand{\eqs}{\@ifstar{\st@rredtrue\NCC@eqs}{\st@rredfalse \NCC@eqs}}
+\newcommand*{\NCC@eqs}[2][]{%
+ \begingroup\NCC@beqs{#1}#2\NCC@eeqs\endgroup\ignorespaces
+}
+\renewenvironment{eqnarray}{\st@rredfalse\NCC@beqs{}}
+ {\NCC@eeqs\ignorespacesafterend}
+\renewenvironment{eqnarray*}{\st@rredtrue\NCC@beqs{}}
+ {\NCC@eeqs\ignorespacesafterend}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\NCC@beqs}
+% The |\NCC@beqs|\marg{skip} starts eqnarray-like equations.
+% The \meta{skip} parameter specifies a skip inserted
+% between columns. If it is empty, the default value of this skip
+% is used. It equals to the thick skip appearing in relations.
+% The implementation of this macro uses hooks from the
+% |amsmath| package.
+% \begin{macrocode}
+\def\NCC@beqs#1{%
+ \NCC@ignorepar$$
+ \inalign@true \intertext@ \displ@y@ \Let@
+ \chardef\dspbrk@context\z@
+ \let\math@cr@@@\NCC@eqcr \let\tag\tag@in@align
+ \let\label\label@in@display \let\split\insplit@
+ \ifst@rred\else \global\@eqnswtrue \fi
+ \tabskip\@mathmargin
+ \@ifempty{#1}{\settowidth\alignsep@{$\m@th\mskip\thickmuskip$}}%
+ {\setlength\alignsep@{#1}}%
+ \halign to \displaywidth\bgroup
+ \strut@ \global\column@\z@ \hfil$\displaystyle{##}$\tabskip\z@skip
+ &\column@plus \hskip\alignsep@ \hfil$\displaystyle{##}$\hfil
+ &\column@plus \hskip\alignsep@ $\displaystyle{##{}}$\hfil
+ \tabskip\@centering
+ &\column@plus \llap{##}\tabskip\z@skip\cr
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@eqcr}
+% The |\NCC@eqcr| hook is called at the end of line of the
+% |eqnarray|. It is originated on \LaTeX's |\@eqncr| command, but
+% uses commands from |amsmath| to prepare a tag in the \AmS\ style.
+% \begin{macrocode}
+\def\NCC@eqcr{%
+ \let\@tempa\relax
+ \ifcase\column@ \def\@tempa{&&&}\or \def\@tempa{&&}\or\def\@tempa{&}%
+ \else
+ \let\@tempa\@empty
+ \@latex@error{Too many columns in eqnarray environment}\@ehc
+ \fi
+ \@tempa
+ \ifst@rred\nonumber\fi
+ \if@eqnsw \global\tag@true \fi
+ \iftag@ \@lign\strut@
+ \iftagsleft@ \rlap{\hskip -\displaywidth\make@display@tag}%
+ \else \make@display@tag \fi
+ \fi
+ \ifst@rred\else\global\@eqnswtrue\fi
+ \cr
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@eeqs}
+% This macro finishes eqnarray-like equations.
+% \begin{macrocode}
+\def\NCC@eeqs{\math@cr\egroup$$}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Math with medium fractions and operators}
+%
+% Finally, we process the |mediummath| option. It is recognized by
+% the |\NCC@op| command to be specified.
+% \begin{macrocode}
+\@ifundefined{NCC@op}{\endinput}{}
+% \end{macrocode}
+%
+% Redifine fractions and binoms.
+% \begin{macrocode}
+\DeclareRobustCommand\frac{\NCC@op@select\mfrac{\genfrac{}{}{}{}}}
+\DeclareRobustCommand\binom{\NCC@op@select\mbinom{\genfrac()\z@{}}}
+\def\NCC@op@select#1#2#3#4{%
+ \mathchoice{#1{#3}{#4}}{#1{#3}{#4}}%
+ {\scriptstyle#2{#3}{#4}}{\scriptscriptstyle#2{#3}{#4}}%
+}
+% \end{macrocode}
+%
+% Redefine all math operators except integrals:
+% \begin{macrocode}
+\def\@tempa#1#2{%
+ \ifx#2\@undefined \let#2#1\fi
+ \def#1{\DOTSB\medop{#2}}%
+}
+\@tempa \coprod \coprod@
+\@tempa \bigvee \bigvee@
+\@tempa \bigwedge \bigwedge@
+\@tempa \biguplus \biguplus@
+\@tempa \bigcap \bigcap@
+\@tempa \bigcup \bigcup@
+\@tempa \prod \prod@
+\@tempa \sum \sum@
+\@tempa \bigotimes \bigotimes@
+\@tempa \bigoplus \bigoplus@
+\@tempa \bigodot \bigodot@
+\@tempa \bigsqcup \bigsqcup@
+% \end{macrocode}
+%
+% Redefine integrals:
+% \begin{macrocode}
+\def\@tempa#1#2#3{\let#3#2%
+ \DeclareRobustCommand#2{\mathop{\medmath{#3}}}%
+ \def#1{\DOTSI\NCC@op@prepare{#2}}%
+}
+\@tempa\int \intop \NCC@op@int
+\@tempa\oint \ointop \NCC@op@oint
+\let\@tempa\relax
+% \end{macrocode}
+%
+% Redefine multiple integrals:
+% \begin{macrocode}
+\renewcommand*{\MultiIntegral}[1]{%
+ \edef\NCC@op{\noexpand\intop
+ \ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi
+ \ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi
+ \ifnum#1>\thr@@\noexpand\intop\noexpand\intkern@\fi
+ \noexpand\intop
+ }%
+ \let\NCC@op@print\NCC@op@printm
+ \NCC@op@prepare@
+}
+\def\intkern@{\kern-\NCC@op@kern}
+\def\intdots@{\setlength\@tempdima{\NCC@op@kern}%
+ \kern-.4\@tempdima{\cdotp}\mkern1.5mu{\cdotp}%
+ \mkern1.5mu{\cdotp}\kern-.4\@tempdima}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccparskip.dtx b/Master/texmf-dist/source/latex/ncctools/nccparskip.dtx
new file mode 100644
index 00000000000..24ac87568d3
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccparskip.dtx
@@ -0,0 +1,84 @@
+% \iffalse
+%%
+%% File: nccparskip.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{nccparskip}
+%<package> [2004/12/08 v1.1 Parskip Control Package (NCC)]
+%
+% \changes{v1.01}{2002/01/09}{This version is uploaded to CTAN}
+% \changes{v1.02}{2002/02/07}{The package is renamed to nccparskip}
+% \changes{v1.1}{2004/12/08}{Documentation was prepared}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nccparskip}
+\SetParskip{6pt plus 1pt minus .4pt}
+\GetFileInfo{nccparskip.sty}
+\begin{document}
+\title{The \textsf{nccparskip} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccparskip.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \DescribeMacro{\SetParskip}
+% The package provides identical distance between all paragraphs except
+% section markups. It redefines control list commands and suppress
+% |\topskip|, |\partopskip|, and |\itemsep| in lists. As a result, the distance
+% between ordinary paragraphs and paragraphs prepared by lists is the same.
+% The command |\SetParskip|\marg{distance} controls this distance.
+% The default distance is
+% \begin{quote}
+% |\SetParskip{4pt plus 1pt minus .2pt}|
+% \end{quote}
+% In this document, we use |\SetParskip{6pt plus 1pt minus .4pt}|.
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% \begin{macro}{\SetParskip}
+% Define the command and set list skips to zero length.
+% \begin{macrocode}
+%<*package>
+\newcommand*{\SetParskip}[1]{\setlength{\parskip}{#1}\parsep\parskip}
+\partopsep\z@
+\topsep\z@
+\itemsep\z@
+% \end{macrocode}
+% \end{macro}
+%
+% We suppose that list definitions were done in the similar way as
+% in standard \LaTeX\ classes. Redefine list control commands:
+% \begin{macrocode}
+\def\@listi{\leftmargin\leftmargini}
+\let\@listI\@listi
+\def\@listii{\leftmargin\leftmarginii
+ \labelwidth\leftmarginii \advance\labelwidth-\labelsep}
+\def\@listiii{\leftmargin\leftmarginiii
+ \labelwidth\leftmarginiii \advance\labelwidth-\labelsep}
+% \end{macrocode}
+%
+% Redefine the |\normalsize|, |\small|, and |\footnotesize|
+% commands to avoid the |\@listi| redefinition in them.
+% \begin{macrocode}
+\let\NCC@normalsize\normalsize
+\def\normalsize{\let\NCC@temp\@listi\NCC@normalsize\let\@listi\NCC@temp}
+\let\NCC@small\small
+\def\small{\let\NCC@temp\@listi\NCC@small\let\@listi\NCC@temp}
+\let\NCC@footnotesize\footnotesize
+\def\footnotesize{\let\NCC@temp\@listi\NCC@footnotesize\let\@listi\NCC@temp}
+% \end{macrocode}
+%
+% Finally we set defaults:
+% \begin{macrocode}
+\normalsize
+\SetParskip{4pt plus 1pt minus .2pt}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccpic.dtx b/Master/texmf-dist/source/latex/ncctools/nccpic.dtx
new file mode 100644
index 00000000000..37cd498e7ed
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccpic.dtx
@@ -0,0 +1,253 @@
+% \iffalse
+%%
+%% File: nccpic.dtx Copyright (C) 2002--2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+%<package>\ProvidesPackage{nccpic}
+%<package> [2005/03/06 v1.2 NCC Extention of Graphicx (NCC)]
+%
+% \changes{v1.01}{2002/01/23}{This version is uploaded to CTAN}
+% \changes{v1.02}{2002/02/17}{All options are passed to graphicx}
+% \changes{v1.03}{2002/03/20}{|\draftgraphics| and |\finalgraphics| introduced}
+% \changes{v1.04}{2004/09/04}{Patch for bounding box calculation}
+% \changes{v1.1}{2004/12/09}{Documentation was prepared}
+% \changes{v1.2}{2005/03/06}{Correct extension lists}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nccpic,desclist}
+\GetFileInfo{nccpic.sty}
+\begin{document}
+\title{The \textsf{nccpic} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccpic.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \section{User Interface}
+%
+% The package is considered as an extension of the |graphicx| package.
+% It passes all options to the |graphicx| and customizes graphics
+% extensions list for most popular drivers, namely |dvips| and |dvidpf|.
+%
+% This allows us omit an extension of a graphics file in the
+% |\includegraphics| command. When a file without extension is searched,
+% this command sequentially tries extensions from the list of extensions
+% until an appropriate file will be found.
+%
+% Using this feature, you can support multiple output from a \LaTeX\
+% document with minimum changes in |.tex| sources. The only required
+% thing is to prepare a number of versions for all graphics files
+% used in the document. For example, the |dvips| program and YAP previewer
+% like |.eps| and |.bmp| files, and the |pdftex| likes |.png| files. To
+% satisfy their needs, you can prepare the |.eps| or |.bmp| version
+% of all pictures for use with dvips and the |.png| version for use with
+% |pdftex|. Then, when you translate your source file with the |latex|
+% command, the |.eps| or |.bmp| versions of graphics files are used.
+% But when you translate your source file with the |pdflatex| command,
+% the |.png| versions of graphics files are used.
+%
+% The next aim of this package is the regulation of
+% placement of graphics files in the file system. It is the bad idea
+% to place graphics together with \LaTeX\ sources, especially when
+% your prepare a book containing many pictures. It will be much better
+% if graphics will be stored in a subdirectory relative to the
+% base directory of your \LaTeX\ sources.
+% We propose to store graphics files in the
+% |graphics| subdirectory of the source directory. To support
+% the search in this storage, the graphics path is customized in
+% this package.
+%
+% \DescribeMacro\ipic
+% The graphics in \LaTeX\ can be prepared at least in two ways:
+% as an external graphics file included with the |\includegraphics|
+% command or its analogue; as a \LaTeX\ |picture| environment
+% or its analogues provided with special graphics packages.
+% In the last case, the placing a picture inside a \LaTeX\ source
+% file is inconvenient. It will be better to put a \LaTeX\ picture
+% in a separate file and include it using the |\input| command.
+% The next step is to place such pictures together with other
+% graphics material into the |graphics| subdirectory and load them using
+% the |\ipic|\marg{filename} command. This command appends
+% the \meta{filename} with the |.pic| extension and tries to load
+% the `\meta{filename}|.pic|' file at first from the base directory
+% of your document and then from the |graphics| subdirectory.
+%
+% \DescribeMacro\draftgraphics
+% \DescribeMacro\finalgraphics
+% The |\draftgraphics| and |\finalgraphics| commands respectively
+% set the draft and final modes for graphics inclusion with the
+% |\includegraphics| command. They are analogues for the |draft|
+% and |final| options of the |graphics| package. But the commands
+% allow more flexible control of graphics mode especially for
+% document classes including this package by default (the |ncc|
+% class from NCC-\LaTeX\ does this).
+% A graphics file included in the draft
+% mode is shown as a rectangle containing the name of graphics file.
+% This is quite useful on the stage of editing a document.
+%
+% \DescribeMacro\putimage
+% The following command includes a graphics file using the
+% |\includegraphics| command. It is provided for compatibility with
+% old NCC-\LaTeX:
+% \begin{quote}
+% |\putimage(|$x$|,|$y$|)[|$x_{\rm real}$|,|$y_{\rm real}$|](|$x_{\rm shift}$|,|$y_{\rm shift}$|)|\marg{filename}
+% \end{quote}
+% Here:
+% \begin{desclist}{}{\hfill}[\tt($x_{\rm shift}$,$y_{\rm shift}$)]
+% \item[\meta{filename}] is a name of graphics file;
+%
+% \item[\tt($x$,$y$)] are dimensions (in |\unitlength|) of the prepared image box;
+%
+% \item[\tt{[$x_{\rm real}$,$y_{\rm real}$]}] are dimensions (in |\unitlength|)
+% of graphics file that are passed to the |\includegraphics| command;
+%
+% \item[\tt($x_{\rm shift}$,$y_{\rm shift}$)] are shifts (in |\unitlength|)
+% of the graphics image with respect to the image box.
+% \end{desclist}
+% The |(|$x$|,|$y$|)| and \meta{filename} parameters are required. Others
+% are optional. If the |[|$x_{\rm real}$|,|$y_{\rm real}$|]| parameter is
+% omitted, $x_{\rm real}:=x$ and $y_{\rm real}:=y$. If the
+% |(|$x_{\rm shift}$|,|$y_{\rm shift}$|)| parameter is omitted, the shift values
+% are set to zero.
+%
+% The |\putimage| command vertically aligns the image box in the different
+% way than the |\includegraphics|. The first one lowers the box in such a way
+% to align its top edge with the top edge of letter `A' of the current font.
+% But the last one aligns the bottom edge of graphics on the baseline.
+%
+% Other distinction between these commands consists in their work in the
+% draft mode. The |\putimage| command does not test a required graphics
+% file on existence and puts the filename at the center of bounding
+% rectangle. But the |\includegraphics| searches the graphics file
+% and puts the filename at the left top corner of bounding rectangle.
+%
+% In version 1.04 of this package, we add a patch to the |graphics| package.
+% The reason of this patch is the following.
+% In latest versions of the MiKTeX, graphics rules
+% are specified for many graphics formats. As a result, if a bounding
+% box is not specified in parameters of the |\includegraphics| command,
+% a file with |.bb| extension is tested on the ps-like bounding box
+% specification. If such file does not exist, the |\includegraphics| command
+% fails even if its parameters exactly specify the graphics width and height.
+% We have changed the unconditional testing of the bounding box
+% to the conditional one: testing is applied if the required file exists,
+% otherwise, this operation is ignored.
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% Load required packages. We use some features of the |nccboxes| package
+% in the |\putimage| command: the |\Strut| and |\jvbox| commands.
+% \begin{macrocode}
+%<*package>
+\RequirePackageWithOptions{graphicx}[1999/02/16]
+\RequirePackage{nccboxes}[2002/01/09]
+% \end{macrocode}
+%
+% Customize extension lists for |dvips| and |dvipdf|% drivers.
+% \begin{macrocode}
+\def\@tempa{dvips.def}
+\ifx\Gin@driver\@tempa
+ \DeclareGraphicsExtensions{.eps,.ps,.eps.gz,.ps.gz,.eps.Z,%
+ .bmp,.msp,.pcx,.pict,.pntg}
+\else
+ \def\@tempa{dvipdf.def}
+ \ifx\Gin@driver\@tempa
+ \DeclareGraphicsExtensions{.eps,.ps,.eps.gz,.ps.gz,.eps.Z,%
+ .bmp,.msp,.jpg}
+ \fi
+\fi
+% \end{macrocode}
+%
+% Set the path list for search graphics files. It is not necessary to
+% set the base directory in the list, because it is always searched
+% first and the search in the graphics path list is applied only if
+% the search in the base directory fails.
+% \begin{macrocode}
+\graphicspath{{graphics/}}
+% \end{macrocode}
+%
+% \begin{macro}{\draftgraphics}
+% \begin{macro}{\finalgraphics}
+% Specify graphics mode control commands:
+% \begin{macrocode}
+\newcommand\draftgraphics{\Gin@drafttrue}
+\newcommand\finalgraphics{\Gin@draftfalse}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ipic}
+% The |\ipic|\marg{filename} command is equivalent to
+% |\input{|\meta{filename}|.pic}| command with search in
+% the directory list specified by the |\graphicspath|.
+% The file is opened within a group and the beginning and
+% final spaces are removed in it.
+% \begin{macrocode}
+\newcommand*{\ipic}[1]{%
+ \begingroup \let\input@path\Ginput@path
+ \ignorespaces\input{#1.pic}\unskip
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\putimage}
+% Introduce the |\putimage| command. Using the empty definition
+% we ensure the command was undefined before.
+% \begin{macrocode}
+\newcommand{\putimage}{}
+\def\putimage(#1,#2){%
+ \@ifnextchar[{\NCC@Gim(#1,#2)}{\NCC@Gim(#1,#2)[#1,#2]}%
+}
+\def\NCC@Gim(#1,#2)[#3,#4]{%
+ \ifGin@draft
+ \def\NCC@temp(##1,##2)##3{%
+ \edef\@tempa{##3}%
+ \put(0,0){%
+ \framebox(#1,#2){\ttfamily\expandafter\strip@prefix\meaning\@tempa}%
+ }%
+ }%
+ \else
+ \def\NCC@temp(##1,##2)##3{%
+ \put(##1,##2){%
+ \includegraphics[width=#3\unitlength,height=#4\unitlength]{##3}%
+ }%
+ }%
+ \fi
+ \@ifnextchar({\NCC@Gim@(#1,#2)}{\NCC@Gim@(#1,#2)(0,0)}%
+}
+\def\NCC@Gim@(#1,#2)(#3,#4)#5{%
+ \jvbox{\Strut}[t]{%
+ \begin{picture}(#1,#2)\NCC@temp(#3,#4){#5}\end{picture}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gin@setfile}
+% The patch to the |\Gin@setfile| command slightly
+% changes its behaviour: if bounding box calculations are
+% required and the corresponding graphics rule contains an extension
+% of file for reading the bounding box info, we skip the reading
+% of given file if it does not exist.
+% \begin{macrocode}
+\let\NCC@Ginsetfile\Gin@setfile
+\def\Gin@setfile#1#2{%
+ \ifGin@bbox\else
+ \ifx\\#2\\\else
+ \IfFileExists{\Gin@base#2}{}{\Gread@false}%
+ \fi
+ \fi
+ \NCC@Ginsetfile{#1}{#2}%
+}
+%</package>
+% \end{macrocode}
+% \end{macro}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccrules.dtx b/Master/texmf-dist/source/latex/ncctools/nccrules.dtx
new file mode 100644
index 00000000000..3e613426a5d
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccrules.dtx
@@ -0,0 +1,397 @@
+% \iffalse
+%%
+%% File: nccrules.dtx Copyright (C) 2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{nccrules}
+%<package> [2005/05/13 v1.0 More rules (NCC)]
+%
+% \changes{v1.0}{2005/05/13}{This version was uploaded to CTAN}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nccrules}
+\newfootnoterule{starred}{\mboxfill[1.5\width][s]{$*$}}
+\newfootnoterule{dotted}{\mboxfill[2\width][s]{.}}
+\newfootnotedashrule{double}{}{.4 1 .4}
+\newfootnotedashrule{dashed}{3 3}{.4}
+\newfootnotedashrule{dotdashed}{4 2 1 2 4 -4}{.6}
+\newfootnotedashrule{ddotdashed}{6 2 1 2 1 2 6 -6}{.6}
+\GetFileInfo{nccrules.sty}
+\begin{document}
+\title{The \textsf{nccrules} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccrules.dtx}
+\end{document}
+%</driver>
+% \fi
+% This package implements
+% |\dashrule| and |\dashrulefill| commands,
+% that simplify composing of dashed
+% lines and dashed multilines. Two kinds of footnote rule generation
+% commands are also introduced: |\newfootnoterule| creates a footnote
+% rule with an arbitrary contents and |\newfootnotedashrule| creates
+% a footnote rule based on dash rule.
+%
+% \section{User Interface}
+%
+% \subsection{Dash Rules}
+%
+% \DescribeMacro\dashrule
+% The command
+% \begin{quote}
+% |\dashrule|\oarg{raise}\marg{h-pattern}\marg{v-pattern}
+% \end{quote}
+% prepares a dash rule. Its syntax is quite similar to the |\rule| command
+% except that \meta{h-pattern} and \meta{v-pattern} can contain a list of
+% sizes delimited with spaces. List sizes are interpreted as follows:
+% size, space, size, space, etc. In other words, every odd size is a
+% size of rule part and every even size is a space between neighbour parts.
+% If the last size in the list is even
+% (means a space), its space value is divided by two and
+% is added before the first rule part and after the last rule part.
+% Units in sizes can be omitted. In this case, pt-units are supposed.
+% Examples:
+% \begin{center}
+% \begin{tabular}{@{}l@{\qquad\qquad}l@{}}
+% x\dashrule[.5ex]{10mm}{1pt}x &
+% |x\dashrule[.5ex]{10mm}{1pt}x| \\
+% x\dashrule{5mm 3 3 3 5mm}{.4}x &
+% |x\dashrule{5mm 3 3 3 5mm}{.4}x| \\
+% x\dashrule{1}{3 2 3}x&
+% |x\dashrule{1}{3 2 3}x|\\
+% x\dashrule{2 2}{2 2}x &
+% |x\dashrule{2 2}{2 2}x|\\
+% x\dashrule{5 3 1 3 5 10}{1 1 0.4 1 1}x &
+% |x\dashrule{5 3 1 3 5 10}{1 1 0.4 1 1}x|
+% \end{tabular}
+% \end{center}
+%
+% \DescribeMacro\dashrulefill
+% The command
+% \begin{quote}
+% |\dashrulefill|\oarg{raise}\oarg{leader-type}\marg{h-pattern}\marg{v-pattern}
+% \end{quote}
+% fills a free space with a dash rule. The rule is composed from the 1st,
+% 3rd, and 4th arguments of the command and is repeated as more times as
+% necessary to fill a free horizontal space. The rest of space after filling is
+% stored depending on \meta{leader-type} used. Default leader type
+% is ``aligned leaders'': every rule is aligned to the multiple of its width
+% counted from the left boundary of filled box. Other cases are: |c| means
+% centered leaders (all extra spaces are collected at both ends of fill
+% area), |x| means distributed leaders (extra spaces are uniformly
+% distributed between every dash rule), and |s| means stretched leaders
+% (the space in h-pattern going after the last rule size is considered as
+% stretchable space and rules are stretched to the whole width of the
+% fill area).
+%
+% Example:
+% \begin{flushleft}
+% |\noindent x\dashrulefill{2 2}{2}\mbox{}\\|\\
+% |xxxxx\dashrulefill[.4ex]{2 2}{2}\mbox{}\\|\\
+% |\mbox{}\dashrulefill[.4ex]{4 4}{2}\mbox{}\\|\\
+% |\mbox{}\dashrulefill[.4ex][c]{4 4}{2}\mbox{}\\|\\
+% |\mbox{}\dashrulefill[.4ex][x]{4 4}{2}\mbox{}\\|\\
+% |\mbox{}\dashrulefill[.4ex][s]{4 4}{2}\mbox{}\\|\\
+% |\mbox{}\dashrulefill[.4ex][s]{4 2 1 2 4 -4}{1}\mbox{}\\[1ex]|\\
+% |\mbox{}\dashrulefill[0mm][c]{2 3}{2 3 2 3 2}\mbox{}\\|\\
+% |\mbox{}\dashrulefill{5 3 1 3 5}{1 1 0.4 1 1}\mbox{}\\|\\
+% |\mbox{}\dashrulefill[0mm][c]{5 3 1 3 5}{1 1 0.4 1 1}\mbox{}\\[-2ex]|\\
+% |\mbox{}\hrulefill|
+% \end{flushleft}
+%
+% It produces the following:
+%
+% \noindent x\dashrulefill{2 2}{2}\mbox{}\\
+% xxxxx\dashrulefill[.4ex]{2 2}{2}\mbox{}\\
+% \mbox{}\dashrulefill[.4ex]{4 4}{2}\mbox{}\\
+% \mbox{}\dashrulefill[.4ex][c]{4 4}{2}\mbox{}\\
+% \mbox{}\dashrulefill[.4ex][x]{4 4}{2}\mbox{}\\
+% \mbox{}\dashrulefill[.4ex][s]{4 4}{2}\mbox{}\\
+% \mbox{}\dashrulefill[.4ex][s]{4 2 1 2 4 -4}{1}\mbox{}\\[1ex]
+% \mbox{}\dashrulefill[0mm][c]{2 3}{2 3 2 3 2}\mbox{}\\
+% \mbox{}\dashrulefill{5 3 1 3 5}{1 1 0.4 1 1}\mbox{}\\
+% \mbox{}\dashrulefill[0mm][c]{5 3 1 3 5}{1 1 0.4 1 1}\mbox{}\\[-2ex]
+% \mbox{}\hrulefill
+%
+% \subsection{Custom Footnote Rules}
+%
+% In |manyfoot| package, you can separate footnote levels
+% with custom footnote rules. In this package we provide two ways for
+% creation such rules. All footnote rules should follow the following
+% contract: they must be prepared as |\hrule| or |\hbox|; the total height
+% of rule or box must be compensated with kerns. Usually a negative
+% kern is inserted before a footnote rule and a nonnegative kern is
+% inserted after the rule. The sum of both kerns and of total height of
+% rule must be equal to zero. We follow this contract in footnote rules
+% created with this package.
+%
+% In |manyfoot| package, every footnote rule must have a name
+% |\|\meta{prefix}|footnoterule|. So, we need to specify the prefix only
+% when a new footnote rule is constructed. Next that we need to specify is
+% a rule width. If width is omitted, the default width of |0.4\columnwidth|
+% is used. The footnote rule generation commands described below
+% are used in the preamble only.
+%
+% \DescribeMacro\newfootnoterule
+% The command
+% \begin{quote}
+% |\newfootnoterule|\marg{prefix}\oarg{width}\marg{rule code}
+% \end{quote}
+% produces a custom user-defined rule.
+% The \meta{rule code} must be stretchable to the given width.
+% The |\mboxfill| command from the |mboxfill| package is useful in it.
+% Examples:
+% \begin{quote}
+% |\newfootnoterule{starred}{\mboxfill[1.5\width][s]{$*$}}|\\
+% |\newfootnoterule{dotted}{\mboxfill[2\width][s]{.}}|
+% \end{quote}
+% The |\starredfootnoterule| and |\dottedfootnoterule| commands
+% are created here. They produce the following rules:
+%
+% \vspace{3mm}
+% \starredfootnoterule
+% \dottedfootnoterule
+%
+% \DescribeMacro\newfootnotedashrule
+% The command
+% \begin{quote}
+% |\newfootnotedashrule|\marg{prefix}\oarg{width}\marg{h-pattern}\marg{v-pattern}
+% \end{quote}
+% produces a dash footnote rule. The special case, when \meta{h-pattern}
+% is empty means the solid rule. Examples:
+% \begin{quote}
+% |\newfootnotedashrule{double}{}{.4 1 .4}|\\
+% |\newfootnotedashrule{dashed}{3 3}{.4}|\\
+% |\newfootnotedashrule{dotdashed}{4 2 1 2 4 -4}{.6}|\\
+% |\newfootnotedashrule{ddotdashed}{6 2 1 2 1 2 6 -6}{.6}|
+% \end{quote}
+% The following rules are created here:
+% |\doublefootnoterule|, |\dashedfootnoterule|,
+% |\dotdashedfootnoterule|, and |\ddotdashedfootnoterule|.
+% They produce the following rules:
+%
+% \vspace{2mm}%
+% \doublefootnoterule
+% \dashedfootnoterule
+% \dotdashedfootnoterule
+% \ddotdashedfootnoterule
+%
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% The |mboxfill| package is required here:
+% \begin{macrocode}
+%<*package>
+\RequirePackage{mboxfill}
+% \end{macrocode}
+%
+% \begin{macro}{\dashrule}
+% |\dashrule|\oarg{raise}\marg{h-pattern}\marg{v-pattern}
+% \begin{macrocode}
+\newcommand\dashrule{}
+\DeclareRobustCommand*\dashrule[3][\z@]{%
+ \setbox\@tempboxa\vbox{}%
+ \NCC@composedash{\NCC@vdash{#2}}{#3}%
+ \setlength\@tempdima{#1}\leavevmode
+ \raise\@tempdima\hbox{%
+ \vbox to\@tempdimc{\vss\unvbox\@tempboxa\vss}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\dashrulefill}
+% |\dashrulefill|\oarg{raise}\oarg{leader-type}\marg{h-pattern}\marg{v-pattern}\\
+% This command is a composition of the |\mboxfill| and
+% |\dashrule| commands. A trick is applied here:
+% we decrease dash rule width on the value of last space
+% in it and then apply |\mboxfill|.
+% \begin{macrocode}
+\newcommand*\dashrulefill[1][\z@]{%
+ \@ifnextchar[{\NCC@dashfill{#1}}{\NCC@dashfill{#1}[]}%
+}
+\def\NCC@dashfill#1[#2]#3#4{%
+ \NCC@composedash{}{#3}%
+ \advance\@tempdimb-\@tempdimc
+ \setbox\@tempboxa\hb@xt@-\@tempdimb
+ {\hss\dashrule[#1]{#3}{#4}\hss}%
+ \mboxfill[\@tempdimc][#2]{\box\@tempboxa}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@composedash}
+% |\NCC@composedash|\marg{action}\marg{pattern} parses the pattern
+% and calls the action when a rule size is parsed. At this point,
+% the |\@tempdima| contains a size parsed and |\@tempdimb| contains
+% the previous space. In |\@tempdimc|, the whole rule size is calculated.
+% \begin{macrocode}
+\def\NCC@composedash#1#2{%
+ \@tempdimb\z@ % Last space
+ \@tempdimc\z@ % Accumulator
+ \@tempswatrue % True value means producing an entry
+ \NCC@parsedash#2 ! !\@nil{%
+ \advance\@tempdimc\@tempdima
+ \if@tempswa #1\@tempswafalse \else
+ \@tempdimb\@tempdima \@tempswatrue
+ \fi
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@parsedash}
+% Pattern parser:
+% \begin{macrocode}
+\def\NCC@parsedash#1 #2\@nil#3{%
+ \if/#1/\else % Empty arg. ignored
+ \ifx#1!\else % Exclamation mark ends the list
+ \@defaultunits\@tempdima#1pt\relax\@nnil
+ #3\NCC@parsedash#2\@nil{#3}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@vdash}
+% |\NCC@vdash|\marg{h-pattern} is
+% applied when a vertical dash is composed.
+% |\@tempdimb| contains the required skip,
+% |\@tempdima| contains the rule height.
+% \begin{macrocode}
+\def\NCC@vdash#1{%
+ \setbox\@tempboxa\vbox{%
+ \unvbox\@tempboxa \vskip\@tempdimb
+ \setbox\@tempboxa\hbox{}%
+ \@tempskipa\@tempdima % Save rule height in \@tempskipa
+ \NCC@composedash{\NCC@hdash}{#1}%
+ \hb@xt@\@tempdimc{\hss\unhbox\@tempboxa\hss}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@hdash}
+% This action is applied when a horizontal dash is composed.
+% |\@tempdimb| contains the required skip,
+% |\@tempdima| contains the rule width,
+% |\@tempskipa| contains the rule height.
+% \begin{macrocode}
+\def\NCC@hdash{%
+ \setbox\@tempboxa\hbox{%
+ \unhbox\@tempboxa \kern\@tempdimb
+ \vrule \@width\@tempdima \@height\@tempskipa
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fnoterule}
+% |\NCC@fnoterule|\marg{width}\marg{rule code}\\
+% This is the footnote rule producing command.
+% As usual, two kerns must be inserted surround the rule: a negative
+% kern before the rule and a nonnegative kern after the rule.
+% The sum of kern values and of the total rule height must
+% vanish. Kerns are calculated in such a way to vertically center
+% the rule relative to 2.8pt distance top to the current position.
+% If the total height of rule is greater than 5.6pt, the rule is moved
+% up on the total rule height (the kern after the rule is zero in this case).
+% \begin{macrocode}
+\def\NCC@fnoterule#1#2{%
+ \setlength\@tempdima{#1}%
+ \setbox\@tempboxa\hb@xt@\@tempdima{#2}%
+ \@tempdima\ht\@tempboxa \advance\@tempdima\dp\@tempboxa
+ \@tempdimb 2.8\p@ \@tempdimc .5\@tempdima
+ \ifdim\@tempdimc>\@tempdimb \@tempdimb\@tempdimc \fi
+ \advance\@tempdimb\@tempdimc
+ \kern-\@tempdimb
+ \box\@tempboxa
+ \advance\@tempdimb -\@tempdima
+ \kern\@tempdimb
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fnotedashrule}
+% |\NCC@fnotedashrule|\marg{width}\marg{h-pattern}\marg{v-pattern}\\
+% Produces the rule based on |\dashrulefill|. A special case of empty
+% \meta{h-pattern} means the solid (maybe multi-line) rule.
+% \begin{macrocode}
+\def\NCC@fnotedashrule#1#2#3{%
+ \NCC@fnoterule{#1}{\def\@tempa{#2}%
+ \ifx\@tempa\@empty
+ \@tempskipb\@tempdima \dashrule{\@tempskipb}{#3}%
+ \else
+ \dashrulefill[\z@][s]{#2}{#3}%
+ \fi
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fnotecreate}
+% |\NCC@fnotecreate|\marg{prefix}\marg{body}\\
+% Creates a footnote rule whose name is composed from the
+% given \meta{prefix} and |footnoterule|. For example if the prefix
+% is |dashed|, the |\dashedfootnoterule| command will be created.
+% \begin{macrocode}
+\def\NCC@fnotecreate#1{%
+ \edef\@tempa{\noexpand\newcommand*%
+ \expandafter\noexpand\csname #1footnoterule\endcsname}%
+ \@tempa
+}
+\@onlypreamble\NCC@fnotecreate
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@fnoteprepare}
+% |\NCC@fnoteprepare|\marg{driver}\marg{prefix}\oarg{width}\\
+% Prepares a footnote rule command. The \meta{driver} is a command
+% that will be called for collecting rule code (it gets more arguments
+% from the input). When a driver prepares the code, it calls the
+% |\NCC@fnotecreate| command. If \meta{width} is omitted, the standard
+% width of |0.4\columnwidth| is used.
+% \begin{macrocode}
+\def\NCC@fnoteprepare#1#2{%
+ \@ifnextchar[{#1{#2}}{#1{#2}[.4\columnwidth]}%
+}
+\@onlypreamble\NCC@fnoteprepare
+% \end{macrocode}
+% \end{macro}
+%
+% Footnote rule creation driver has the following syntax:
+% \begin{quote}
+% |\|\meta{driver}\marg{prefix}\oarg{width}\meta{more arguments}
+% \end{quote}
+%
+% \begin{macro}{\newfootnoterule}
+% |\newfootnoterule|\marg{prefix}\oarg{width}\marg{rule code}
+% \begin{macrocode}
+\newcommand\newfootnoterule{\NCC@fnoteprepare\NCC@fnotedriver}
+\def\NCC@fnotedriver#1[#2]#3{%
+ \NCC@fnotecreate{#1}{\NCC@fnoterule{#2}{#3}}%
+}
+\@onlypreamble\newfootnoterule
+\@onlypreamble\NCC@fnotedriver
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newfootnotedashrule}
+% |\newfootnotedashrule|\marg{prefix}\oarg{width}\marg{h-pattern}\marg{v-pattern}
+% \begin{macrocode}
+\newcommand\newfootnotedashrule{\NCC@fnoteprepare\NCC@fnotedashdriver}
+\def\NCC@fnotedashdriver#1[#2]#3#4{%
+ \NCC@fnotecreate{#1}{\NCC@fnotedashrule{#2}{#3}{#4}}%
+}
+\@onlypreamble\newfootnotedashrule
+\@onlypreamble\NCC@fnotedashdriver
+%</package>
+% \end{macrocode}
+% \end{macro}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccsect.dtx b/Master/texmf-dist/source/latex/ncctools/nccsect.dtx
new file mode 100644
index 00000000000..980915c91a0
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccsect.dtx
@@ -0,0 +1,2101 @@
+% \iffalse
+%%
+%% File: nccsect.dtx Copyright (C) 2002--2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{nccsect}
+%<package> [2005/06/15 v1.3 Extended Section, Caption, and TOC Handling (NCC)]
+%
+% \changes{v1.00}{2002/02/01}{This version is uploaded to CTAN}
+% \changes{v1.01}{2002/02/08}{\NCC@thetocchapter hook added}
+% \changes{v1.02}{2002/02/13}{Bug in using the \nosectiontag fixed}
+% \changes{v1.02}{2002/03/19}{Test for caption with empty text added}
+% \changes{v1.03}{2002/05/19}{Vskips in captions after style changes now}
+% \changes{v1.04}{2002/05/22}{Centering in captions now works}
+% \changes{v1.1}{2004/12/12}{Introduce |\NCC@sec@reset@controls|}
+% \changes{v1.1}{2004/12/12}{Simplify making sections. The |\NCC@makesection| now
+% incompatible with previous version!!!}
+% \changes{v1.1}{2004/12/12}{Revised version: many internal changes}
+% \changes{v1.1}{2004/12/12}{Documentation was prepared}
+% \changes{v1.2}{2005/04/15}{Emulate |\@makecaption| for compatibility}
+% \changes{v1.2}{2005/04/15}{Compatibility with the supertabular package added}
+% \changes{v1.2}{2005/04/15}{Compatibility with the longtable package added}
+% \changes{v1.2}{2005/05/20}{Introduce |\beforechapter| hook}
+% \changes{v1.2}{2005/05/20}{Add |\StartHromTextArea| and |\StartFromHeaderArea|}
+% \changes{v1.2}{2005/05/21}{Add |\epigraph| and |\epigraphparameters|}
+% \changes{v1.2}{2005/05/22}{Add |\captionstyle| and related staff}
+% \changes{v1.2}{2005/05/22}{Add |\TOCMarginDrift|}
+% \changes{v1.2}{2005/05/22}{Add |\applystyle| command to TOC Entry style}
+% \changes{v1.2}{2005/06/08}{Set |\@twocolumnfalse| in before-chapter hook}
+% \changes{v1.2}{2005/06/08}{Allow sectioning in |\beforechapter| hook}
+% \changes{v1.3}{2005/06/15}{Fixed bug with using |\applystyle| command}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nccsect,nccboxes,desclist}
+\GetFileInfo{nccsect.sty}
+\begin{document}
+\title{The \textsf{nccsect} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccsect.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \section{The Scope and Objectives}
+%
+% The package changes the implementation of sections, captions,
+% and toc-entries in the \LaTeX\ kernel. The reasons for the changes
+% are concerned with the following disadvantages of the
+% standard \LaTeX\ implementation:
+%
+% \paragraph{1} Standard \LaTeX\ sectioning commands can prepare
+% display sections in the single style: justified paragraph
+% with hand indented number. To change this style to another
+% one (centered, par-indented, or else), you need
+% to re-implement the internal |\@sect| command. It is no
+% control for this style on user's level.
+%
+% \paragraph{2} If you want to customize the presentation a number in
+% a section (for example, put a paragraph mark \S\ before a number
+% or put a point after a number), you at least need to
+% re-implement the |\@sect| command.
+%
+% \paragraph{3} The sectioning commands provide no straightforward
+% control for running headings. The marking commands
+% like the |\sectionmark| solve this problem partially.
+% Using them within parameter of sectioning command,
+% you can change the mark properly, but this solution does not work in
+% complicated documents which use first and last marks
+% appearing on a page. The safe solution consists in direct
+% replacement a mark prepared within the |\@sect| command
+% to a custom mark.
+%
+% \paragraph{4} Special efforts are required to pass a section
+% without number to the header and to the toc-list. There is no simple
+% solution providing this action.
+%
+% \paragraph{5} Captions for tables and figures are prepared in
+% just the same way, although, they are usually used in different
+% places of floating environments: table captions start
+% \textit{before\/} a table, but figure captions go \textit{after\/}
+% a figure. So, the vertical skip inserted before a caption is
+% unnecessary for table captions. The right solution is to design
+% captions for different float types in different ways.
+%
+% \paragraph{6} The star-form of captions is absent. It is useful
+% when a document contains an alone figure or table. Moreover,
+% in fiction books, unnumbered captions useful.
+%
+% \paragraph{7} The design of toc-entries is hard for modifications.
+% It is much better to calculate the skips in toc-entries on the
+% base of prototyping technique instead of hard-coding them
+% with absolute values. Moreover, the skips for nested sections
+% must depend on of higher level skips. For example, if we
+% change skips for a section entry, the skips for subsection entries
+% should be adjusted automatically.
+%
+% \bigskip
+% The package eliminates above-mention disadvantages of the standard
+% \LaTeX\ implementation. The commands implemented in it are divided
+% into two levels: user level and design level. The user-level commands
+% are intended for use within a document and the design-level commands
+% are directed to class and package writers.
+%
+% \section{User Interface}
+%
+% The table below shows sectioning commands provided with standard
+% \LaTeX\ classes. Every section has a \textit{level\/} (an integer
+% number). Sections can be printed in one of two modes:
+% \textit{display\/} or \textit{run-in\/} mode. Display section is
+% prepared as a separate justified paragraph having a hand indent if a
+% section has a number. Run-in section starts a paragraph.
+% \begin{center}\catcode`|=12
+% \small\tabcolsep=10pt
+% \renewcommand\cboxstyle{\footnotesize}
+% \begin{tabular}{|l|c|c|}\hline
+% \hfill\cbox{Command}\hfill\mbox{} &
+% \hfill\cbox{Level}\hfill\mbox{} &
+% \hfill\cbox{Mode}\hfill\mbox{}\\\hline
+% \Strut/.8/
+% \cs{part} & $-$1 or 0\footnotemark & display \\
+% \cs{chapter} & 0\footnotemark & display \\
+% \cs{section} & 1 & display \\
+% \cs{subsection} & 2 & display \\
+% \cs{subsubsection} & 3 & display \\
+% \cs{paragraph} & 4 & run-in \\
+% \cs{subparagraph} & 5 & run-in \\
+% \hline
+% \end{tabular}\footnotetext[1]{The \cs{part} command has zero level
+% in article-like classes and has the negative level in book-like
+% classes. In book-like classes a part is prepared on
+% a separate page.}\footnotetext{The \cs{chapter} command is defined
+% in book-like classes only.}
+% \end{center}
+%
+% \DescribeMacro\startsection
+% The package redefines all standard sectioning commands except
+% the |\part| command in the book-like class. Along with the
+% commands shown in the table above, you can use the following
+% uniform notations:
+% \begin{quote}
+% |\startsection|\marg{level}\oarg{toc-entry}\marg{title}\quad or\\
+% |\startsection|\marg{level}|*|\marg{title}
+% \end{quote}
+% The \meta{level} is a level of section. The first command
+% produces a numbered section (if~the numbering depth allows this)
+% and the last one produces a section without number.
+% As for the standard \LaTeX\ sectioning, the first variant of
+% the |\startsection| command additionally passes their arguments
+% to the section mark command (if the mark command exists)
+% and to the aux-file.
+% The last variant does no additional actions.
+%
+% \bigskip
+% \textbf{NOTE}: The package allows declaring additional section
+% levels. They, of course, have no predefined alias names as
+% standard section levels.
+%
+% \bigskip
+% \DescribeMacro\sectionstyle
+% The |\sectionstyle|\marg{style} command allows change
+% a style of subsequent display sections. The following styles
+% are predefined:
+% \begin{desclist}{\tt}{ \rm\hfill---}[hangindent*]\itemsep=0mm
+% \item[hangindent] standard LaTeX style (default).
+% \item[hangindent*] the same as |hangindent|, but ragged right.
+% \item[parindent] section titles are indented on |\parindent|.
+% \item[parindent*] the same as |parindent|, but ragged right.
+% \item[center] section titles are centered.
+% \end{desclist}
+% You can apply the |\sectionstyle| so many times in the document
+% as you want. This command complies with standard \LaTeX\ scoping
+% rules.
+%
+% \DescribeMacro\indentaftersection
+% \DescribeMacro\noindentaftersection
+% The paragraph indentation after a display section is controlled with
+% the |\indentaftersection| and |\noindentaftersection| commands.
+% The first one allows and the last one suppresses
+% indentation after section. The commands act on the subsequent
+% display sections in the scope of their use.
+%
+% The customization of a number tag and running head of a concrete
+% section is provided with so-call \textit{modifiers}. A modifier
+% is a command acting on the nearest sectioning command going after it.
+% Usually, the modifiers are placed just before a sectioning command.
+% All modifiers act with non-starred versions of sections.
+% If the next sectioning command is starred, modifiers are ignored.
+%
+% \DescribeMacro\norunninghead
+% The |\norunninghead| command suppresses generation of running head for the
+% next non-starred section, i.e.\ it skips the call of section mark command
+% in the next section.
+%
+% \DescribeMacro\runninghead
+% The |\runninghead|\marg{running-title} command overrides a text going to the
+% running head when a new non-starred section starts and an appropriate\linebreak
+% |\pagestyle| is in use. This command has higher priority
+% than the |\norunninghead|.
+%
+% \DescribeMacro\noheadingtag
+% The |\noheadingtag| command suppresses a number tag in the next section,
+% but all other attendant actions are executed (writing to the aux-file and
+% updating the running head).
+%
+% \DescribeMacro\headingtag
+% The |\headingtag|\marg{tag} command overrides a number tag in the next
+% section. It has the higher priority than |\noheadingtag|. Overridden
+% section tag can be referred with the |\label| command.
+% All fragile commands in the overridden tag should be protected.
+%
+% \DescribeMacro{\headingtag*}
+% The |\headingtag*|\marg{tag} command prepares a number tag as is, ignoring
+% the tag style, prefix, and suffix. The aux-file and running head are not
+% updated in this case.
+%
+% \DescribeMacro\skipwritingtoaux
+% The |\skipwritingtoaux| suppresses writing to aux-file for the next section
+% command.
+%
+% \bigskip
+% \textbf{NOTE}: All modifiers use global settings.
+%
+% \bigskip
+% \DescribeMacro\caption
+% \DescribeMacro{\caption*}
+% The captions are implemented in this package using the same technique as
+% the sectioning commands. There are two versions of caption command
+% allowed within floating environments:
+% \begin{quote}
+% |\caption|\oarg{toc-entry}\marg{title}\quad and\\
+% |\caption*|\marg{title}
+% \end{quote}
+% The first one works in the same manner as the standard \LaTeX\ |\caption|
+% command. Its star-version prepares a caption without number and preceding
+% words `Figure' or `Table'.
+%
+% You can use line breaking commands in captions. But in this case,
+% you need to set the optional \meta{toc-entry} parameter to avoid
+% translation errors.
+%
+% \DescribeMacro\captionstyle
+% \DescribeMacro\captiontagstyle
+% \DescribeMacro\captionwidth
+% Caption appearance can be customized. You can customize ether all caption
+% types or only selected caption type. The following commands do this:
+% \begin{quote}
+% |\captionstyle|\oarg{type}\marg{style}\\
+% |\captiontagstyle|\oarg{type}\marg{style}\\
+% |\captionwidth|\oarg{type}\marg{length}
+% \end{quote}
+% If |type| is omitted, these commands are applied to all types (out of floats)
+% or to the current type (inside a float). If both typed and non-typed
+% cases are specified for a float type, typed case has a
+% precedence before non-typed one. The |\captionstyle| specifies a style
+% the caption text will be formatted:
+% \begin{desclist}{\tt}{}[centerlast]
+% \item[default] standard \LaTeX's style,
+% \item[para] simple paragraph,
+% \item[left] all lines are flushed left,
+% \item[center] all lines are centered,
+% \item[right] all lines are flushed right, or
+% \item[centerlast] as |para|, but the last line is centered.
+% \end{desclist}
+% The |\captiontagstyle| specifies a position of caption tag:
+% \begin{desclist}{\tt}{}[centerlast]
+% \item[para] tag is formatted together with text;
+% \item[left] tag is adjusted to the left in a separate line;
+% \item[center] tag is centered in a separate line; or
+% \item[right] tag is adjusted to the right in a separate line.
+% \end{desclist}
+% The |\captionwidth| specifies a width of caption. Defaults:
+% \begin{quote}
+% |\captionstyle{default}|\\
+% |\captiontagstyle{para}|\\
+% |\captionwidth{\linewidth}|
+% \end{quote}
+%
+% \bigskip
+% \textbf{NOTE}: The above-described section modifiers can be used with non-starred
+% captions. Although, the |\runninghead| and |\norunninghead| commands
+% have no sense with captions, but you can do them working if define
+% a |\figuremark| or |\tablemark| command.
+%
+% \section{Declare Sections and Captions}
+%
+% \DescribeMacro\DeclareSection
+% To define or redefine a section or caption command, you can use
+% in the preamble of your document the
+% following command:
+% \begin{quote}
+% |\DeclareSection|\marg{level}\marg{type}\oarg{indent}\marg{prefix}\\
+% | |\marg{beforeskip}\marg{afterskip}\marg{style}
+% \end{quote}
+% \begin{desclist}{}{}[\meta{beforeskip}]
+% \item[\meta{level}] a section level number. Zero and negative values
+% are interpreted as follows:
+% 0 means declaring the |\chapter| or |\part| command depending on a
+% class used; a negative value means declaring a caption.
+%
+% \item[\meta{type}] a section type. For zero level, this
+% parameter is ignored. For negative level, it defines a float type
+% (i.e., |figure| or |table|). For positive level, it defines
+% a counter name. The name of marking command is composed from
+% the type as |\|\meta{type}|mark|.
+%
+% \item[\meta{indent}] indentation of heading from the left margin
+% (zero is default). Ignored for negative levels.
+%
+% \item[\meta{prefix}] a prefix inserted before a section-number tag
+% (usually empty). In chapter, part, or caption declaration commands,
+% it is inserted right before the tag name, e.g., before the |\@chapapp|,
+% |\partname|, |\figurename|, or |\tablename| command.
+%
+% \item[\meta{beforeskip}] the skip to leave above the heading.
+%
+% \item[\meta{afterskip}] if positive, then the skip to leave below
+% the heading, else negative of skip to leave to right of run-in
+% heading. The negative value is allowed for positive section levels
+% only.
+%
+% \item[\meta{style}] commands to set a style. The last command in
+% this argument may be a command such as |\MakeUppercase| that
+% takes an argument. The section heading will be supplied as the
+% argument to this command. So setting it to, say,
+% |\bfseries\MakeUppercase| would produce bold, uppercase headings.
+% \end{desclist}
+% Sections having nonnegative \meta{level} and positive \meta{afterskip}
+% are display sections. They are declared with the |hangindent| style
+% and do not obey the |\sectionstyle| command.
+%
+% \DescribeMacro{\DeclareSection*}
+% To declare a display section having dynamic alignment controlled with the
+% |\sectionstyle| command, use the star-version of the previous command:
+% \begin{quote}
+% |\DeclareSection*|\marg{level}\marg{type}\marg{prefix}\\
+% | |\marg{beforeskip}\marg{afterskip}\marg{style}
+% \end{quote}
+% A negative \meta{afterskip} has no meaning in this case.
+%
+% \DescribeMacro\bff
+% To prepare bold section headings,
+% you can use the |\bff| command in the \meta{style} parameter.
+% It tries to set everything bold. Its definition is the following:
+% \begin{quote}
+% |\newcommand{\bff}{\normalfont\bfseries\mathversion{bold}}|
+% \end{quote}
+%
+% Examples of section and caption declarations:
+% \begin{quote}
+% |\DeclareSection{-2}{table}{}{0pt}{10pt}{}|\\
+% |\DeclareSection{-1}{figure}{}{10pt}{0pt}{}|\\
+% |\DeclareSection*{1}{section}{}%|\\
+% | {3.5ex plus 1ex minus .2ex}%|\\
+% | {2.3ex plus .2ex}{\Large\bff}|
+% \end{quote}
+% Here we declare the table caption command with zero skip
+% before it and |10pt| skip after it. On contrary, the
+% figure caption command produced |10pt| skip before it
+% and zero skip after it. The |\section| command is declared with
+% dynamic horizontal alignment. It is prepared in the |\Large|
+% font with everything bold.
+%
+% \DescribeMacro\SectionTagSuffix
+% The |\SectionTagSuffix|\marg{suffix} command specifies a suffix
+% inserted after a section number tag. For example, the command
+% \begin{quote}
+% |\SectionTagSuffix{.\quad}|
+% \end{quote}
+% sets the decimal point after every section number tag.
+% Sections of 0th level ignore this suffix. The default tag is |\quad|.
+% The command can be used in the preamble only.
+%
+% \DescribeMacro\CaptionTagSuffix
+% The |\CaptionTagSuffix|\marg{suffix} command specifies a suffix
+% inserted after a caption number tag. It can be used in the preamble only.
+% The default caption tag is:
+% \begin{quote}
+% |\CaptionTagSuffix{:\hskip .7em plus .2em minus .1em}|
+% \end{quote}
+%
+% \section{Declare TOC-Entries}
+%
+% \DescribeMacro\DeclareTOCEntry
+% To declare an entry of table of contents or other lists
+% (list of figures or list of tables), use the following command
+% (in the preamble only):
+% \begin{quote}
+% |\DeclareTOCEntry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\
+% | |\marg{style}\oarg{next}
+% \end{quote}
+% \begin{desclist}{}{\hfill}[\meta{prototype}]
+% \item[\meta{level}] a section level number.
+% For zero and negative level the following commands are created:
+% 0 means |\l@chapter| or |\l@part| depending on class used;
+% $-1$ means |\l@figure|; $-2$ means |\l@table|. If level
+% is greater than 5, the name of toc-entry command is
+% generated as |\l@section@|\meta{level-in-roman},
+% i.e., the 6th level toc-entry is |\l@section@vi|.
+%
+% \item[\meta{action}] commands applied before entry is produced (usually empty).
+%
+% \item[\meta{prefix}] text inserted before the section number (usually empty).
+%
+% \item[\meta{prototype}] prototype of number for alignment the toc-entry body.
+% The hang indent of this toc-entry will be equal to the width of
+% \begin{quote}
+% \meta{prefix}\meta{prototype}\meta{numberline-suffix}.
+% \end{quote}
+%
+% \item[\meta{style}] commands to set a style. The last command in this argument
+% may be a command such as |\MakeUppercase| that takes an
+% argument. The produced entry will be supplied as the
+% argument to this command. So setting it to, say,
+% |\bfseries\MakeUppercase| would produce bold,
+% uppercase entry. This style is applied to the number also.
+% To apply different styles to the text of entry and to its page
+% number, use in this parameter the command
+% \begin{quote}
+% |\applystyle|\marg{text-style}\marg{number-style}
+% \end{quote}
+%
+% \item[\meta{next}] prototype for left margin adjustment for an entry of the
+% next level. Default is the hang indent of the current toc-entry.
+% \end{desclist}
+% A toc-entry is produced within a group.
+%
+% \DescribeMacro\NumberlineSuffix
+% The |\NumberlineSuffix|\marg{calc-suffix}\marg{actual-suffix}
+% command allows customize a skip inserted after
+% numbers in TOC-like entries. The \meta{calc-suffix} parameter
+% is used in calculations of hang indent of toc-entries and the
+% \meta{actual-suffix} is really inserted at the end of number.
+% The \marg{calc-suffix} is usually wider than the \meta{actual-suffix}.
+% The default is |\NumberlineSuffix{\quad}{\enskip}|.
+% This command is available in the preamble only.
+%
+% \DescribeMacro\PnumPrototype
+% The |\PnumPrototype|\marg{prototype} command is used for adjustment
+% the right margin of the text of toc-entries in toc-lists.
+% Default is |\PnumPrototype{99}|.
+% If your document has more than 99 pages, use
+% |\PnumPrototype{999}|.
+% This command is available in the preamble only.
+%
+% \DescribeMacro\TOCMarginDrift
+% The |\TOCMarginDrift|\marg{increment} command specifies a value of
+% right-margin drift in TOCs. The increment is applied after the |\@plus|
+% token in definition of right margin. Empty argument means no drift.
+% Examples:
+% \begin{quote}
+% |\TOCMarginDrift{2em}|\\
+% |\TOCMarginDrift{1fil}|
+% \end{quote}
+% The command can be use anywhere in the document.
+%
+% \DescribeMacro\runinsectionskip
+% This command is useful in the \meta{action} parameter of the
+% toc-entry declaration to produce the skip before a toc-entry
+% equal to the skip before run-in sections.
+%
+% The following example shows how toc-entries are declared in books:
+% \begin{quote}
+% |\DeclareTOCEntry{-2}{}{}{9.9}{}% table|\\
+% |\DeclareTOCEntry{-1}{}{}{9.9}{}% figure|\\
+% |\DeclareTOCEntry{0}{\runinsectionskip\def\@dotsep{1000}%|\\
+% | \aftergroup\penalty\aftergroup\@highpenalty}{}{9}{\bff}% chapter|\\
+% |\DeclareTOCEntry{1}{}{}{9.9}{}[9.9]% section|\\
+% |\DeclareTOCEntry{2}{}{}{9.9.9}{}[9.9.9]% subsection|\\
+% |\DeclareTOCEntry{3}{}{}{}{}[\qquad]% subsubsection|
+% \end{quote}
+% The number prototype for figures and tables is `9.9' here.
+% The |\l@chapter| entry applies the run-in section skip before it and
+% redefines the |\@dotsep| command to remove dot leaders.
+% Using the |\aftergroup| command, it inserts the |\@highpenalty|
+% after this toc-entry to avoid a page break at this point.
+% The left margin adjustment after section and nested toc-entries
+% is calculated here using the prototype of widest section number.
+% This produces the following nesting:
+% \begin{flushleft}
+% {\bf 1\quad Chapter}\\
+% \jhbox{{\bf 1\quad}}{}1.1\quad Section\\
+% \jhbox{{\bf 1\quad}1.1}{}1.1.1\quad Subsection\\
+% \jhbox{{\bf 1\quad}1.11.1.1}{}Subsubsection
+% \end{flushleft}
+%
+% \section{Declare New Float Types}
+%
+% The standard \LaTeX\ classes provide two types of floating environments:
+% figures and tables. If you have prepared a new floating
+% environment in some way (i.e., using the |float| package by Anselm
+% Lingnau), you can declare a caption for the new float
+% with the commands described in previous sections.
+%
+% \DescribeMacro\RegisterFloatType
+% In books, when a new chapter starts, the |\chapter| command
+% puts a special vertical skip to the contents of list of figures and
+% of list of tables. This behaviour can be easy extended to new float types
+% if you register them within this package. The registration is
+% provided with the following command:
+% \begin{quote}
+% |\RegisterFloatType|\marg{float-type}
+% \end{quote}
+% After the float type is registered, you can declare a toc-entry
+% for it using the negation of its registration number in the
+% \meta{level} parameter. The
+% first new float type is registered third (after the figure and table).
+% So, you must
+% use \meta{level} = $-3$ for it, $-4$ for the next registered float
+% type and so on.
+%
+% In the following example, we define a new float type, |program|,
+% and prepare the caption and toc-entry commands for it.
+% The caption of programs
+% is supposed to be used at the beginning of program.
+% So, we make it in the same manner as the table caption.
+% \begin{quote}
+% |\documentclass{book}|\\
+% |\usepackage{float,nccsect}|\\
+% |\newfloat{program}{tp}{lop}[chapter]|\\
+% |\floatname{program}{Program}|\\
+% |\RegisterFloatType{program}|\\
+% |\DeclareSection{-3}{program}{}{0pt}{10pt}{}|\\
+% |\DeclareTOCEntry{-3}{}{}{9.9}{}|
+% \end{quote}
+%
+% To produce a list of programs, you can then use the |\listof|
+% command from the |float| package as follows:
+% \begin{quote}
+% |\listof{program}{List of Programs}|
+% \end{quote}
+% \StopEventually{}
+%
+% \section{Epigraphs and Related Staff}
+%
+% \DescribeMacro\beforechapter
+% \DescribeMacro\epigraph
+% To put epigraph before any chapter, you can use two methods:
+% low-level |\beforechapter|\marg{anything} hook or
+% user-level command
+% \begin{quote}
+% |\epigraph|\oarg{width}\marg{text}\marg{author}
+% \end{quote}
+% The last one applies a special formatting to epigraph and
+% calls the first one. The |\beforechapter| hook inserts its
+% contents at the beginning of page just before a chapter
+% instead of spacing specified in the chapter declaration.
+%
+% \DescribeMacro\epigraphparameters
+% Formatting of user-level epigraph is provided with the
+% following command
+% \begin{quote}
+% |\epigraphparameters|\marg{style}\marg{width}\marg{height}\marg{author-style}\\
+% | |\marg{after-action}
+% \end{quote}
+% Here \meta{style} is a style applied to the whole epigraph
+% (font selection, spacing and positioning, etc.), the \meta{width}
+% is the default epigraph width (can be changed in an epigraph),
+% the \meta{author-style} is the style applied to the author's
+% signature, and the \meta{after-action} is an action applied after
+% the epigraph (usually a vertical spacing). All styles and actions
+% are applied in the vertical mode. An \meta{author-style} can finish with
+% one-argument macro getting the author of epigraph and formatting it.
+%
+% \DescribeMacro\epigraphwidth
+% In |\epigraphparameters|, you can use the |\epigraphwidth| macro
+% which contains a selected epigraph width.
+%
+% The default style is:
+% \begin{quote}
+% |\epigraphparameters{\StartFromHeaderArea\small\raggedleft}|\\
+% | {.45\linewidth}{5\baselineskip}|\\
+% | {\raggedleft\itshape}{\vspace{2ex}}|
+% \end{quote}
+%
+% \DescribeMacro\StartFromTextArea
+% The |\vspace*| command applied at the beginning of page has one serious
+% disadvantage: it skips more space that specified in its parameter.
+% To remove this disadvantage, we introduce the |\StartFromTextArea|
+% command that
+% inserts a zero-height strut and allows use the |\vspace| command after it
+% without troubles.
+%
+% \DescribeMacro\StartFromHeaderArea
+% You can also extend the text area on the header if apply the
+% |\StartFromHeaderArea| command at the beginning of page.
+% Such action is useful in epigraphs: the first chapter's page usually
+% has an empty header and positioning an epigraph from the header
+% is the good practice.
+%
+% \section{The Implementation}
+%
+% \begin{macro}{\NCC@secskip}
+% \begin{macro}{\NCC@runskip}
+% The package shares the following commands with the
+% |nccthm| package:
+% \begin{quote}
+% |\NCC@secskip|\marg{skip} adds the \meta{skip} before a section,\\
+% |\NCC@runskip| is a skip inserted before run-in sections.
+% \end{quote}
+% We protect the definitions of these commands with testing
+% the |nccthm| package to be already loaded.
+% \begin{macrocode}
+%<*package>
+\@ifpackageloaded{nccthm}{}{%
+ \def\NCC@secskip#1{%
+ \if@noskipsec \leavevmode \fi \par
+ \if@nobreak \everypar{}\else
+ \addpenalty\@secpenalty
+ \addvspace{#1}%
+ \fi
+ }
+ \def\NCC@runskip{2.75ex \@plus 1ex \@minus .2ex}
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\runinsectionskip}
+% This command is useful in toc-entries:
+% \begin{macrocode}
+\newcommand{\runinsectionskip}{\NCC@secskip{\NCC@runskip}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{The Kernel}
+%
+% We start with declaring the section controls (modifiers):
+% \begin{desclist}{\tt}{\hfill}[NCC@nosecmark]\raggedright
+% \item[NCC@nosectag] is true if |\noheadingtag| is applied;
+% \item[NCC@secstartag] is true if |\headingtag*|\marg{tag} is applied;
+% \item[\cs{NCC@sectag}] saves a value of the |\headingtag| parameter;
+% \item[NCC@nosecmark] is true if |\norunninghead| is applied;
+% \item[\cs{NCC@secmark}\rm\marg{mark-command}] executes the \meta{mark-command}
+% with the parameter of |\runninghead| command;
+% \item[NCC@noaux] is true if |\skipwritingtoaux| is applied.
+% \end{desclist}
+% \begin{macrocode}
+\newif\ifNCC@nosectag
+\newif\ifNCC@secstartag
+\newif\ifNCC@nosecmark
+\newif\ifNCC@noaux
+% \end{macrocode}
+%
+% \begin{macro}{\NCC@global}
+% We reset all controls globally, but in the |\beforechapter|
+% hook we need to reset them locally. So, we reset all controls
+% using the |\NCC@global| modifier which value is |\global| by default.
+% \begin{macrocode}
+\let\NCC@global\global
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@sec@reset@controls}
+% This command resets all controls to default values.
+% It must be applied at the end of every section command.
+% \begin{macrocode}
+\def\NCC@sec@reset@controls{%
+ \NCC@global\NCC@nosectagfalse
+ \NCC@global\NCC@secstartagfalse
+ \NCC@global\let\NCC@sectag\relax
+ \NCC@global\NCC@nosecmarkfalse
+ \NCC@global\let\NCC@secmark\relax
+ \NCC@global\NCC@noauxfalse
+}
+\NCC@sec@reset@controls
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\norunninghead}
+% \begin{macro}{\runninghead}
+% \begin{macro}{\noheadingtag}
+% \begin{macro}{\headingtag}
+% \begin{macro}{\headingtag*}
+% \begin{macro}{\skipwritingtoaux}
+% User interface to section controls:
+% \begin{macrocode}
+\newcommand{\norunninghead}{\NCC@global\NCC@nosecmarktrue}
+\newcommand*{\runninghead}[1]{\NCC@global\def\NCC@secmark##1{##1{#1}}}
+\newcommand{\noheadingtag}{\NCC@global\NCC@nosectagtrue}
+\newcommand{\headingtag}{%
+ \@ifstar{\NCC@global\NCC@secstartagtrue\NCC@setsectag}{\NCC@setsectag}%
+}
+\def\NCC@setsectag#1{\NCC@global\def\NCC@sectag{#1}}
+\newcommand{\skipwritingtoaux}{\NCC@global\NCC@noauxtrue}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makesection}
+% The |\NCC@makesection|\marg{type}\marg{level}\marg{toc-entry}\marg{toc-action}
+% produces a section or caption. It analyzes the modifiers and customizes
+% sections or captions. The \meta{toc-action} parameter contains an
+% attendant action that must be applied at the end of macro.
+% It writes a toc-entry to aux-file.
+%
+% The command uses the following hooks that must be prepared
+% before its call:
+% \begin{desclist}{}{}[\cs{NCC@make}\marg{action}]
+% \item[\cs{NCC@makesectag}\marg{value}] produces a tag using the
+% given value;
+%
+% \item[\cs{NCC@make}\marg{action}] makes a section or caption heading
+% and applies the \meta{action} after heading. Before the call
+% of this command, the |\@svsec| macro is prepared (it contains a
+% prepared tag).
+% \end{desclist}
+% We start from the case when the |\headingtag*|\marg{tag} modifier was
+% applied and the section tag was saved in the |\NCC@sectag| macro.
+% We apply the |\NCC@make| procedure with the given section tag.
+% Attendant actions are ignored for this case.
+% \begin{macrocode}
+\def\NCC@makesection#1#2#3#4{%
+ \ifNCC@secstartag
+ \let\@svsec\NCC@sectag
+ \NCC@make{}%
+ \else
+% \end{macrocode}
+% Prepare a tag creation command in the |\the|\meta{type} macro.
+% We can do some temporary changes here that will be restored
+% at the end of macro. The restore hook is prepared in the
+% |\NCC@restsec| command.
+% \begin{macrocode}
+ \ifx\NCC@sectag\relax
+% \end{macrocode}
+% The |\noheadingtag| case: we temporary set the |secnumdepth|
+% counter to very low negative value. This prevents numbering
+% this section:
+% \begin{macrocode}
+ \ifNCC@nosectag
+ \edef\NCC@restsec{%
+ \noexpand\c@secnumdepth \the\c@secnumdepth\relax
+ }%
+ \c@secnumdepth -1000
+% \end{macrocode}
+% The ordinary case: No restore actions is necessary here.
+% \begin{macrocode}
+ \else
+ \let\NCC@restsec\relax
+ \ifnum#2>\c@secnumdepth \else\refstepcounter{#1}\fi
+ \fi
+% \end{macrocode}
+% The |\headingtag|\marg{tag} case: we temporary let the
+% |\the|\meta{type} macro to be equal to the |\NCC@sectag|
+% command produced by the |\headingtag|,
+% save the original value in the |\NCC@thesec| command,
+% and prepare the |\NCC@restsec| macro.
+% \begin{macrocode}
+ \else
+ \expandafter\let\expandafter\NCC@thesec\csname the#1\endcsname
+ \def\NCC@restsec{%
+ \expandafter\let\csname the#1\endcsname\NCC@thesec
+ }%
+ \expandafter\let\csname the#1\endcsname\NCC@sectag
+ \protected@edef\@currentlabel{\NCC@sectag}%
+ \fi
+% \end{macrocode}
+%
+% Prepare section tag in the |\@svsec| command:
+% \begin{macrocode}
+ \ifnum #2>\c@secnumdepth
+ \let\@svsec\@empty
+ \else
+ \protected@edef\@svsec{%
+ \protect\NCC@makesectag{\csname the#1\endcsname}%
+ }%
+ \fi
+% \end{macrocode}
+%
+% We cannot do the marking right now because the producing of section
+% can be suspended to the beginning of the nearest paragraph
+% (in run-in sections). So, we need to prepare a mark action
+% in a command that will save its state as long as necessary.
+% This command is |\NCC@makemark|.
+% \begin{macrocode}
+ \let\NCC@makemark\@empty
+ \@ifundefined{#1mark}{}{%
+ \ifx\NCC@secmark\relax
+% \end{macrocode}
+% Ordinary case: prepare the section mark with the
+% \meta{toc-entry} parameter.
+% \begin{macrocode}
+ \ifNCC@nosecmark \else
+ \def\NCC@makemark{\csname #1mark\endcsname{#3}}%
+ \fi
+% \end{macrocode}
+% The |\runninghead|\marg{heading} case:
+% pass the mark command in the parameter of |\NCC@secmark|.
+% We need to save the |\NCC@secmark| value in some command
+% and pass this command within |\NCC@makemark| because
+% the |\NCC@secmark| could be removed before the use.
+% \begin{macrocode}
+ \else
+ \let\NCC@savesecmark\NCC@secmark
+ \def\NCC@makemark{%
+ \NCC@savesecmark{\csname #1mark\endcsname}%
+ \let\NCC@savesecmark\relax
+ }%
+ \fi
+ }%
+% \end{macrocode}
+%
+% Make the section. We must apply the restore action at
+% the end action of |\NCC@make| command by the same reason that
+% the section making may be suspended:
+% \begin{macrocode}
+ \ifNCC@noaux
+ \NCC@make{\NCC@makemark \NCC@restsec}%
+ \else
+ \NCC@make{\NCC@makemark #4\NCC@restsec}%
+ \fi
+% \end{macrocode}
+%
+% Reset modifiers:
+% \begin{macrocode}
+ \fi
+ \NCC@sec@reset@controls
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Section Making Commands}
+%
+% \begin{macro}{\indentaftersection}
+% \begin{macro}{\noindentaftersection}
+% Introduce macros controlling indentation after display sections:
+% \begin{macrocode}
+\newcommand{\indentaftersection}{\@afterindenttrue}
+\newcommand{\noindentaftersection}{\@afterindentfalse}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\SectionTagSuffix}
+% The |\SectionTagSuffix|\marg{suffix} sets a suffix after a section tag:
+% \begin{macrocode}
+\newcommand*{\SectionTagSuffix}[1]{\def\NCC@asecnum{#1}}
+\@onlypreamble\SectionTagSuffix
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@defaultsectag}
+% This command restores the making tag command to its default
+% value.
+% \begin{macrocode}
+\def\NCC@makesectag@default#1{#1\NCC@asecnum}
+\def\NCC@defaultsectag{\let\NCC@makesectag\NCC@makesectag@default}
+\NCC@defaultsectag
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@secname}
+% The |\NCC@secname|\marg{level} command generates section name
+% (|section|,\linebreak |subsection|, \ldots,
+% or |section@vi|, |section@vii|, \ldots\ for new section levels).
+% This name is used as the second parameter of the |\addcontentsline|
+% command and in the declarations of toc-entries.
+% \begin{macrocode}
+\def\NCC@secname#1{%
+ \ifcase#1\relax \or section\or subsection\or subsubsection\or
+ paragraph\or subparagraph\else section@\romannumeral#1\fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@startsection}
+% The |\@startsection| command
+% has the same syntax as the original \LaTeX\ version:
+% \begin{quote}
+% |\@startsection|\marg{type}\marg{level}\marg{indent}\marg{beforeskip}\\
+% | |\marg{afterskip}\marg{style}
+% \end{quote}
+% but works in a bit different way: it ignores the sign of
+% \meta{beforeskip}. In the original version the testing
+% was applied to set an appropriate |afterindent| mode.
+% But we change this mode using |\indentaftersection| and
+% |\noindentaftersection| macros.
+% \begin{macrocode}
+\def\@startsection#1#2#3#4#5#6{%
+ \@tempskipa #4\relax
+ \ifdim \@tempskipa <\z@ \@temskipa -\@tempskipa \fi
+ \NCC@secskip \@tempskipa
+ \secdef{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}{\@ssect{#3}{#4}{#5}{#6}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makesec}
+% We save the interface of |\@ssect| and |\@sect| commands, but
+% change their implementation. They are based on the following
+% command:
+% \begin{quote}
+% |\NCC@makesec|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
+% \end{quote}
+% In fact, there are two versions of this command:
+% the traditional version, |\NCC@makesect|, and the
+% version with dynamic control of section style,\linebreak |\NCC@makesecx|.
+% The first one is the default version. To be sure, that this
+% version will be used by default, we every time let
+% the |\NCC@makesec| to be equal to |\NCC@makesect| after
+% a section is produced.
+% \end{macro}
+%
+% \begin{macro}{\@ssect}
+% The starred form of section:
+% \begin{quote}
+% |\@ssect|\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{heading}
+% \end{quote}
+% \begin{macrocode}
+\def\@ssect#1#2#3#4#5{%
+ \let\@svsec\@empty
+ \NCC@makesec{#1}{#4}{#5}{#3}{}%
+ \NCC@sec@reset@controls
+ \let\NCC@makesec\NCC@makesect
+ \NCC@defaultsectag
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@sect}
+% The base form of section:
+% \begin{quote}
+% |\@sect|\marg{type}\marg{level}\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\\
+% | |\oarg{toc-entry}\marg{heading}
+% \end{quote}
+% \begin{macrocode}
+\def\@sect#1#2#3#4#5#6[#7]#8{%
+ \def\NCC@make{\NCC@makesec{#3}{#6}{#8}{#5}}%
+ \NCC@makesection{#1}{#2}{#7}{%
+ \addcontentsline{toc}{\NCC@secname{#2}}{%
+ \ifnum #2>\c@secnumdepth \else
+ \protect\numberline{\csname the#1\endcsname}%
+ \fi
+ #7%
+ }%
+ }%
+ \let\NCC@makesec\NCC@makesect
+ \NCC@defaultsectag
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makesect}
+% The traditional section making command:
+% \begin{quote}
+% |\NCC@makesect|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
+% \end{quote}
+% \begin{macrocode}
+\def\NCC@makesect#1#2#3#4#5{%
+ \@tempskipa #4\relax
+ \ifdim \@tempskipa>\z@
+ \begingroup \normalfont
+ #2{\@hangfrom{\hskip #1\relax\@svsec}%
+ \interlinepenalty \@M\ignorespaces #3\@@par}%
+ \endgroup
+ #5%
+ \else
+ \def\@svsechd{{\normalfont #2{\hskip #1\relax
+ \@svsec\ignorespaces #3}}#5}%
+ \fi
+ \@xsect{#4}%
+}
+\let\NCC@makesec\NCC@makesect
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Make Sections with Dynamic Control}
+%
+% \begin{macro}{\NCC@sec}
+% A style of sections having dynamic control is defined by the
+% |\NCC@sec|\marg{tag} hook. This hook is applied inside a group
+% preparing a heading.
+% \end{macro}
+%
+% \begin{macro}{\sectionstyle}
+% The |\sectionstyle|\marg{style} changes a style of display sections.
+% In fact, it calls the |\NCC@sec@|\meta{style} command.
+% \begin{macrocode}
+\newcommand*{\sectionstyle}[1]{%
+ \@ifundefined{NCC@sec@#1}%
+ {\PackageError{nccsect}{Unknown section style `#1'}{}}%
+ {\csname NCC@sec@#1\endcsname}%
+}
+\def\NCC@sec@hangindent{\def\NCC@sec##1{\@hangfrom{##1}}}
+\@namedef{NCC@sec@hangindent*}{%
+ \def\NCC@sec##1{\@hangfrom{##1}\rightskip\@flushglue}%
+}
+\def\NCC@sec@parindent{\def\NCC@sec##1{\@hangfrom\indent##1}}
+\@namedef{NCC@sec@parindent*}{%
+ \def\NCC@sec##1{\@hangfrom\indent\rightskip\@flushglue##1}%
+}
+\def\NCC@sec@center{\def\NCC@sec##1{\centering##1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makesecx}
+% The dynamic section making command:
+% \begin{quote}
+% |\NCC@makesecx|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
+% \end{quote}
+% It prepares only display sections and ignores the \meta{indent} parameter.
+% \begin{macrocode}
+\def\NCC@makesecx#1#2#3#4#5{%
+ \begingroup\normalfont
+ #2{\NCC@sec{\@svsec}\interlinepenalty \@M\ignorespaces #3\@@par}%
+ \endgroup #5%
+ \par \nobreak \vskip #4\relax \@afterheading \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Make the Main Section}
+%
+% \begin{macro}{\NCC@startmainsec}
+% The main section is a section of zero level.
+% It is prepared with the following command:
+% \begin{quote}
+% |\NCC@startmainsec|\marg{alignment}\marg{prefix}\marg{beforeskip}\\
+% | |\marg{afterskip}\marg{style}
+% \end{quote}
+% It starts either a new chapter or a new part depending on the class
+% loaded. To decide what version should be prepared, we test the
+% |\chapter| command on existence.
+% \begin{macrocode}
+\@ifundefined{chapter}{%
+% \end{macrocode}
+%
+% The case of an article-like class. Zero-level section is the |\part|.
+% \begin{macrocode}
+ \def\NCC@startmainsec#1#2#3#4#5{%
+ \def\NCC@makesectag##1{\leavevmode#2\partname\nobreakspace##1}%
+ \NCC@secskip{#3}%
+ \secdef{\@part{#1}{#4}{#5}}{\@spart{#1}{#4}{#5}}%
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\@spart}
+% Prepare the starred version of part:
+% \begin{quote}
+% |\@spart|\marg{alignment}\marg{afterskip}\marg{style}\marg{heading}
+% \end{quote}
+% \begin{macrocode}
+ \def\@spart#1#2#3#4{%
+ \let\@svsec\@empty
+ \NCC@makepart{#1}{#3}{#4}{#2}{}%
+ \NCC@sec@reset@controls
+ \NCC@defaultsectag
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@part}
+% Prepare the non-starred version of part:
+% \begin{quote}
+% |\@part|\marg{alignment}\marg{afterskip}\marg{style}\oarg{toc-entry}\marg{heading}
+% \end{quote}
+% \begin{macrocode}
+ \def\@part#1#2#3[#4]#5{%
+ \def\NCC@make{\NCC@makepart{#1}{#3}{#5}{#2}}%
+ \NCC@makesection{part}{\z@}{#4}{%
+ \addcontentsline{toc}{part}{%
+ \ifnum \c@secnumdepth>\m@ne \protect\numberline{\thepart}\fi
+ #4%
+ }%
+ }%
+ \NCC@defaultsectag
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makepart}
+% This command makes a part.
+% \begin{quote}
+% |\NCC@makepart|\marg{alignment}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
+% \end{quote}
+% The |\@svsec| is either |\@empty| or contains a part tag.
+% \begin{macrocode}
+ \def\NCC@makepart#1#2#3#4#5{%
+ \begingroup \normalfont
+ \ifx\@svsec\@empty \else #1{\@svsec\@@par}\nobreak \fi
+ \interlinepenalty \@M #1{#2{#3}\@@par}%
+ \endgroup
+ #5%
+ \par\nobreak \vskip #4\relax \@afterheading \ignorespaces
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\partmark}
+% Define the |\partmark| if it is undefined before.
+% \begin{macrocode}
+ \providecommand*\partmark[1]{\markboth{}{}}
+}{
+% \end{macrocode}
+% \end{macro}
+%
+% The case of a book-like class. Zero-level section is the |\chapter|.
+% \begin{macrocode}
+ \def\NCC@startmainsec#1#2#3#4#5{%
+ \NCC@startchap
+ \def\NCC@makesectag##1{\leavevmode#2\@chapapp\nobreakspace##1}%
+ \secdef{\@chapter{#1}{#3}{#4}{#5}}{\@schapter{#1}{#3}{#4}{#5}}%
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\beforechapter}
+% The |\beforechapter|\marg{something} hook is applied to the nearest
+% chapter. An empty value of its parameter means no hook.
+% \begin{macrocode}
+ \newcommand\beforechapter[1]{\gdef\NCC@beforechapter{#1}}
+ \beforechapter{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@schapter}
+% Prepare the starred version of chapter:
+% \begin{quote}
+% |\@schapter|\marg{alignment}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{heading}
+% \end{quote}
+% \begin{macrocode}
+ \def\@schapter#1#2#3#4#5{%
+ \let\@svsec\@empty
+ \NCC@makechapter{#1}{#2}{#4}{#5}{#3}{}%
+ \NCC@sec@reset@controls
+ \NCC@defaultsectag
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@chapter}
+% Prepare the non-starred version of chapter:
+% \begin{quote}
+% |\@chapter|\marg{alignment}\marg{beforeskip}\marg{afterskip}\marg{style}\\
+% | |\oarg{toc-entry}\marg{heading}
+% \end{quote}
+% It uses the |\NCC@infloats|\marg{action} hook that applies the specified
+% action for all registered float types.
+% \begin{macrocode}
+ \def\@chapter#1#2#3#4[#5]#6{%
+ \@ifundefined{if@mainmatter}{}{\if@mainmatter\else\noheadingtag\fi}%
+ \def\NCC@make{\NCC@makechapter{#1}{#2}{#4}{#6}{#3}}%
+ \NCC@makesection{chapter}{\z@}{#5}{%
+ \typeout{\@chapapp\space\thechapter.}%
+ \addcontentsline{toc}{chapter}{%
+ \ifnum \c@secnumdepth>\m@ne
+ \protect\numberline{\NCC@thetocchapter}\fi
+ #5%
+ }%
+ \NCC@infloats{\addtocontents{\@nameuse{ext@\@captype}}%
+ {\protect\runinsectionskip}}%
+ }%
+ \NCC@defaultsectag
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@startchap}
+% The start chapter hook:
+% \begin{macrocode}
+ \def\NCC@startchap{%
+ \if@openright\cleardoublepage\else\clearpage\fi
+ \thispagestyle{plain}\global\@topnum\z@
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@thetocchapter}
+% The following hook allows redefine the appearance of chapter name
+% in the TOC:
+% \begin{macrocode}
+ \def\NCC@thetocchapter{\thechapter}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makechapter}
+% This command makes a chapter:
+% \begin{quote}
+% |\NCC@makechapter|\marg{alignment}\marg{beforeskip}\marg{style}\marg{heading}\\
+% | |\marg{afterskip}\marg{action}
+% \end{quote}
+% The |\@svsec| is either |\@empty| or contains a chapter tag.
+% \begin{macrocode}
+ \def\NCC@makechapter#1#2#3#4#5#6{%
+ \if@twocolumn
+ \@topnewpage[\NCC@makechaphead{#1}{#2}{#3}{#4}{#5}]%
+ \else
+ \NCC@makechaphead{#1}{#2}{#3}{#4}{#5}%
+ \fi
+ #6%
+ \@afterheading
+ \ignorespaces
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makechaphead}
+% This command makes a chapter head:
+% \begin{quote}
+% |\NCC@makechaphead|\marg{alignment}\marg{beforeskip}\marg{style}\marg{heading}\\
+% | |\marg{afterskip}
+% \end{quote}
+% \begin{macrocode}
+ \def\NCC@makechaphead#1#2#3#4#5{%
+ \ifx\NCC@beforechapter\@empty
+ \StartFromTextArea \vspace{#2}%
+ \else
+ \begingroup
+ \@twocolumnfalse
+ \let\NCC@global\@empty
+ \NCC@sec@reset@controls
+ \normalfont \NCC@beforechapter \par
+ \endgroup
+ \beforechapter{}%
+ \fi
+ \begingroup \normalfont
+ \ifx\@svsec\@empty \else #1{\@svsec\@@par}\fi
+ \interlinepenalty \@M #1{#3{#4}\@@par}%
+ \endgroup
+ \par\nobreak \vskip #5\relax
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\epigraph}
+% \begin{macro}{\epigraphparameters}
+% \begin{quote}
+% |\epigraph|\oarg{width}\marg{text}\marg{author}\\
+% |\epigraphparameters|\marg{style}\marg{width}\marg{height}\marg{author-style}\\
+% | |\marg{after-action}
+% \end{quote}
+% \begin{macrocode}
+ \newcommand*\epigraph[1][\NCC@epigraphwidth]{\NCC@epigraph{#1}}
+ \newcommand*\epigraphparameters[5]{%
+ \def\NCC@epigraphwidth{#2}%
+ \long\def\NCC@epigraph##1##2##3{
+ \beforechapter{\def\epigraphwidth{##1}%
+ #1\par
+ \NCC@makeepigraph{#3}{##2}{#4{##3}}\par
+ #5%
+ }%
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makeepigraph}
+% \begin{quote}
+% |\NCC@makeepigraph|\marg{height}\marg{text}\marg{author}
+% \end{quote}
+% \begin{macrocode}
+ \long\def\NCC@makeepigraph#1#2#3{%
+ \@begin@tempboxa\vtop{\setlength{\hsize}{\epigraphwidth}%
+ \@parboxrestore{#2\@@par}#3\@@par
+ }%
+ \setlength\@tempdima{#1}\advance\@tempdima -\totalheight
+ \ifdim\@tempdima>\z@
+ \advance\@tempdima\depth
+ \dp\@tempboxa\@tempdima
+ \fi
+ \leavevmode\box\@tempboxa
+ \@end@tempboxa
+ }
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Make Captions}
+%
+% \begin{macro}{\CaptionTagSuffix}
+% The |\CaptionTagSuffix|\marg{suffix} sets a suffix after a caption tag:
+% \begin{macrocode}
+\newcommand*{\CaptionTagSuffix}[1]{\def\NCC@acapnum{#1}}
+\@onlypreamble\CaptionTagSuffix
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\captionstyle}
+% The |\captionstyle|\oarg{type}\marg{style} selects a style to be applied
+% to the caption text. Three styles are available now: |default|, |center|,
+% and |centerlast|.
+% \begin{macrocode}
+\newcommand*\captionstyle[1][]{%
+ \NCC@set@capkey{style}{style}{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\captiontagstyle}
+% The |\captiontagstyle|\oarg{type}\marg{style} selects a style of caption tag:
+% |right| or |para|.
+% \begin{macrocode}
+\newcommand*\captiontagstyle[1][]{%
+ \NCC@set@capkey{tag}{tag style}{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\captionwidth}
+% The |\captionwidth|\oarg{type}\marg{length} specifies a caption width.
+% Default width is |\linewidth|.
+% \begin{macrocode}
+\newcommand*\captionwidth[2][]{%
+ \NCC@prepare@capkey{width}{#1}{\setlength{\hsize}{#2}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@set@capkey}
+% |\NCC@set@capkey|\marg{key}\marg{description}\marg{type}\marg{value}
+% \begin{macrocode}
+\def\NCC@set@capkey#1#2#3#4{%
+ \@ifundefined{NCC@makecap#1@#4}
+ {\PackageError{nccsect}{Unknown caption #2 `#4'}{}%
+ }{%
+ \edef\@tempa{\noexpand\NCC@prepare@capkey{#1}{#3}{%
+ \expandafter\noexpand\csname NCC@makecap#1@#4\endcsname
+ }%
+ }%
+ \@tempa
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@prepare@capkey}
+% |\NCC@prepare@capkey|\marg{key}\marg{type}\marg{definition}
+% \begin{macrocode}
+\def\NCC@prepare@capkey#1#2{%
+ \def\@tempa{#2}%
+ \ifx\@tempa\@empty
+ \ifx\@captype\@undefined \else \let\@tempa\@captype \fi
+ \fi
+ \expandafter\def\csname NCC@cap#1@\@tempa\endcsname
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@apply@cap}
+% |\NCC@apply@cap|\marg{key}
+% \begin{macrocode}
+\def\NCC@apply@cap#1{%
+ \@ifundefined{NCC@cap#1@\@captype}%
+ {\let\@tempa\@empty}{\let\@tempa\@captype}%
+ \csname NCC@cap#1@\@tempa\endcsname
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@startcaption}
+% This command starts a caption:
+% \begin{quote}
+% |\NCC@startcaption|\marg{beforeskip}\marg{afterskip}\marg{style}
+% \end{quote}
+% \begin{macrocode}
+\def\NCC@startcaption#1#2#3{%
+ \secdef{\NCC@caption{#1}{#2}{#3}}{\NCC@scaption{#1}{#2}{#3}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@scaption}
+% Starred version of caption:
+% \begin{quote}
+% |\NCC@scaption|\marg{beforeskip}\marg{afterskip}\marg{style}\marg{text}
+% \end{quote}
+% \begin{macrocode}
+\long\def\NCC@scaption#1#2#3#4{%
+ \let\@svsec\@empty
+ \NCC@makecaption{#3}{#1}{#4}{#2}{}%
+ \NCC@sec@reset@controls
+ \NCC@defaultsectag
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@caption}
+% Non-starred version of caption:
+% \begin{quote}
+% |\NCC@caption|\marg{beforeskip}\marg{afterskip}\marg{style}\oarg{toc-entry}\marg{text}
+% \end{quote}
+% \begin{macrocode}
+\long\def\NCC@caption#1#2#3[#4]#5{%
+ \def\NCC@make{\NCC@makecaption{#3}{#1}{#5}{#2}}%
+ \NCC@makesection{\@captype}{\z@}{#4}{%
+ \begingroup
+ \let\centering\@empty
+ \addcontentsline{\@nameuse{ext@\@captype}}{\@captype}{%
+ \ifnum \c@secnumdepth>\m@ne
+ \protect\numberline{\@nameuse{the\@captype}}\fi
+ #4%
+ }%
+ \endgroup
+ }%
+ \NCC@defaultsectag
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecaption}
+% This command makes a caption:
+% \begin{quote}
+% |\NCC@makecaption|\marg{style}\marg{beforeskip}\marg{text}\marg{afterskip}\marg{action}
+% \end{quote}
+% The |\@svsec| is either |\@empty| or contains a caption tag.
+% \begin{macrocode}
+\long\def\NCC@makecaption#1#2#3#4#5{%
+ \begingroup\par\normalfont
+ #1{}\addvspace{#2}\noindent
+% \end{macrocode}
+% Calculate in |\@tempcnta| caption variants:
+% 0~-- no caption, 1~-- caption tag only, 2~-- caption text only,
+% 3~-- both caption tag and text are nonempty.
+% \begin{macrocode}
+ \ifx\@svsec\@empty \@tempcnta\z@ \else \@tempcnta\@ne \fi
+ \def\@tempa{#3}%
+ \ifx\@tempa\@empty \else \advance\@tempcnta\tw@ \fi
+% \end{macrocode}
+% Put caption in a parbox aligned at the top line.
+% \begin{macrocode}
+ \ifnum\@tempcnta=\z@ \else
+ \vtop{\NCC@apply@cap{width}\@parboxrestore
+ \NCC@apply@cap{tag}{#3}\@@par}\par
+% \end{macrocode}
+% We avoid insert zero skip after parbox to allow captions of
+% side-by-side figures to be aligned at their top line.
+% \begin{macrocode}
+ \setlength\@tempskipa{#4}%
+ \ifdim\@tempskipa=\z@ \else \vskip \@tempskipa\fi
+ \fi
+ \endgroup
+ #5%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecaptag@para}
+% The |\NCC@makecaptag@para|\marg{text} prepares run-in tag.
+% \begin{macrocode}
+\long\def\NCC@makecaptag@para#1{%
+ \ifnum\@tempcnta<\thr@@ \let\NCC@acapnum\@empty\fi
+ \NCC@apply@cap{style}{{\@svsec}\ignorespaces#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecaptag@left}
+% The |\NCC@makecaptag@left|\marg{text} prepares flush-left tag.
+% \begin{macrocode}
+\def\NCC@makecaptag@left{\NCC@separate@captag\raggedright}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecaptag@center}
+% The |\NCC@makecaptag@center|\marg{text} prepares centered tag.
+% \begin{macrocode}
+\def\NCC@makecaptag@center{\NCC@separate@captag\centering}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecaptag@right}
+% The |\NCC@makecaptag@right|\marg{text} prepares flush-right tag.
+% \begin{macrocode}
+\def\NCC@makecaptag@right{\NCC@separate@captag\raggedleft}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@separate@captag}
+% The |\NCC@separate@captag|\marg{style}\marg{text} prepares a
+% caption tag in a separate line.
+% \begin{macrocode}
+\long\def\NCC@separate@captag#1#2{%
+ \ifodd\@tempcnta
+ {\let\NCC@acapnum\@empty #1\@svsec\@@par}%
+ \fi
+ \ifnum\@tempcnta>\@ne
+ \ifnum\@tempcnta=\thr@@ \vskip .5ex\fi
+ \NCC@apply@cap{style}{#2}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecapstyle@default}
+% The |\NCC@makecapstyle@default|\marg{text} prepares caption text
+% in default \LaTeX's style.
+% \begin{macrocode}
+\long\def\NCC@makecapstyle@default#1{%
+ \setbox\@tempboxa\vtop{\hsize\linewidth\@parboxrestore#1\@@par}%
+ \ifdim\dp\@tempboxa<\baselineskip \centering#1%
+ \else \box\@tempboxa \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecapstyle@para}
+% The |\NCC@makecapstyle@para|\marg{text} prepares ordinary caption.
+% \begin{macrocode}
+\long\def\NCC@makecapstyle@para#1{#1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecapstyle@left}
+% The |\NCC@makecapstyle@left|\marg{text} prepares flush-left caption.
+% \begin{macrocode}
+\long\def\NCC@makecapstyle@left#1{\raggedright#1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecapstyle@right}
+% The |\NCC@makecapstyle@right|\marg{text} prepares flush-right caption.
+% \begin{macrocode}
+\long\def\NCC@makecapstyle@right#1{\raggedleft#1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecapstyle@center}
+% The |\NCC@makecapstyle@center|\marg{text} prepares centered caption.
+% \begin{macrocode}
+\long\def\NCC@makecapstyle@center#1{\centering#1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@makecapstyle@centerlast}
+% The |\NCC@makecapstyle@centerlast|\marg{text} prepares caption with
+% last line centered.
+% \begin{macrocode}
+\long\def\NCC@makecapstyle@centerlast#1{%
+ \leftskip\z@\@plus 1fil%
+ \rightskip\z@\@plus -1fil%
+ \parfillskip\z@\@plus 2fil\relax#1%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RegisterFloatType}
+% The |\RegisterFloatType|\marg{type} command registers a float type:
+% \begin{macrocode}
+\newcommand*{\RegisterFloatType}[1]{%
+ \edef\NCC@floatlist{\NCC@floatlist{#1}}%
+}
+\let\NCC@floatlist\@empty
+\@onlypreamble\RegisterFloatType
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@infloats}
+% The |\NCC@infloats|\marg{action} command applies the given \meta{action}
+% to all registered float types. During the cycle,
+% the |\@captype| contains a name of float and
+% the |\@tempcnta| is equal to its registration number
+% (1~for the figure float, 2~for the table float, and so on).
+% \begin{macrocode}
+\def\NCC@infloats#1{%
+ \@tempcnta\z@
+ \let\NCC@temp \@captype
+ \expandafter \@tfor \expandafter \@captype
+ \expandafter :\expandafter =\NCC@floatlist \do
+ {\advance\@tempcnta\@ne #1}%
+ \let\@captype\NCC@temp
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Declare Sections and Captions}
+%
+% \begin{macro}{\DeclareSection}
+% Now we can implement the |\DeclareSection| command.
+% It generates:
+% \begin{desclist}{}{}
+% \item[\cs{NCC@mainsection}] command if \meta{level} = 0;
+% \item[\cs{NCC@section}\meta{level-in-roman}] command if \meta{level} $>$ 0;
+% \item[\cs{NCC@cap@}\meta{float-type}] command if \meta{level} $<$ 0.
+% \end{desclist}
+% \begin{macrocode}
+\newcommand{\DeclareSection}{\@ifstar{\NCC@dsecx}{\NCC@dsec}}
+\def\NCC@dsec#1#2{%
+ \@ifnextchar[{\NCC@dsect{#1}{#2}}{\NCC@dsect{#1}{#2}[\z@skip]}%
+}
+\@onlypreamble\DeclareSection
+\@onlypreamble\NCC@dsec
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@dsect}
+% The non-starred version of section declaration command
+% prepares display sections with traditional formatting:
+% \begin{quote}
+% |\NCC@dsect|\marg{level}\marg{type}\oarg{indent}\marg{prefix}\marg{beforeskip}\\
+% | |\marg{afterskip}\marg{style}
+% \end{quote}
+% It is also used for generation of run-in sections
+% and captions.
+% \begin{macrocode}
+\def\NCC@dsect#1#2[#3]#4#5#6#7{%
+ \ifnum#1>\z@
+ \expandafter\def\csname NCC@section\romannumeral#1\endcsname{%
+ \def\NCC@makesectag####1{#4####1\NCC@asecnum}%
+ \let\NCC@makesec\NCC@makesect
+ \@startsection{#2}{#1}{#3}{#5}{#6}{#7}}%
+ \else
+ \ifnum#1=\z@
+ \def\NCC@mainsection{%
+ \NCC@startmainsec{\@hangfrom{\hskip #3}\rightskip\@flushglue}%
+ {#4}{#5}{#6}{#7}%
+ }%
+ \else
+ \NCC@dsecf{#2}{#4}{#5}{#6}{#7}%
+ \fi
+ \fi
+}
+\@onlypreamble\NCC@dsect
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@dsecx}
+% The starred version of section declaration command
+% prepares display sections with dynamic formatting:
+% \begin{quote}
+% |\NCC@dsecx|\marg{level}\marg{type}\marg{prefix}\marg{beforeskip}\marg{afterskip}\marg{style}
+% \end{quote}
+% It can be also used for generation of captions.
+% \begin{macrocode}
+\def\NCC@dsecx#1#2#3#4#5#6{%
+ \ifnum#1>\z@
+ \expandafter\def\csname NCC@section\romannumeral#1\endcsname{%
+ \def\NCC@makesectag####1{#3####1\NCC@asecnum}%
+ \let\NCC@makesec\NCC@makesecx
+ \@startsection{#2}{#1}{\z@}{#4}{#5}{#6}}%
+ \else
+ \ifnum#1=\z@
+ \def\NCC@mainsection{%
+ \NCC@startmainsec{\NCC@sec{}\rightskip\@flushglue}%
+ {#3}{#4}{#5}{#6}%
+ }%
+ \else
+ \NCC@dsecf{#2}{#3}{#4}{#5}{#6}%
+ \fi
+ \fi
+}
+\@onlypreamble\NCC@dsecx
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@dsecf}
+% This command declares captions of floats:
+% \begin{quote}
+% |\NCC@dsecf|\marg{type}\marg{prefix}\marg{beforeskip}\marg{afterskip}\marg{style}
+% \end{quote}
+% \begin{macrocode}
+\def\NCC@dsecf#1#2#3#4#5{%
+ \expandafter\def\csname NCC@cap@#1\endcsname{%
+ \def\NCC@makesectag####1{#2{\csname #1name\endcsname}%
+ \nobreakspace####1\NCC@acapnum}%
+ \NCC@startcaption{#3}{#4}{#5}%
+ }%
+}
+\@onlypreamble\NCC@dsectf
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@makecaption}
+% We emulate here the |\@makecaption{\fnum@|\meta{type}|}|\marg{caption}
+% command to provide the compatibility with packages using it.
+% It calls the |\NCC@cap@|\meta{type} command using the type specified
+% in |\@captype| command. The counter is already stepped
+% before this command and all necessary things are written
+% to aux. Therefore, we turn off writing to aux and decrease a value of
+% the float counter by |-1| because it will be stepped within again.
+% \begin{macrocode}
+\long\def\@makecaption#1#2{%
+ \begingroup
+ \skipwritingtoaux
+ \addtocounter\@captype\m@ne
+ \csname NCC@cap@\@captype\endcsname[]{#2}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Add patches to the |supertabular| and |longtable| packages if they are used:
+% \begin{macrocode}
+\AtBeginDocument{%
+ \@ifpackageloaded{supertabular}{%
+ \long\def\ST@caption#1[#2]#3{\par%
+ \addcontentsline{\csname ext@#1\endcsname}{#1}%
+ {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
+ \def\@captype{#1}%
+ \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
+ }%
+ }{}%
+ \@ifpackageloaded{longtable}{%
+ \def\LT@makecaption#1#2#3{%
+ \LT@mcol\LT@cols c{\hbox to\z@{\hss
+ \parbox[t]\LTcapwidth{\def\@captype{table}%
+ \ifx#1\@gobble \NCC@cap@table*{#3}%
+ \else \@makecaption{\fnum@table}{#3}%
+ \fi
+ }%
+ \hss
+ }}%
+ }%
+ }{}%
+}
+% \end{macrocode}
+%
+% \subsection{Declare TOC-Entries}
+%
+% \begin{macro}{\DeclareTOCEntry}
+% The toc-entries declaration command:
+% \begin{quote}
+% |\DeclareTOCEntry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\
+% | |\marg{style}\oarg{next}
+% \end{quote}
+% \begin{macrocode}
+\newcommand*{\DeclareTOCEntry}[5]{%
+ \@ifnextchar[{\NCC@dtoc{#1}{#2}{#3}{#4}{#5}}%
+ {\NCC@dtoc{#1}{#2}{#3}{#4}{#5}%
+ [{#3#4\let\NCC@do\@firstoftwo\NCC@atocnum}]}%
+}
+\def\NCC@dtoc#1#2#3#4#5[#6]{%
+% \end{macrocode}
+% Declare a toc-entry command for a registered float.
+% We scan the registration list and find the necessary
+% float type comparing its registration number with the negation
+% of level. The generated command is |\l@|\meta{float-type}:
+% \begin{macrocode}
+ \ifnum#1<\z@
+ \@tempswatrue
+ \NCC@infloats{%
+ \ifnum#1=-\@tempcnta
+ \expandafter\def\csname l@\@captype\endcsname
+ {\NCC@tocentry\z@{#2}{#3}{#4}{#5}}%
+ \@tempswafalse
+ \@break@tfor
+ \fi
+ }%
+% \end{macrocode}
+% Incorrect level number. Generate an error.
+% \begin{macrocode}
+ \if@tempswa
+ \@tempcnta#1\relax
+ \@tempcnta -\@tempcnta
+ \PackageError{nccsect}
+ {Float type registration number \the\@tempcnta\space
+ is out of range}{}%
+ \fi
+ \else
+% \end{macrocode}
+% Prepare in |\@tempa| a command name: |\l@section| or |\l@subsection|
+% or \ldots\ or |\l@subparagraph| or |\l@section@vi| or \ldots:
+% \begin{macrocode}
+ \ifnum#1>\z@
+ \edef\@tempa{\noexpand\def\expandafter\noexpand
+ \csname l@\NCC@secname{#1}\endcsname}%
+% \end{macrocode}
+% or |\l@part| or |\l@chapter|:
+% \begin{macrocode}
+ \else
+ \@ifundefined{chapter}{\def\@tempa{\def\l@part}}%
+ {\def\@tempa{\def\l@chapter}}%
+ \fi
+% \end{macrocode}
+% Declare the toc-entry:
+% \begin{macrocode}
+ \@tempa{\NCC@tocentry{#1}{#2}{#3}{#4}{#5}}%
+% \end{macrocode}
+% Prepare in the |\l@tocskip@|\meta{next-level-in-roman} command
+% the left margin adjustment command:
+% \begin{macrocode}
+ \@tempcnta #1\relax \advance\@tempcnta\@ne
+ \expandafter\def\csname l@tocskip@\romannumeral\@tempcnta
+ \endcsname{\NCC@tocadj{#5{#6}}}%
+ \fi
+}
+\@onlypreamble\DeclareTOCEntry
+\@onlypreamble\NCC@dtoc
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@tocentry}
+% This command makes a toc-entry:
+% \begin{quote}
+% |\NCC@tocentry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\
+% | |\marg{style}\marg{entry}\marg{page-number}
+% \end{quote}
+% \begin{macrocode}
+\def\NCC@tocentry#1#2#3#4#5#6#7{%
+ \ifnum #1>\c@tocdepth \else
+ \par\begingroup\normalfont #2%
+ \let\applystyle\@firstoftwo
+% \end{macrocode}
+% Calculate the left margin in the |\@tempdimb| register
+% applying the |\l@tocskip@i|, \ldots, |\l@tocskip@|\meta{level-in-roman}
+% commands:
+% \begin{macrocode}
+ \@tempdimb\z@ \@tempcnta #1\relax
+ \@whilenum \@tempcnta >\z@\do
+ {\@nameuse{l@tocskip@\romannumeral \@tempcnta}%
+ \advance\@tempcnta\m@ne}%
+% \end{macrocode}
+% Prepare the |\NCC@maketocnum|\marg{tag} command creating
+% a number-line tag:
+% \begin{macrocode}
+ \def\NCC@maketocnum##1{\NCC@do{#5}{}{#3##1\NCC@atocnum}}%
+% \end{macrocode}
+% Calculate the hang indent value in |\@tempdima|:
+% \begin{macrocode}
+ \settowidth\@tempdima{\let\NCC@do\@firstoftwo\NCC@maketocnum{#4}}%
+% \end{macrocode}
+% Produce the toc-entry:
+% \begin{macrocode}
+ \@dottedtocline{#1}{\@tempdimb}{\@tempdima}%
+ {\let\NCC@do\@secondoftwo#5{\ignorespaces#6\unskip}}%
+ {\let\applystyle\@secondoftwo#5{#7}}%
+% \end{macrocode}
+% Allow break after toc-entry:
+% \begin{macrocode}
+ \@nobreakfalse
+ \endgroup
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@tocadj}
+% The command increases |\@tempdimb| on the width of the argument:
+% \begin{macrocode}
+\def\NCC@tocadj#1{\settowidth\@tempdima{#1}\advance\@tempdimb\@tempdima}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\numberline}
+% Redefine the |\numberline|\marg{tag} command to work correct
+% if the width of tag is greater than |\@tempdima|. The
+% tag is prepared with the |\NCC@maketocnum|\marg{tag} command.
+% \begin{macrocode}
+\def\numberline#1{%
+ \setbox\@tempboxa\hbox{\NCC@maketocnum{#1}}%
+ \ifdim \wd\@tempboxa > \@tempdima
+ \box\@tempboxa
+ \else
+ \hb@xt@\@tempdima{\unhbox\@tempboxa\hfil}%
+ \fi
+ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@maketocnum}
+% The default implementation of the |\NCC@maketocnum|\marg{tag} command.
+% We must define it because the |\numberline| command must
+% work out of scope of toc-entries.
+% \begin{macrocode}
+\def\NCC@maketocnum#1{#1\let\NCC@do\@secondoftwo\NCC@atocnum}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NumberlineSuffix}
+% The |\NumberlineSuffix|\marg{calc-suffix}\marg{actual-suffix}
+% command saves suffices inserted after number tag in the |\numberline|
+% command. It saves it in the |\NCC@atocnum| hook as parameters of
+% |\NCC@do| command. Letting the last one to |\@firstoftwo| or
+% |\@secondoftwo|, we select the \meta{calc-suffix} or \meta{actual-suffix}
+% respectively.
+% \begin{macrocode}
+\newcommand*{\NumberlineSuffix}[2]{\def\NCC@atocnum{\NCC@do{#1}{#2}}}
+\@onlypreamble\NumberlineSuffix
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\TOCMarginDrift}
+% The |\TOCMarginDrift|\marg{drift} specifies a drift of right margin
+% in TOC.
+% \begin{macrocode}
+\newcommand*\TOCMarginDrift[1]{%
+ \def\@tempa{#1}%
+ \ifx\@tempa\@empty \let\NCC@tocdrift\@empty
+ \else \def\NCC@tocdrift{\@plus #1\relax}\fi
+}
+\TOCMarginDrift{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PnumPrototype}
+% The |\PnumPrototype|\marg{prototype} command saves the page number
+% prototype in the |\NCC@pnum| hook and applies the |\NCC@setpnum|
+% command.
+% \begin{macrocode}
+\newcommand*{\PnumPrototype}[1]{\def\NCC@pnum{#1}\NCC@setpnum}
+\@onlypreamble\PnumPrototype
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@setpnum}
+% The |\NCC@setpnum| command calculates the page number widths in
+% |\@pnumwidth| and the toc right margin in |\@tocrmarg|.
+% If the toc-style is customizable, we recommend to apply this
+% command right after toc-styling commands to update margins
+% for the new toc-style.
+% \begin{macrocode}
+\def\NCC@setpnum{%
+ \settowidth\@tempdima{\NCC@pnum}%
+ \edef\@pnumwidth{\the\@tempdima}%
+ \advance\@tempdima 1em
+ \edef\@tocrmarg{\the\@tempdima \noexpand\NCC@tocdrift}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Service and Defaults}
+%
+% \begin{macro}{\StartFromTextArea}
+% The command is applied at the beginning of page
+% to set current position exactly at the first line
+% of text area.
+% \begin{macrocode}
+\newcommand\StartFromTextArea{\par
+ {\parskip\z@ \strut\par}\vskip -\baselineskip
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\StartFromHeaderArea}
+% The command is applied at the beginning of page
+% to set current position exactly at the header line.
+% \begin{macrocode}
+\newcommand\StartFromHeaderArea{%
+ \StartFromTextArea
+ \vskip -\headsep \vskip -\ht\strutbox
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bff}
+% The |\bff| command tries to set everything bold.
+% \begin{macrocode}
+\newcommand{\bff}{\normalfont\bfseries\mathversion{bold}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\startsection}
+% Define the |\startsection| command:
+% \begin{macrocode}
+\newcommand*{\startsection}[1]{%
+ \ifnum#1>\z@
+ \def\@tempa{\csname NCC@section\romannumeral#1\endcsname}%
+ \else
+ \ifnum#1=\z@
+ \def\@tempa{\NCC@mainsection}%
+ \else
+ \def\@tempa{\part}%
+ \fi
+ \fi
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\section}
+% \begin{macro}{\subsection}
+% \begin{macro}{\subsubsection}
+% \begin{macro}{\paragraph}
+% \begin{macro}{\subparagraph}
+% Set aliases for the positive section levels:
+% \begin{macrocode}
+\def\section{\startsection\@ne}
+\def\subsection{\startsection\tw@}
+\def\subsubsection{\startsection\thr@@}
+\def\paragraph{\startsection4}
+\def\subparagraph{\startsection5}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\caption}
+% Redefine the |\caption| command. We do this at the beginning
+% of document to reject possible redefinitions of captions
+% in other packages such as |float|. I think this is not the
+% |float|'s responsibility to decide where a caption must go on:
+% before or after the float body. And what about complicated
+% floats consisting of side floats and etc.? We also reset to zero
+% the |\abovecaptionskip| and |\belowcaptionskip| registers if they
+% are specified to provide partial compatibility with the |float|
+% package. If the registers are not specified (as in |ncc| class),
+% they are emulated with macros.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \def\caption{%
+ \ifx\@captype\@undefined
+ \@latex@error{\noexpand\caption outside float}\@ehd
+ \expandafter\@gobble
+ \else
+ \expandafter\@firstofone
+ \fi
+ {\csname NCC@cap@\@captype\endcsname}%
+ }%
+ \@ifundefined{abovecaptionskip}{\def\abovecaptionskip{\z@}}%
+ {\abovecaptionskip\z@}%
+ \@ifundefined{belowcaptionskip}{\def\belowcaptionskip{\z@}}%
+ {\belowcaptionskip\z@}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Register standard floats:
+% \begin{macrocode}
+\RegisterFloatType{figure}
+\RegisterFloatType{table}
+% \end{macrocode}
+%
+% Declare all sections and captions except the main section:
+% \begin{macrocode}
+\DeclareSection{-2}{table}{}{\z@}{10pt}{}
+\DeclareSection{-1}{figure}{}{10pt}{\z@}{}
+\DeclareSection*1{section}{}%
+ {3.5ex \@plus 1ex \@minus .2ex}%
+ {2.3ex \@plus .2ex}{\Large\bff}
+\DeclareSection*2{subsection}{}%
+ {3.25ex \@plus 1ex \@minus .2ex}%
+ {1.5ex \@plus .2ex}{\large\bff}
+\DeclareSection*3{subsubsection}{}%
+ {3ex \@plus 1ex \@minus .2ex}%
+ {1.5ex \@plus .2ex}{\normalsize\bff}
+\DeclareSection4{paragraph}{}%
+ {\NCC@runskip}{-1em}{\normalsize\bff}
+\DeclareSection5{subparagraph}[\parindent]{}%
+ {\NCC@runskip}{-1em}{\normalsize\bff}
+\@ifundefined{chapter}{
+% \end{macrocode}
+%
+% \begin{macro}{\part}
+% Declare the main section and toc-entries for the
+% article-like style:
+% \begin{macrocode}
+ \def\part{\startsection\z@}
+ \DeclareSection*0{part}{\Large\bff}%
+ {5ex \@plus 1ex \@minus .2ex}%
+ {4ex \@plus .2ex}{\huge\bff}
+ \DeclareTOCEntry{-2}{}{}{9}{}% table
+ \DeclareTOCEntry{-1}{}{}{9}{}% figure
+ \DeclareTOCEntry0{\runinsectionskip\def\@dotsep{1000}}{}{III}{\bff}[]
+ \DeclareTOCEntry1{\runinsectionskip}{}{9}{}
+ \DeclareTOCEntry2{}{}{9.9}{}
+ \DeclareTOCEntry3{}{}{9.9.9}{}
+}{
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\chapter}
+% Declare the main section, toc-entries for the
+% book-like style, and specify default epigraph parameters:
+% \begin{macrocode}
+ \def\chapter{\startsection\z@}
+ \DeclareSection*0{chapter}{\vspace{3ex}\huge\bff}{10ex}%
+ {8ex \@plus .2ex}{\Huge\bff}
+ \DeclareTOCEntry{-2}{}{}{9.9}{}% table
+ \DeclareTOCEntry{-1}{}{}{9.9}{}% figure
+ \DeclareTOCEntry0{\runinsectionskip\def\@dotsep{1000}%
+ \aftergroup\penalty\aftergroup\@highpenalty}{}{9}{\bff}
+ \DeclareTOCEntry1{}{}{9.9}{}[9.9]
+ \DeclareTOCEntry2{}{}{9.9.9}{}[9.9.9]
+ \DeclareTOCEntry3{}{}{}{}[\qquad]
+ \epigraphparameters{\StartFromHeaderArea\small\raggedleft}%
+ {.45\linewidth}{5\baselineskip}%
+ {\raggedleft\itshape}{\vspace{2ex}}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Declare other toc-entries:
+% \begin{macrocode}
+\DeclareTOCEntry4{}{}{}{}[\qquad]
+\DeclareTOCEntry5{}{}{}{}[\qquad]
+% \end{macrocode}
+%
+% Set defaults:
+% \begin{macrocode}
+\noindentaftersection
+\sectionstyle{hangindent}
+\SectionTagSuffix{\quad}
+\captionwidth{\linewidth}
+\captionstyle{default}
+\captiontagstyle{para}
+\CaptionTagSuffix{:\hskip .7em \@plus .2em \@minus .1em}
+\NumberlineSuffix{\quad}{\enskip}
+\PnumPrototype{99}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccstretch.dtx b/Master/texmf-dist/source/latex/ncctools/nccstretch.dtx
new file mode 100644
index 00000000000..8d942ef80e6
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccstretch.dtx
@@ -0,0 +1,74 @@
+% \iffalse
+%%
+%% File: nccstretch.dtx Copyright (C) 2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{nccstretch}
+%<package> [2004/11/30 v1.0 Text Stretch Package (NCC)]
+%
+% \changes{v1.0}{2004/11/30}{This version was uploaded to CTAN}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{nccstretch}
+\GetFileInfo{nccstretch.sty}
+\begin{document}
+\title{The \textsf{nccstretch} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccstretch.dtx}
+\end{document}
+%</driver>
+% \fi
+% \section{User Interface}
+%
+% \DescribeMacro{\stretchwith}
+% The package implements the command
+% \begin{quote}
+% |\stretchwith|\marg{foo}\marg{text}
+% \end{quote}
+% that stretches the \meta{text} parameter inserting the
+% \meta{foo} sequence between every pair of neighbour tokens of
+% the \meta{text}. Spaces in the text are ignored. So, to save
+% a space, you need to insert a backslash before it or enclose
+% a space in braces. If you do not want to insert \meta{foo}
+% between some tokens, enclose them in braces. While stretching,
+% all first-level braces are removed. The examples below
+% show some use cases (we delimit the results with rules to show
+% exactly how the command works):
+% \begin{center}\small%
+% \newcommand*\ruled[1]{\rule{.4pt}{2ex}#1\rule{.4pt}{2ex}}%
+% \begin{tabular}{@{}l@{\qquad}l@{}}
+% \textbf{Command} & \textbf{Result}\\
+% |\stretchwith{\,}{Proof\ of\ Theorem\ 1}| &
+% \ruled{\stretchwith{\,}{Proof\ of\ Theorem\ 1}}\\
+% |\stretchwith{.}{\ test{ }test{}\ \ {test}{\"e}}| &
+% \ruled{\stretchwith{.}{\ test{ }test{}\ \ {test}{\"e}}}\\
+% |\makebox[1.5\width]{\stretchwith{\hfill}{test\ test}}| &
+% \ruled{\makebox[1.5\width]{\stretchwith{\hfill}{test\ test}}}
+% \end{tabular}
+% \end{center}
+% \StopEventually{}
+%
+% \section{The Implementation}
+% \begin{macro}{\stretchwith}
+% The command is implemented using |\@tfor| cycle.
+% The |\@tempa| command contains a sequence to be inserted
+% before the next token. It is set to |\relax| before the
+% cycle and is set to \meta{foo} after every inserted token.
+% This trick allows insert \meta{foo} \textbf{between}
+% neighbour tokens only.
+% \begin{macrocode}
+%<*package>
+\newcommand*\stretchwith[2]{%
+ \let\@tempa\relax
+ \def\@tempb{#1}%
+ \@tfor\@tempc:=#2\do {\@tempa \@tempc \let\@tempa\@tempb}%
+}
+%</package>
+% \end{macrocode}
+% \end{macro}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/nccthm.dtx b/Master/texmf-dist/source/latex/ncctools/nccthm.dtx
new file mode 100644
index 00000000000..033ec5d7d84
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/nccthm.dtx
@@ -0,0 +1,1109 @@
+% \iffalse
+%%
+%% File: nccthm.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{nccthm}
+%<package> [2004/12/16 v1.1 NCC Extention to Theorems (NCC)]
+%
+% \changes{v1.02}{2002/01/31}{This version is uploaded to CTAN}
+% \changes{v1.03}{2002/02/17}{Break mode is turned off globally}
+% \changes{v1.04}{2002/05/19}{An extra group added in theorem headers
+% to scope font changes}
+% \changes{v1.05}{2002/06/07}{Bug in referencing in APAR mode fixed}
+% \changes{v1.06}{2003/01/13}{Spaces after label are ignored now}
+% \changes{v1.07}{2004/04/08}{Improvements in interpreting spaces after label}
+% \changes{v1.1}{2004/12/16}{In apar mode, ignore indent option if margin option used}
+% \changes{v1.1}{2004/12/16}{Documentation was prepared}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{desclist}
+\usepackage[blackqed,whiteqed]{nccthm}
+\countstyle[apar]{section}
+\newtheorem{theorem}{Theorem}
+\newtheorem*{atheorem}{Theorem}
+\TheoremBreakStyle
+\newtheorem{definition}{Definition}[remark]
+\TheoremNoBreakStyle
+\newtheorem{lemma}[theorem]{Lemma}
+\newcommand\Line{\qef\hrule height .4pt width \linewidth\nobreak
+ \qef}
+\GetFileInfo{nccthm.sty}
+\begin{document}
+\title{The \textsf{nccthm} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{nccthm.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \section{Overview}
+%
+% This is yet another extension of the \LaTeX\ theorem making
+% environment. Further, we'll call the \textit{theorem\/}
+% any mathematical statement consisting of one or more paragraphs,
+% and starting with a header containing an optional number.
+% A theorem is set off from the main text with an extra space.
+% Its title and body are often emphasized with a font change.
+%
+% In comparison with the |theorem| package by Frank Mittelbach and the
+% |amsthm| package by American Mathematical Society, the
+% |nccthm| package is distinct in the following:
+%
+% \paragraph{1} All new theorem environments generated with the
+% |nccthm| package use the \textit{dynamic counters\/} (see |dcounter|
+% package from this bungle for more details). As a result, this allows
+% a package writer to generate predefined theorems
+% and do not think on how they will be numbered, because the
+% decision is later made by a user.
+% For example, if you want all theorems to have enumeration
+% subordinated to sections, you need to write down the command
+% \begin{quote}
+% |\countstyle{section}|
+% \end{quote}
+% in the preamble. In this case, counters of all new theorems will be
+% set to zero at the beginning of every section and their enumeration
+% will be composed from the section number and the theorem counter number
+% itself. You can also change a enumeration style for concrete
+% counters (not only for dynamic counters) with the |\countstyle|
+% command specifying the list of counters in its optional parameter.
+% For example, if you prepare a book and want to subordinate
+% the equation and table counters to sections (they are subordinated to
+% chapters by default), write down in the preamble the following
+% \begin{quote}
+% |\countstyle[equation,table]{section}|
+% \end{quote}
+% The last example: to make a plain enumeration of sections
+% and reject their dependance on any other counter, write down
+% in the preamble |\countstyle[section]{}|.
+%
+% \paragraph{2} We have divided all theorem modification features into
+% three orthogonal groups.
+%
+% A \textit{type\/} defines font shapes used in the theorem.
+% Two types are predefined: \textit{theorem\/} and \textit{remark}.
+% You can define more types or redefine existing types.
+%
+% A \textit{mode\/} defines the precedence of number in the header.
+% In standard mode, a number goes after a theorem title.
+% The reverse mode (number starts header), named here the
+% \textit{APAR\/} mode, is special. All theorems using this mode
+% are counted with the same |apar| counter. To generate theorems
+% in the standard mode, the |\newtheorem| command is used.
+% The |\newtheorem*| command is used for generation \textit{apar\/}
+% theorems.
+%
+% A \textit{style\/} specifies the appearance of theorems.
+% It consists of three modifiers: \textit{breaking},
+% \textit{indentation},
+% and \textit{marginal numbering}. The breaking modifier determines
+% the separation of theorem header from theorem body (run-in header
+% or line break after header). The indentation modifier has two
+% values: \textit{noindent\/} and \textit{parindent}. It
+% defines an indentation style of a theorem header.
+% The marginal numbering modifier affects on apar theorems:
+% in \textit{margin\/} style, the number of an apar theorem
+% is typed on margins; in \textit{nomargin\/}
+% style, the number starts a paragraph.
+%
+% The breaking modifier is controlled with special commands but other
+% modifiers are specified with package options.
+%
+% \paragraph{3} We do not base the implementation of theorems
+% on the |trivlist| environment. This allows us to use two methods
+% of theorem markup: environment-like markup (|\begin{theorem}| \ldots\
+% |\end{theorem}|) or command-like markup (|\theorem| \ldots |\qef|).
+% The |\qef| command is used as the end of any theorem. It resets the
+% font to the normal font and produces a vertical skip.
+% The command-like markup is useful in apar theorems.
+%
+% \paragraph{4} Service commands are introduced. Using package options
+% you can select a type of Q.E.D.\ symbol: black or white. You can use
+% both of them. The |\proof| command starts a proof of statement.
+% We have no |proof| environment, because the proof is prepared in
+% the normal font. To complete a proof, use |\qed| or |\qef|
+% (the first one additionally prints the right adjusted Q.E.D. symbol).
+% You can easy customize delimiters of theorem and proof headers.
+%
+% \section{Quod Erat Demonstrandum}
+%
+% The Q.E.D. symbol is usually used at the end of proof of a
+% math statement. Sometimes, another symbol finishes a math
+% statement itself. The package allows using two types of Q.E.D.
+% symbols: black (\blackqedsymbol) and white (\whiteqedsymbol).
+%
+% \DescribeMacro\qedsymbol
+% The default Q.E.D. symbol is white. It is printed with the
+% |\qedsymbol| command.
+%
+% \DescribeMacro\qed
+% \DescribeMacro\qef
+% The |\qed| command is used to finish a proof. It prints
+% right-adjusted Q.E.D. symbol and applies the |\qef| command
+% (it finishes this paragraph).
+% The |\qef| command finishes a paragraph,
+% changes the current font to the normal font, and skips
+% a |\paragraph|-like vertical space.
+% \qed
+%
+% \DescribeMacro{\qed*}
+% The star-form of |\qed| command prints the Q.E.D. symbol
+% but not applies the |\qef| command.
+%
+% The usage of the above mentioned commands at the end of
+% proof is the following: if the proof end with an ordinary
+% paragraph, use the |\qed| command at its end; if the
+% proof ends with a list, use the |\qed*| command at
+% the end of the last list item and the |\qef|
+% command after the end of list; and if the proof ends
+% with a display formula, use the |\qedsymbol| command
+% as its tag (|\tag*{\qedsymbol}| when use the
+% |amsmath| package).
+%
+%
+% \DescribeMacro{\blackqed}
+% \DescribeMacro{\blackqedsymbol}
+% If you load the package with the `|blackqed|' option, two
+% additional commands are generated, |\blackqedsymbol| and |\blackqed|.
+% The default |\qedsymbol| and |\qed| commands are let to be
+% equal to their black versions.
+%
+% \DescribeMacro{\whiteqed}
+% \DescribeMacro{\whiteqedsymbol}
+% Analogously, the `|whiteqed|' option generates the
+% |\whiteqedsymbol| and\linebreak |\whiteqed| commands and lets
+% the default |\qedsymbol| and |\qed| commands to be
+% equal to their white versions.
+%
+% If both these options are used, the default
+% |\qedsymbol| and |\qed| commands are let to be equal
+% the version loaded last. For example, the following command
+% loads both versions of Q.E.D. and lets the white
+% version to be the default version:
+% \begin{quote}
+% |\usepackage[blackqed,whiteqed]{nccthm}|
+% \end{quote}
+%
+% \section{Other Package Options}
+%
+% The package loads options in the order they are written
+% in the options list. Along with the `|blackqed|' and `|whiteqed|'
+% options described above, the following options are available:
+% \begin{desclist}{\tt}{\hfill}[nomargin]
+% \item[noindent] theorems are typed without indentation;
+% \item[indent] theorems are typed with paragraph indentation;
+% \item[nomargin] numbers for theorems in apar mode are typed normally;
+% \item[margin] numbers for theorems in apar mode are typed on margin.
+% \end{desclist}
+%
+% The default options are |noindent| and |nomargin|. The following
+% examples show how the combinations of |(no)indent| and |(no)margin|
+% options interact.
+%
+% \liketheorem{Theorem}{1} The standard theorem in the |noindent + nomargin| style.\qef
+% \likeremark*{Remark} The apar theorem in the |noindent + nomargin| style.\qef
+% \makeatletter\NCC@thmindenttrue\NCC@thmmarginfalse\makeatother
+% \liketheorem{Theorem}{2} The standard theorem in the |indent + nomargin| style.\qef
+% \likeremark*{Remark} The apar remark in the |indent + nomargin| style.\qef
+% \makeatletter\NCC@thmindentfalse\NCC@thmmargintrue\makeatother
+% \liketheorem*{Theorem} The apar theorem in the |noindent + margin| style.\qef
+% \makeatletter\NCC@thmindenttrue\NCC@thmmargintrue\makeatother
+% \likeremark*{Remark} The apar remark in the |indent + margin| style.\qef
+% \makeatletter\NCC@thmindentfalse\NCC@thmmarginfalse\makeatother
+%
+% As you can see, mixing of all these styles in the same document
+% leads to bad results. This is the reason why these styles are
+% implemented using options.
+%
+% As you can also see from the last example,
+% the |indent| style is ignored for apar theorems typed in
+% the |margin| style.
+%
+% \section{Structure and Types of Theorems}
+%
+% The structure of a theorem is the following:
+% \begin{desclist}{}{\hfill}[\meta{normal-header}\quad]
+% \item[\meta{theorem}] \meta{header} \meta{space-or-break} \meta{body}
+% \item[\meta{header}] \meta{normal-header} \verb+|+ \meta{apar-header}
+% \item[\meta{normal-header}] \meta{title} \oarg{number} \oarg{comment} \meta{after-char}
+% \item[\meta{apar-header}] \meta{apar-tag} \meta{title} \oarg{comment} \meta{after-char}
+% \end{desclist}
+% A theorem type controls the appearance of the following elements
+% of theorems: \meta{title}, \meta{comment}, and \meta{body}.
+% The \meta{number} element inherits the style from \meta{title}.
+% The \meta{after-char} element inherits either the style of \meta{comment}
+% if it presents or the style of \meta{title} otherwise. The style of \meta{apar-tag}
+% is controlled with the special way and will be described later.
+%
+% \DescribeMacro{\newtheoremtype}
+% \DescribeMacro{\renewtheoremtype}
+% The package provides the following theorem type generation commands:
+% \begin{quote}
+% |\newtheoremtype|\marg{type}\marg{title-style}\marg{comment-style}\marg{body-style}\\
+% |\renewtheoremtype|\marg{type}\marg{title-style}\marg{comment-style}\marg{body-style}
+% \end{quote}
+% The \meta{type} parameter is a type name. Other parameters
+% specify fonts to be used in the corresponding parts of a
+% theorem.
+% Font style parameters are considered to be used after the
+% |\normalfont| command.
+%
+% \DescribeMacro{\like...}
+% When a new theorem type is generated, the |\like|\meta{type} command
+% is created for it. It has two forms: normal and starred. The normal version
+% prints a theorem in the standard mode and the starred version prints
+% an apar theorem. The syntax:
+% \begin{quote}
+% |\like|\meta{type}\marg{title}\marg{number}\oarg{comment}\\
+% |\like|\meta{type}*\marg{title}\oarg{comment}
+% \end{quote}
+% The starred version of this command has no \meta{number} argument, because
+% it is numbered using the |apar| counter.
+% If the \meta{number} argument in the non-starred version of this command
+% is empty, the number will be omitted in the theorem header.
+% If the \meta{comment} argument presents, the comment is typed enclosed
+% in round brackets. This behaviour can be changed with customization
+% commands.
+%
+% Two theorem types, `|theorem|' and `|remark|', are predefined as follows:
+% \begin{quote}
+% |\newtheoremtype{theorem}{\bfseries}{}{\itshape}|\\
+% |\newtheoremtype{remark}{\itshape}{}{}|
+% \end{quote}
+%
+% \DescribeMacro\liketheorem
+% \DescribeMacro\likeremark
+% Using the |\liketheorem| and |\likeremark| commands, you can
+% produce a\linebreak theorem of the given type with arbitrary title without
+% generation a special environment for it. It is very useful
+% if a theorem with the given title appears in a document only once.
+%
+% \textbf{Note:} Type generation commands are available in the
+% preamble only.
+%
+% \section{Generate New Theorems}
+%
+% \DescribeMacro\newtheorem
+% A standard theorem environment is generated with the
+% |\newtheorem| command:
+% \begin{quote}
+% |\newtheorem|\marg{env-name}\oarg{counter}\marg{title}\oarg{type}
+% \end{quote}
+% In comparison with the standard \LaTeX\ version of this command,
+% the last optional
+% parameter has another meaning: it specifies a theorem type.
+% This is because its standard meaning (the base counter)
+% useless here. If the \meta{type} parameter is omitted,
+% the `|theorem|' type is used. The optional argument \meta{counter}
+% is a counter this environment will be counted with. If it is
+% omitted, the counter name equal to the \meta{env-name} is used.
+% We do not test the \meta{counter} on existence when
+% a new theorem environment is generated. The theorem counter is declared
+% to be the dynamic counter. It is defined at the first use and
+% inherits the style declared by the latest use of the command
+% \begin{quote}
+% |\countstyle|\marg{base-counter}
+% \end{quote}
+% Its argument contains a name of base-counter for all dynamically
+% created counters. Dynamically created counter is set to zero when the
+% base counter is stepped. Its |\the| command is the following:
+% \begin{quote}
+% |\the|\meta{base-counter}.|\arabic|\marg{dynamic-counter}
+% \end{quote}
+% If the \meta{base-counter} is empty, a dynamic counter will be
+% numbered in the plain style.
+%
+% \qef
+% \textbf{Note:} In contrast with the standard definition,
+% the described |\newtheorem| command may be used with all
+% four parameters.
+%
+% \qef
+% \DescribeMacro{\newtheorem*}
+% To generate a new apar theorem environment, the starred version of
+% the |\newtheorem| command is applied:
+% \begin{quote}
+% |\newtheorem*|\marg{env-name}\marg{title}\oarg{type}
+% \end{quote}
+% All apar theorems are counted with the `|apar|' counter.
+%
+% \DescribeMacro{\renewtheorem}
+% \DescribeMacro{\renewtheorem*}
+% You can also redefine already defined theorem environments
+% using the commands
+% \begin{quote}
+% |\renewtheorem|\marg{env-name}\oarg{counter}\marg{title}\oarg{type}\\
+% |\renewtheorem*|\marg{env-name}\marg{title}\oarg{type}
+% \end{quote}
+% While redefinition a theorem environment, you can change values of
+% all other parameters after \meta{env-name}.
+%
+% \DescribeMacro\TheoremBreakStyle
+% \DescribeMacro\TheoremNoBreakStyle
+% When a theorem environment is defined or redefined, a decision
+% what must be inserted after the theorem header (space or break)
+% is made on the base of current break style. The
+% |\TheoremBreakStyle| and |\TheoremNoBreakStyle| commands change
+% this style to the `break' and `no-break' respectively. The default
+% style is `no-break'.
+%
+% \textbf{Note:} Theorem generation commands are available in the preamble only.
+%
+% \section{Using Theorems}
+%
+% The syntax of using theorem environments is the following:
+% \begin{quote}
+% |\begin|\marg{env-name}\oarg{comment} \meta{body}
+% |\end|\marg{env-name}
+% \end{quote}
+% You can also use the command-like syntax:
+% \begin{quote}
+% |\|\meta{env-name}\oarg{comment} \meta{body} |\qef|
+% \end{quote}
+% which is more likely for apar theorems.
+%
+% \DescribeMacro\breakafterheader
+% \DescribeMacro\nobreakafterheader
+% You can change a break style for a theorem applying
+% the |\breakafterheader| and |\nobreakafterheader| commands
+% just before using the theorem.
+%
+% Let us do the following in the preamble:
+% \begin{quote}
+% |\countstyle[apar]{section}|\\
+% |\newtheorem{theorem}{Theorem}|\\
+% |\newtheorem*{atheorem}{Theorem}|\\
+% |\TheoremBreakStyle|\\
+% |\newtheorem{definition}{Definition}[remark]|\\
+% |\TheoremNoBreakStyle|\\
+% |\newtheorem{lemma}[theorem]{Lemma}|
+% \end{quote}
+% This code generates 4 theorem environments: the `|theorem|' provides a
+% standard Theorem statement;
+% the `|atheorem|' provides a Theorem statement in the apar mode
+% with per-section numbering;
+% the `|definition|' provides a standard Definition statement
+% prepared as a remark; and the `|lemma|' provides a standard
+% Lemma statement counted with the |theorem| counter. Definitions
+% are printed in the break style.
+%
+% \begin{quote}
+% |\begin{theorem} A theorem. \end{theorem}|\\
+% |\begin{lemma} A lemma. \end{lemma}|\\
+% |\breakafterheader|\\
+% |\begin{theorem}[A comment] A theorem with break.\end{theorem}|\\
+% |\atheorem A theorem in apar mode. \qef|\\
+% |\begin{definition} A definition. \end{definition}|
+% \end{quote}
+% This code produces the following:
+% \Line
+% \begin{theorem} A theorem. \end{theorem}
+% \begin{lemma} A lemma. \end{lemma}
+% \breakafterheader
+% \begin{theorem}[A comment] A theorem with break.\end{theorem}
+% \atheorem A theorem in apar mode. \qef
+% \begin{definition} A definition. \end{definition}
+% \Line
+%
+% To prepare a theorem without number or having a special number,
+% use the |\like|\meta{type} command. Examples:
+% \begin{quote}
+% |\liketheorem{Theorem}{A} Special theorem.\qef|\\
+% |\liketheorem{Proposition}{}[Comment] It has no number.\qef|\\
+% |\breakafterheader|\\
+% |\likeremark{Example}{2.3.5} An example.\qef|\\
+% |\likeremark*{Remark} An apar remark. \qef|
+% \end{quote}
+% This code produces the following:
+% \Line
+% \liketheorem{Theorem}{A} Special theorem.\qef
+% \liketheorem{Proposition}{}[Comment] It has no number.\qef
+% \breakafterheader
+% \likeremark{Example}{2.3.5} An example.\qef
+% \likeremark*{Remark} An apar remark. \qef
+% \Line
+%
+% \DescribeMacro\proof
+% The |\proof| command prints the proof of a math statement. Syntax:
+% \begin{quote}
+% |\proof|\oarg{of-theorem} \meta{body} |\qed|
+% \end{quote}
+% The optional parameter \meta{of-theorem} contains a
+% text appended to the title of proof. The break-style change
+% commands can be applied to this command. Examples:
+% \begin{quote}
+% |\proof An ordinary proof.\qed|\\
+% |\proof[of Theorem A] A special proof.\qed|\\
+% |\breakafterheader|\\
+% |\proof[of the Pythagor Theorem] A proof.\qed|
+% \end{quote}
+% This code produces the following:
+% \Line
+% \proof An ordinary proof.\qed
+% \proof[of Theorem A] A special proof.\qed
+% \breakafterheader
+% \proof[of the Pythagor Theorem] A proof.\qed
+% \Line
+%
+% \section{Apar Sections}
+%
+% Header of an apar theorem is similar to the header printed
+% by the |\paragraph| or |\subparagraph| command (except
+% paragraph numbering that is usually omitted).
+% Moreover, from the logical point of view, the apar
+% theorems are specially designed enumerated paragraphs.
+% Therefore, it is a good idea to use apar markup
+% as some kind of special sectioning.
+%
+% \DescribeMacro\apar
+% The following command supports sectioning in the apar mode:
+% \begin{quote}
+% |\apar|\oarg{title}
+% \end{quote}
+% It produces a new paragraph starting with the \meta{apar-tag}
+% element and having the optional title. The indentation style and
+% marginal style of apar section is the same as for apar theorems.
+% The vertical skip before
+% the apar section is just the same as before theorems.
+% If the |nccsect| package is loaded, the apar skip is equal
+% to the skip produced with the |\paragraph| and |\subparagraph|
+% commands.
+%
+% These properties of apar sections are useful in design of
+% articles having short sections. For example, if an article
+% consists of many short sections prepared with the |\subsection|
+% command, it looks very loose, because subsections are produced
+% in the display style. It will be better to allow subsections
+% run-in paragraph. Using the |\apar| command, you can do this
+% very easy: add the following command to the preamble
+% \begin{quote}
+% |\countstyle[apar]{section}|
+% \end{quote}
+% and prepare subsections with the |\apar| command. Example:
+% \begin{quote}
+% |\apar[Subsection title] Subsection body ...|\\
+% |\apar[Next title:] The body ...|\\
+% |\atheorem In fact, this is a special apar section ...|\\
+% |\apar Subsection without title ...|\\
+% |\breakafterheader|\\
+% |\apar[One more title] Break before its body|
+% \end{quote}
+% This code produces the following:
+% \Line
+% \apar[Subsection title] Subsection body ...
+% \apar[Next title:] The body ...
+% \atheorem In fact, this is a special apar section ...
+% \apar Subsection without title ...
+% \breakafterheader
+% \apar[One more title] Break before its body
+% \Line
+%
+% \section{Customization Commands}
+%
+% \DescribeMacro{\NCC@runskip}
+% The vertical skips before and after theorems are identic. They are
+% produced with the |\qef| command. The length of the skip is coded
+% in the inner command |\NCC@runskip|. This command is also used in
+% the |nccsect| package as a skip inserted before the |\paragraph|
+% and |\subparagraph| commands. Its default value
+% \begin{quote}
+% |2.75ex plus 1ex minus 0.2ex|
+% \end{quote}
+%
+% \DescribeMacro{\TheoremCommentDelimiters}
+% The |\TheoremCommentDelimiters|\marg{left}\marg{right} command
+% specifies delimiters inserted before and after a theorem comment.
+% The default setting is:
+% \begin{quote}
+% |\TheoremCommentDelimiters{(}{)}|
+% \end{quote}
+%
+% \DescribeMacro{\AfterTheoremHeaderChar}
+% The |\AfterTheoremHeaderChar|\marg{after-char} command
+% specifies an \meta{after-char} element that ends
+% header of theorem and header of proof. The default setting is
+% an empty element.
+%
+% \DescribeMacro{\AfterTheoremHeaderSkip}
+% The |\AfterTheoremHeaderSkip|\marg{skip-command} command
+% specifies a command inserted between theorem header and body.
+% In break style, this command is ignored.
+% The default setting is:
+% \begin{quote}
+% |\AfterTheoremHeaderSkip{\hskip 1em plus 0.2em minus 0.2em}|
+% \end{quote}
+%
+% \DescribeMacro\ProofStyleParameters
+% The |\ProofStyleParameters|\marg{style}\marg{title} command
+% specifies style parameters used in the |\proof|
+% command: the first one is a font style and the last one
+% is a proof title. The default setting is:
+% \begin{quote}
+% |\ProofStyleParameters{\bfseries}{Proof}|
+% \end{quote}
+%
+% \DescribeMacro\AparStyleParameters
+% The |\AparStyleParameters|\marg{style}\marg{prefix}\marg{suffix}
+% command specifies the style of apar sections: the \meta{style}
+% is a style of apar section title; the tag of apar theorems
+% and sections is prepared using \meta{prefix} and \meta{suffix}
+% specified with this command as follows
+% \meta{prefix}|\theapar|\meta{suffix}. The default setting is:
+% \begin{quote}
+% |\AparStyleParameters{\bfseries}{\bfseries}{\enskip}|
+% \end{quote}
+%
+% \qef
+% \textbf{Note:} All customization commands except the
+% |\NCC@runskip| are allowed in the preamble only.
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% \begin{macro}{\NCC@secskip}
+% \begin{macro}{\NCC@runskip}
+% The package shares the following commands with the
+% |nccsect| package:
+% \begin{quote}
+% |\NCC@secskip|\marg{skip} adds the \meta{skip} before a section,\\
+% |\NCC@runskip| is a skip inserted before run-in sections.
+% \end{quote}
+% We protect the definitions of these commands with testing
+% the |nccsect| package to be already loaded.
+% \begin{macrocode}
+%<*package>
+\@ifpackageloaded{nccsect}{}{%
+ \def\NCC@secskip#1{%
+ \if@noskipsec \leavevmode \fi \par
+ \if@nobreak \everypar{}\else
+ \addpenalty\@secpenalty
+ \addvspace{#1}%
+ \fi
+ }
+ \def\NCC@runskip{2.75ex \@plus 1ex \@minus .2ex}
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Q.E.D. Support}
+%
+% \begin{macro}{\NCC@qedsymbol}
+% \begin{macro}{\qedsymbol}
+% The |\NCC@qedsymbol| command is the base implementation
+% of white Q.E.D. symbol.
+% If no Q.E.D. selection options used, the
+% |\qedsymbol| is equal to the base version.
+% \begin{macrocode}
+\DeclareRobustCommand{\NCC@qedsymbol}{%
+ \mbox{\normalsize\normalfont\thinlines \@tempdima 1.5ex
+ \advance\@tempdima-2\@wholewidth
+ \edef\@tempa{\the\@tempdima}%
+ \kern \@wholewidth
+ \raisebox\@wholewidth[1.5ex]{%
+ \frame{\rule\z@\@tempa\rule\@tempa\z@}}%
+ \kern \@wholewidth
+ }%
+}
+\let\qedsymbol\NCC@qedsymbol
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\qed}
+% \begin{macro}{\qed*}
+% The |\qed| command produces the flush-right Q.E.D. symbol
+% and applies the |\qef| command in the non-starred case.
+% \begin{macrocode}
+\newcommand{\qed}{\NCC@qed{\qedsymbol}}
+\def\NCC@qed#1{\unskip\allowbreak%
+ \hspace*{1em plus 1fill minus .2em}#1\@ifstar{}{\qef}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\qef}
+% The |\qef| finishes a paragraph, adds the |\@secpenalty|,
+% and produces the vertical skip of |\NCC@runskip| size.
+% If also sets the normal font and removes the no-break
+% condition suppressing indentation in the next
+% paragraph.
+% \begin{macrocode}
+\newcommand{\qef}{\NCC@secskip{\NCC@runskip}\@nobreakfalse\normalfont}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Package Options}
+%
+% \begin{macro}{\whiteqedsymbol}
+% \begin{macro}{\whiteqed}
+% The `|whiteqed|' option:
+% \begin{macrocode}
+\DeclareOption{whiteqed}{%
+ \let\whiteqedsymbol\NCC@qedsymbol
+ \newcommand{\whiteqed}{\NCC@qed{\whiteqedsymbol}}
+ \let\qedsymbol\whiteqedsymbol
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\blackqedsymbol}
+% \begin{macro}{\blackqed}
+% The `|blackqed|' option:
+% \begin{macrocode}
+\DeclareOption{blackqed}{%
+ \DeclareRobustCommand{\blackqedsymbol}{%
+ \begingroup\normalsize\normalfont\thinlines
+ \rule{1.5ex}{1.5ex}\endgroup
+ }
+ \newcommand{\blackqed}{\NCC@qed{\blackqedsymbol}}
+ \let\qedsymbol\blackqedsymbol
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ifNCC@thmindent}
+% \begin{macro}{\ifNCC@thmmargin}
+% Theorem indentation and marginal numbering options
+% are based on two if-macros:
+% the |NCC@thmindent| controls the indentation of headers and
+% the |NCC@thmmargin| controls the marginal numbering in
+% the apar mode.
+% \begin{macrocode}
+\newif\ifNCC@thmindent
+\newif\ifNCC@thmmargin
+\DeclareOption{noindent}{\NCC@thmindentfalse}
+\DeclareOption{indent}{\NCC@thmindenttrue}
+\DeclareOption{nomargin}{\NCC@thmmarginfalse}
+\DeclareOption{margin}{\NCC@thmmargintrue}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Set defaults and process all options in the order
+% they appear in the options list.
+% \begin{macrocode}
+\ExecuteOptions{noindent,nomargin}
+\ProcessOptions*
+% \end{macrocode}
+%
+% \subsection{The Kernel}
+%
+% We use the |\@ifempty| command from the |amsgen| package
+% and dynamic counters from the |dcounter| package.
+% \begin{macrocode}
+\RequirePackage{amsgen}
+\RequirePackage{dcounter}[1998/12/19]
+% \end{macrocode}
+%
+% \begin{macro}{\NCC@thmbrmode}
+% \begin{macro}{\ifNCC@thmbr}
+% A theorem break mode is controlled with the |\NCC@thmbrmode|
+% macro and the |\ifNCC@thmbr|. The |\NCC@thmbrmode| can have
+% three possible values:
+% \begin{desclist}{}{\hfill}[\cs{relax}\ ]
+% \item[\cs{relax}] undefined mode;
+% \item[\cs{z@}] break mode;
+% \item[\cs{@ne}] no-break mode.
+% \end{desclist}
+% If the break mode is undefined, the decision is made on the
+% analyzes of the |NCC@thmbr| value: true value means break,
+% false value means no-break.
+% \begin{macrocode}
+\let\NCC@thmbrmode\relax
+\newif\ifNCC@thmbr
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\breakafterheader}
+% \begin{macro}{\nobreakafterheader}
+% The |\breakafterheader| and |\nobreakafterheader|
+% commands test the current break mode and set an
+% appropriate mode if it is undefined yet. As a result,
+% usage of these commands before a theorem leads to
+% overriding the default break mode specified in
+% theorem's macro.
+% \begin{macrocode}
+\newcommand\breakafterheader{%
+ \ifx\NCC@thmbrmode\relax \global\chardef\NCC@thmbrmode\z@\fi
+}
+\newcommand\nobreakafterheader{%
+ \ifx\NCC@thmbrmode\relax \global\chardef\NCC@thmbrmode\@ne\fi
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\TheoremBreakStyle}
+% \begin{macro}{\TheoremNoBreakStyle}
+% \begin{macro}{\TheoremCommentDelimiters}
+% \begin{macro}{\AfterTheoremHeaderChar}
+% \begin{macro}{\AfterTheoremHeaderSkip}
+% Theorem customization commands:
+% \begin{macrocode}
+\newcommand{\TheoremBreakStyle}{\NCC@thmbrtrue}
+\newcommand{\TheoremNoBreakStyle}{\NCC@thmbrfalse}
+\newcommand*{\TheoremCommentDelimiters}[2]{%
+ \def\NCC@thmcmt@##1{#1\ignorespaces##1\unskip#2}%
+}
+\newcommand*{\AfterTheoremHeaderChar}[1]{\def\NCC@thmchar{#1}}
+\newcommand*{\AfterTheoremHeaderSkip}[1]{\def\NCC@thmskip{#1}}
+\@onlypreamble\TheoremBreakStyle
+\@onlypreamble\TheoremNoBreakStyle
+\@onlypreamble\TheoremCommentDelimiters
+\@onlypreamble\AfterTheoremHeaderChar
+\@onlypreamble\AfterTheoremHeaderSkip
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\NCC@thmhdr}
+% The |\NCC@thmhdr|\marg{style}\marg{header} prints a theorem header
+% in the required \meta{style} and implements the current break mode.
+% At the end of macro, the break mode is reset to |\relax|.
+% The header is prepared in a group.
+% \begin{macrocode}
+\def\NCC@thmhdr#1#2{%
+ \qef
+% \end{macrocode}
+% Insert a negative low penalty to increase a chance of
+% page break before the beginning of theorem.
+% \begin{macrocode}
+ \addpenalty{-\@lowpenalty}%
+ \begingroup
+ #1%
+% \end{macrocode}
+% Test the break mode. If it is undefined, we set it basing
+% on the value of |\ifNCC@thmbr| switch.
+% \begin{macrocode}
+ \ifx\NCC@thmbrmode\relax
+ \ifNCC@thmbr \chardef\NCC@thmbrmode\z@
+ \else \chardef\NCC@thmbrmode\@ne
+ \fi
+ \fi
+% \end{macrocode}
+% The break case: to implement the break in the vertical
+% mode, it is enough to put the header in hbox. To allow
+% multi-line header, we prepare it in inner vbox.
+% \begin{macrocode}
+ \ifnum\NCC@thmbrmode=\z@
+ \@tempdima\parindent
+ \hbox{\vbox{\hsize\linewidth\@parboxrestore
+ \ifNCC@thmindent\parindent\@tempdima\fi
+ \leavevmode\strut#2\strut
+ }}\nobreak\noindent
+% \end{macrocode}
+% The no-break case: The |\ncc@thmskip| command
+% \begin{macrocode}
+ \else
+ \ifNCC@thmindent\else\noindent\fi
+ \leavevmode{#2\normalfont\NCC@thmskip}\nobreak
+ \fi
+ \endgroup
+% \end{macrocode}
+% Reset the break mode to the initial value:
+% \begin{macrocode}
+ \global\let\NCC@thmbrmode\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@thmcmt}
+% The |\NCC@thmcmt|\marg{comment-style}\marg{comment} tests
+% a comment to be nonempty and produces it in corresponding style.
+% \begin{macrocode}
+\def\NCC@thmcmt#1#2{%
+ \@ifempty{#2}{}{\/\space\normalfont#1\NCC@thmcmt@{#2}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@lthm}
+% Standard mode basic command:
+% \begin{quote}
+% |\NCC@lthm|\marg{header-style}\marg{comment-style}\marg{body-style}\marg{title}\\
+% | |\marg{number}\oarg{comment}
+% \end{quote}
+% \begin{macrocode}
+\def\NCC@lthm#1#2#3#4#5{%
+ \@ifnextchar[{\NCC@lthm@{#1}{#2}{#3}{#4}{#5}}%
+ {\NCC@lthm@{#1}{#2}{#3}{#4}{#5}[]}%
+}
+\def\NCC@lthm@#1#2#3#4#5[#6]{%
+% \end{macrocode}
+% Prepare theorem header.
+% \begin{macrocode}
+ \NCC@thmhdr{}{%
+ #1#4\@ifempty{#5}{}{\space#5}%
+ \NCC@thmcmt{#2}{#6}\NCC@thmchar
+ }%
+% \end{macrocode}
+% Set the body style and do a small skip to avoid extra
+% space after the |\label| command.
+% \begin{macrocode}
+ #3\hskip 0.001\p@ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@thxhdr}
+% The |\NCC@thxhdr|\marg{style}\marg{header} produces an apar theorem
+% header.
+% \begin{macrocode}
+\def\NCC@thxhdr#1#2{%
+ \refstepcounter{apar}%
+ \NCC@thmhdr{%
+% \end{macrocode}
+% In margin style, the indent style is turned off for apar theorems:
+% \begin{macrocode}
+ \ifNCC@thmmargin \NCC@thmindentfalse \fi
+ #1%
+ }{%
+% \end{macrocode}
+% Put the \meta{apar-tag} (prepared in the |\NCC@thmapar| command)
+% before the header using |\llap| or |\hbox|. Then put the header.
+% \begin{macrocode}
+ \ifNCC@thmmargin \llap{\NCC@thmapar}\else \hbox{\NCC@thmapar}\fi
+ #2%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@lthx}
+% Apar mode basic command:
+% \begin{quote}
+% |\NCC@lthx|\marg{header-style}\marg{comment-style}\marg{body-style}\marg{title}\\
+% | |\oarg{comment}
+% \end{quote}
+% \begin{macrocode}
+\def\NCC@lthx#1#2#3#4{%
+ \@ifnextchar[{\NCC@lthx@{#1}{#2}{#3}{#4}}%
+ {\NCC@lthx@{#1}{#2}{#3}{#4}[]}%
+}
+\def\NCC@lthx@#1#2#3#4[#5]{%
+ \NCC@thxhdr{}{%
+ \normalfont#1#4\NCC@thmcmt{#2}{#5}\NCC@thmchar
+ }%
+ #3\hskip 0.001\p@ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NCC@likethm}
+% The base for |\like|\meta{type} commands. It passes the control
+% to |\NCC@lthm| or |\NCC@lthx| depending on the star appearing
+% after the third parameter:
+% \begin{quote}
+% |\NCC@likethm|\marg{header-style}\marg{comment-style}\marg{body-style}\marg{title}\\
+% | |\marg{number}\oarg{comment}\\
+% |\NCC@likethm|\marg{header-style}\marg{comment-style}\marg{body-style}|*|\marg{title}\\
+% | |\oarg{comment}
+% \end{quote}
+% \begin{macrocode}
+\def\NCC@likethm#1#2#3{%
+ \@ifstar{\NCC@lthx{#1}{#2}{#3}}{\NCC@lthm{#1}{#2}{#3}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Apar Sections}
+%
+% The counter used in the apar mode is dynamic:
+% \begin{macrocode}
+\DeclareDynamicCounter{apar}
+% \end{macrocode}
+%
+% \begin{macro}{\AparStyleParameters}
+% Apar style parameters provider:
+% \begin{macrocode}
+\newcommand*{\AparStyleParameters}[3]{%
+ \def\NCC@thmaparstyle{#1}%
+ \def\NCC@thmapar{#2\theapar#3}%
+}
+\@onlypreamble\AparStyleParameters
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\apar}
+% The |\apar|\oarg{title} command starts a new apar-numbered
+% paragraph. If the \meta{title} is omitted or empty,
+% we must ignore the |\NCC@thmskip|.
+% \begin{macrocode}
+\newcommand*{\apar}[1][]{%
+ \NCC@thxhdr{\NCC@thmaparstyle}
+ {\@ifempty{#1}{\let\NCC@thmskip\@empty}{\ignorespaces#1\unskip}}%
+ \hskip 0.001\p@ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Proof of Theorem}
+%
+% \begin{macro}{\ProofStyleParameters}
+% Proof style parameters provider:
+% \begin{macrocode}
+\newcommand*{\ProofStyleParameters}[2]{%
+ \def\NCC@thmproofstyle{#1}%
+ \def\NCC@thmproof{#2}%
+}
+\@onlypreamble\ProofStyleParameters
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\proof}
+% The |\proof|\oarg{of-theorem} command:
+% \begin{macrocode}
+\newcommand*{\proof}[1][]{%
+ \NCC@thmhdr{\NCC@thmproofstyle}{%
+ \NCC@thmproof
+ \@ifempty{#1}{}{\space\ignorespaces#1\unskip}%
+ \NCC@thmchar
+ }%
+ \hskip 0.001\p@ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Generate New Theorem Types}
+%
+% \begin{macro}{\like...}
+% New theorem type generation means definition a |\like|\meta{type}
+% command preparing theorems of corresponding type.
+% The syntax of a |\like|\meta{type} command is
+% the following:
+% \begin{quote}
+% |\like|\meta{type}\marg{title}\marg{number}\oarg{comment}\\
+% |\like|\meta{type}|*|\marg{title}\oarg{comment}
+% \end{quote}
+% The first one produces a standard theorem and the last one produces
+% an apar theorem.
+% \end{macro}
+%
+% \begin{macro}{\newtheoremtype}
+% \begin{macro}{\renewtheoremtype}
+% Theorem type generation commands:
+% \begin{quote}
+% |\newtheoremtype|\marg{type}\marg{title-style}\marg{comment-style}\marg{body-style}\\
+% |\renewtheoremtype|\marg{type}\marg{title-style}\marg{comment-style}\marg{body-style}
+% \end{quote}
+% \begin{macrocode}
+\newcommand*{\newtheoremtype}[1]{%
+ \edef\@tempa{\noexpand\newcommand*{\expandafter\noexpand
+ \csname like#1\endcsname}}\NCC@nthmtype
+}
+\newcommand*{\renewtheoremtype}[1]{%
+ \edef\@tempa{\noexpand\renewcommand*{\expandafter\noexpand
+ \csname like#1\endcsname}}\NCC@nthmtype
+}
+\def\NCC@nthmtype#1#2#3{\@tempa{\NCC@likethm{#1}{#2}{#3}}}
+\@onlypreamble\newtheoremtype
+\@onlypreamble\renewtheoremtype
+\@onlypreamble\NCC@nthmtype
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Generate New Theorems}
+%
+% \begin{macro}{\NCC@thmdef}
+% Basic theorem generation command:
+% \begin{quote}
+% |\NCC@thmdef|\marg{env-name}\marg{action}\marg{parameters}\oarg{type}
+% \end{quote}
+% The |\@tempa| command must contain either |\noexpand\newenvironment| or
+% |\noexpand\renewenvironment| before the call.
+% The \meta{action} is an action applied at the beginning
+% of theorem. The \meta{parameters} contains parameters passed
+% to the |\like|\meta{type} command.
+% \begin{macrocode}
+\def\NCC@thmdef#1#2#3{%
+ \@ifnextchar[{\NCC@thmdef@{#1}{#2}{#3}}%
+ {\NCC@thmdef@{#1}{#2}{#3}[theorem]}%
+}
+\def\NCC@thmdef@#1#2#3[#4]{%
+% \end{macrocode}
+% Generate an error if the given type is unknown.
+% \begin{macrocode}
+ \@ifundefined{like#4}{%
+ \PackageError{nccthm}{Unknown theorem type `#4'}{}%
+ }%
+% \end{macrocode}
+% |\@tempa := \[re]newenvironment|\marg{env-name}|{#1\like|\meta{type}|#2}|
+% \begin{macrocode}
+ \edef\@tempa##1##2{%
+ \@tempa{#1}{##1\expandafter\noexpand\csname like#4\endcsname##2}%
+ }%
+% \end{macrocode}
+% Generate a theorem envirinment:
+% \begin{macrocode}
+ \ifNCC@thmbr
+ \@tempa{#2\breakafterheader}{#3}{\qef\ignorespacesafterend}%
+ \else
+ \@tempa{#2\nobreakafterheader}{#3}{\qef\ignorespacesafterend}%
+ \fi
+}
+\@onlypreamble\NCC@thmdef
+\@onlypreamble\NCC@thmdef@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newtheorem}
+% \begin{macro}{\renewtheorem}
+% \begin{macro}{\newtheorem*}
+% \begin{macro}{\renewtheorem*}
+% Theorem generation commands:
+% \begin{quote}
+% |\newtheorem|\marg{env-name}\oarg{counter}\marg{title}\oarg{type}\\
+% |\renewtheorem|\marg{env-name}\oarg{counter}\marg{title}\oarg{type}\\
+% |\newtheorem*|\marg{env-name}\marg{title}\oarg{type}\\
+% |\renewtheorem*|\marg{env-name}\marg{title}\oarg{type}
+% \end{quote}
+% \begin{macrocode}
+\renewcommand*{\newtheorem}{\def\@tempa{\noexpand\newenvironment}%
+ \@ifstar{\NCC@nthx}{\NCC@nthm}}
+\newcommand*{\renewtheorem}{\def\@tempa{\noexpand\renewenvironment}%
+ \@ifstar{\NCC@nthx}{\NCC@nthm}}
+\def\NCC@nthx#1#2{\NCC@thmdef{#1}{}{*{#2}}}
+\def\NCC@nthm#1{\@ifnextchar[{\NCC@nthm@{#1}}{\NCC@nthm@{#1}[#1]}}
+\def\NCC@nthm@#1[#2]#3{%
+ \DeclareDynamicCounter{#2}%
+ \NCC@thmdef{#1}{\refstepcounter{#2}}{{#3}{\csname the#2\endcsname}}%
+}
+\@onlypreamble\newtheorem
+\@onlypreamble\renewtheorem
+\@onlypreamble\NCC@nthx
+\@onlypreamble\NCC@nthm
+\@onlypreamble\NCC@nthm@
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Defaults}
+%
+% \begin{macrocode}
+\newtheoremtype{theorem}{\bfseries}{}{\itshape}
+\newtheoremtype{remark}{\itshape}{}{}
+\TheoremNoBreakStyle
+\TheoremCommentDelimiters{(}{)}
+\AfterTheoremHeaderChar{}
+\AfterTheoremHeaderSkip{\hskip 1em \@plus .2em \@minus .2em}
+\AparStyleParameters{\bfseries}{\bfseries}{\enskip}
+\ProofStyleParameters{\bfseries}{Proof}
+%</package>
+% \end{macrocode}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/ncctools.ins b/Master/texmf-dist/source/latex/ncctools/ncctools.ins
new file mode 100644
index 00000000000..065bff23055
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/ncctools.ins
@@ -0,0 +1,75 @@
+%% Copyright 1998--2004 by Alexander I. Rozhenko.
+%%
+%% This file is part of the `ncctools' bundle.
+%%
+%% I am allowed to distribute this file together with all files
+%% mentioned in the manifest.txt.
+%%
+%% You are not allowed to modify its contents.
+%%
+
+% This file requires docstrip version 2.4 or higher available from
+% ftp.dante.de tex-archive/macros/latex/unpacked/docstrip.tex
+
+\input docstrip
+
+\def\SimplePackage#1{%
+ \generate{\file{#1.sty}{\from{#1.dtx}{package}}}}
+
+\keepsilent
+
+%% This is the preamble that will be placed on unpacked files
+
+\preamble
+
+IMPORTANT NOTICE:
+
+This file is a generated file from the sources of the `ncctools'
+bundle.
+
+You are not allowed to modify this file.
+
+You are allowed to distribute this file if and only if
+it is distributed with the corresponding source files in
+the `ncctools' bundle.
+
+For the copying and distribution conditions of the source files,
+see the README file distributed with the ncctools bundle.
+\endpreamble
+
+%%%%%%%%%%%%%% Generate packages
+
+\SimplePackage{dcounter}
+\SimplePackage{desclist}
+\SimplePackage{extdash}
+\SimplePackage{manyfoot}
+\SimplePackage{mboxfill}
+\SimplePackage{nccbbb}
+\SimplePackage{nccboxes}
+\SimplePackage{ncccomma}
+\SimplePackage{ncccropbox}
+\SimplePackage{ncccropmark}
+\SimplePackage{nccfancyhdr}
+\SimplePackage{nccfloats}
+\SimplePackage{nccfoots}
+\SimplePackage{nccmath}
+\SimplePackage{nccparskip}
+\SimplePackage{nccpic}
+\SimplePackage{nccrules}
+\SimplePackage{nccsect}
+\SimplePackage{nccstretch}
+\SimplePackage{nccthm}
+\SimplePackage{tocenter}
+\SimplePackage{watermark}
+
+\Msg{***********************************************************}
+\Msg{*}
+\Msg{* To finish the installation you have to move all the files}
+\Msg{* with extension `.sty' into a directory searched by TeX.}
+\Msg{*}
+\Msg{* To produce the documentation run the .dtx files through LaTeX.}
+\Msg{*}
+\Msg{* Happy TeXing}
+\Msg{***********************************************************}
+
+\endbatchfile
diff --git a/Master/texmf-dist/source/latex/ncctools/tocenter.dtx b/Master/texmf-dist/source/latex/ncctools/tocenter.dtx
new file mode 100644
index 00000000000..4246b929346
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/tocenter.dtx
@@ -0,0 +1,314 @@
+% \iffalse
+%%
+%% File: tocenter.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{tocenter}
+%<package> [2004/12/09 v1.1 Centering Page Layout (NCC)]
+%
+% \changes{v1.0}{2002/01/31}{This version was uploaded to CTAN}
+% \changes{v1.1}{2004/12/09}{Documentation was prepared}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{tocenter}
+\GetFileInfo{tocenter.sty}
+\begin{document}
+\title{The \textsf{tocenter} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{tocenter.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% The package provides commands
+% customizing the layout parameters of a documents.
+%
+% \section{User Interface}
+%
+% \DescribeMacro{\ToCenter}
+% The |\ToCenter|\oarg{hfm}\marg{text-width}\marg{text-height} command
+% calculates margins in such a way to center the specified text area
+% together with header/footer/marginals areas on a sheet of paper.
+% The optional \meta{hfm} parameter specifies what additional areas take into
+% account while centering. It is a combination of three letters |h| (headers),
+% |f| (footers), and |m| (marginal notes). If this parameters is omitted,
+% additional areas are ignored while calculations. For example,
+% the following command
+% \begin{quote}
+% |\ToCenter[h]{\textwidth}{\textheight}|
+% \end{quote}
+% centers the text+header area on the page. The text height and wight
+% are not changed here. This command is useful in books without marginal
+% notes.
+%
+% \DescribeMacro{\FromMargins}
+% The |\FromMargins|\oarg{hfm}\marg{left}\marg{right}\marg{top}\marg{bottom}
+% command calculates the page layout parameters in the MS Word-like style.
+% It sets page margins to the values specified in the last four
+% parameters and calculates the width and
+% height of the text area in such a way to satisfy the requirements.
+% For example, the command
+% \begin{quote}
+% |\FromMargins[hf]{20mm}{10mm}{25mm}{15mm}|
+% \end{quote}
+% calculates the text area dimensions and margins in such a way to
+% provide 20~mm distance from the left edge of the page, 10~mm
+% distance from the right edge, 25~mm distance from the top edge, and
+% 15~mm distance from the bottom edge in assumption that header and
+% footer are in use.
+%
+% If twoside mode is turned on, the left and right margins specified
+% in the |\FromMargins| command are considered for odd pages.
+% For even pages, their values are swapped.
+%
+% If |m|-letter is specified in the optional parameter, the margins are
+% determined depending on two-side and two-column switches. In two-column mode,
+% marginal notes are posed on both sides of paper, but in one-column mode
+% the marginal notes are posed on the outer side of a page in two-side mode
+% and to the right of the text area in one-side mode. All these specifics
+% is taken into account while calculations of text margins.
+% The reverse margin mode is also supported.
+%
+% \DescribeMacro{\ToCenter*}
+% \DescribeMacro{\FromMargins*}
+% The star-forms of these commands
+% \begin{quote}
+% |\ToCenter*|\marg{text-width}\marg{text-height}\\
+% |\FromMargins*|\marg{left}\marg{right}\marg{top}\marg{bottom}
+% \end{quote}
+% are intended for positioning of simple documents without headers,
+% footers, marginal notes, cross-references, and table of contents.
+% Additionally, the empty page style is set and the writing to aux-file
+% is suppressed.
+%
+% \textit{All mentioned commands are allowed in the preamble only.}
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% \begin{macro}{\NCC@pos}
+% The |\NCC@pos|\marg{hfm} command parses the \meta{hfm} parameter
+% and prepares |\NCC@h|\marg{register}, |\NCC@f|\marg{register},
+% and |\NCC@m|\marg{register} commands to adjust values of skip
+% registers. The |\NCC@pos| command is also useful in the |cropmark| package.
+% \begin{macrocode}
+%<*package>
+\def\NCC@pos#1{%
+ \let\NCC@h\@gobble \let\NCC@f\@gobble \let\NCC@m\@gobble
+ \@tfor\@tempa:=#1\do{%
+% \end{macrocode}
+% If |h|-letter appears, the |\NCC@h| hook will adjust the value of register
+% on the header height and separation:
+% \begin{macrocode}
+ \if h\@tempa
+ \def\NCC@h##1{\advance##1\headsep \advance##1\headheight}%
+ \else
+% \end{macrocode}
+% If |f|-letter appears, the |\NCC@f| hook will adjust the value of register
+% on the footer skip distance:
+% \begin{macrocode}
+ \if f\@tempa
+ \def\NCC@f##1{\advance##1\footskip}%
+ \else
+% \end{macrocode}
+% If |m|-letter appears, the |\NCC@m| hook will adjust the value of register
+% on the width and separation of marginal paragraphs:
+% \begin{macrocode}
+ \if m\@tempa
+ \def\NCC@m##1{\advance##1\marginparwidth
+ \advance##1\marginparsep}%
+ \fi
+ \fi
+ \fi
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ToCenter}
+% The star-form of this command differs in the omitted
+% optional parameter, empty page style, and suppressed
+% writing to external files:
+% \begin{macrocode}
+\newcommand{\ToCenter}{%
+ \@ifstar{\pagestyle{empty}\nofiles\NCC@center[]}{\NCC@center}%
+}
+\@onlypreamble\ToCenter
+% \end{macrocode}
+% At the first, we parse the \meta{hfm} parameter:
+% \begin{macrocode}
+\newcommand*{\NCC@center}[3][]{\NCC@pos{#1}%
+% \end{macrocode}
+% Start calculations from horizontal margins and width:
+% set text width and calculate in |\@tempdima| the
+% whole width of area to be centered.
+% \begin{macrocode}
+ \setlength\textwidth{#2}%
+ \@tempdima\textwidth \NCC@m\@tempdima
+% \end{macrocode}
+% In two-column mode, margins appear on both sides of text.
+% We must add the width of marginal area again to |\@tempdima|:
+% \begin{macrocode}
+ \if@twocolumn
+ \NCC@m\@tempdima
+% \end{macrocode}
+% In two-column mode, we set the odd and even side margins to
+% \begin{quote}
+% |\NCC@m{(\paperwidth-\@tempdima)/2}|:
+% \end{quote}
+% \begin{macrocode}
+ \@tempdimb\paperwidth
+ \advance\@tempdimb -\@tempdima
+ \@tempdima .5\@tempdimb \NCC@m\@tempdima
+ \oddsidemargin\@tempdima
+ \evensidemargin\@tempdima
+% \end{macrocode}
+% In one-column mode with reverse margins, we set
+% \begin{quote}
+% |\evensidemargin:=(\paperwidth-\@tempdima)/2|\\
+% |\oddsidemargin:=\NCC@m{(\paperwidth-\@tempdima)/2}|
+% \end{quote}
+% and, with normal margins, we set
+% \begin{quote}
+% |\oddsidemargin:=(\paperwidth-\@tempdima)/2|\\
+% |\evensidemargin:=\NCC@m{(\paperwidth-\@tempdima)/2}|
+% \end{quote}
+% \begin{macrocode}
+ \else
+ \@tempdimb\paperwidth
+ \advance\@tempdimb -\@tempdima \@tempdima .5\@tempdimb
+ \if@reversemargin
+ \evensidemargin\@tempdima
+ \NCC@m\@tempdima
+ \oddsidemargin\@tempdima
+ \else
+ \oddsidemargin\@tempdima
+ \NCC@m\@tempdima
+ \evensidemargin\@tempdima
+ \fi
+ \fi
+% \end{macrocode}
+% Now we calculate the vertical layout parameters.
+% Again, in the |\@tempdima| we calculate the full
+% height of useful areas and set the top margin to
+% \begin{quote}
+% |(\paperwidth-\@tempdima)/2|
+% \end{quote}
+% if headers are in use.
+% \begin{macrocode}
+ \setlength\textheight{#3}%
+ \@tempdima\textheight \NCC@h\@tempdima \NCC@f\@tempdima
+ \@tempdimb\paperheight
+ \advance\@tempdimb -\@tempdima
+ \topmargin .5\@tempdimb
+% \end{macrocode}
+% Otherwise, we decrease the value of top margin on the height
+% and separation of header:
+% \begin{macrocode}
+ \ifx\NCC@h\@gobble
+ \advance\topmargin -\headsep
+ \advance\topmargin -\headheight
+ \fi
+% \end{macrocode}
+% Do final correction of all margins: decrease their values
+% on 1~inch. This compensates the default adjustment applied by
+% dvi drivers.
+% \begin{macrocode}
+ \advance \oddsidemargin -1in
+ \advance \evensidemargin -1in
+ \advance \topmargin -1in
+}
+\@onlypreamble\NCC@center
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FromMargins}
+% Finally, we implement the |\FromMargins| command.
+% \begin{macrocode}
+\newcommand{\FromMargins}{%
+ \@ifstar{\pagestyle{empty}\nofiles\NCC@margin[]}{\NCC@margin}%
+}
+\@onlypreamble\FromMargins
+% \end{macrocode}
+% Again, start from parsing the \meta{hfm} parameter:
+% \begin{macrocode}
+\newcommand*{\NCC@margin}[5][]{\NCC@pos{#1}%
+% \end{macrocode}
+% Calculate horizontal parameters at first.
+% In two-side mode, the left margin is equal to the
+% |\oddsidemargin| and the right margin is equal to the
+% |\evensidemargin|. In one-side mode, the
+% |\oddsidemargin| is calculated in the same manner
+% and the |\evensidemargin| is useless. So, we need
+% not distinguish one-side and two-side modes here
+% and do all things as for two-side mode.
+% \begin{macrocode}
+ \setlength\oddsidemargin{#2}%
+ \setlength\evensidemargin{#3}%
+% \end{macrocode}
+% Calculate in |\@tempdima| the amount of space occupied
+% by horizontal margins and marginal notes.
+% \begin{macrocode}
+ \@tempdima\oddsidemargin \advance\@tempdima\evensidemargin
+ \NCC@m\@tempdima
+% \end{macrocode}
+% In two-column mode, marginal notes should be counted twice
+% and the values of odd and even margins must be adjusted
+% on the marginal width.
+% \begin{macrocode}
+ \if@twocolumn
+ \NCC@m\@tempdima
+ \textwidth\paperwidth
+ \advance\textwidth -\@tempdima
+ \NCC@m\oddsidemargin \NCC@m\evensidemargin
+% \end{macrocode}
+% In one-column mode, we must adjust only one margin
+% depending on placement of marginal notes.
+% \begin{macrocode}
+ \else
+ \textwidth\paperwidth
+ \advance\textwidth -\@tempdima
+ \if@reversemargin
+ \NCC@m\oddsidemargin
+ \else
+ \NCC@m\evensidemargin
+ \fi
+ \fi
+% \end{macrocode}
+% Now we calculate the vertical layout parameters.
+% We set the |\@tempdima| to the sum of
+% top margin, bottom margin, header, and footer.
+% \begin{macrocode}
+ \setlength\topmargin{#4}%
+ \setlength\@tempdima{#5}\advance\@tempdima\topmargin
+ \NCC@h\@tempdima \NCC@f\@tempdima
+% \end{macrocode}
+% The rest of page is the text height:
+% \begin{macrocode}
+ \textheight\paperheight
+ \advance\textheight -\@tempdima
+% \end{macrocode}
+% We must decrease the |\topmargin| on the header separation
+% and height if headers are useless.
+% \begin{macrocode}
+ \ifx\NCC@h\@gobble
+ \advance\topmargin -\headsep
+ \advance\topmargin -\headheight
+ \fi
+% \end{macrocode}
+% Do final correction of all margins:
+% \begin{macrocode}
+ \advance \oddsidemargin -1in
+ \advance \evensidemargin -1in
+ \advance \topmargin -1in
+}
+\@onlypreamble\NCC@margin
+%</package>
+% \end{macrocode}
+% \end{macro}
+\endinput
diff --git a/Master/texmf-dist/source/latex/ncctools/watermark.dtx b/Master/texmf-dist/source/latex/ncctools/watermark.dtx
new file mode 100644
index 00000000000..b48d728720d
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ncctools/watermark.dtx
@@ -0,0 +1,216 @@
+% \iffalse
+%%
+%% File: watermark.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{watermark}
+%<package> [2004/12/09 v1.1 Watermarks (NCC)]
+%
+% \changes{v1.00}{2002/01/29}{This version is uploaded to CTAN}
+% \changes{v1.01}{2002/02/13}{Hbox underfull removed in empty |\thispageheading|}
+% \changes{v1.02}{2003/04/04}{Hbox underfull removed in plain and empty styles}
+% \changes{v1.1}{2004/12/09}{Simplify the implementation of |\thispageheading|}
+% \changes{v1.1}{2004/12/09}{Documentation was prepared}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{watermark,nccboxes}
+\GetFileInfo{watermark.sty}
+\begin{document}
+\title{The \textsf{watermark} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{watermark.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \thispageheading{This heading was prepared with the
+% {\tt\string\thispageheading} command.\\
+% It allows long multi-line headings!}
+%
+% \section{User Interface}
+%
+% \DescribeMacro\watermark
+% \DescribeMacro\leftwatermark
+% \DescribeMacro\rightwatermark
+% \DescribeMacro\thiswatermark
+% The package provides watermarks on output pages. A watermark is
+% some text or picture printed at the background of paper.
+% A watermark is prepared in a picture box stored at the
+% beginning of header. So, you should place
+% the watermark material with LaTeX's |\put| and |\multiput| commands.
+% Allowed watermark commands are shown in the table:
+% \begin{center}\catcode`|=12
+% \small
+% \renewcommand\cboxstyle{\footnotesize}
+% \begin{tabular}{|l|l|}\hline
+% \hfill\cbox{Command}\hfill\mbox{} &
+% \hfill\cbox{Meaning}\hfill\mbox{}\\\hline
+% \Strut/.8/
+% \verb+\watermark+\marg{body} &
+% Set the same watermark for all pages\\
+% \verb+\leftwatermark+\marg{body} &
+% Set the even-page watermark\\
+% \verb+\rightwatermark+\marg{body} &
+% Set the odd-page watermark\\
+% \verb+\thiswatermark+\marg{body} &
+% Set a watermark for the current page only \\
+% \hline
+% \end{tabular}
+% \end{center}
+% In one-side mode, the |\leftwatermark| is ignored and the
+% |\rightwatermark| is applied to all pages.
+%
+% \DescribeMacro\thispageheading
+% The package also provides the command
+% |\thispageheading|\marg{heading}
+% which replaces a heading for the current page to the specified
+% multi-line heading. The heading is prepared in the parbox
+% of the |\textwidth| width aligned on the top line. This
+% command does not suppress watermarks.
+%
+% Examples of using watermarks are shown in the |ncccropmark|
+% package.
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% \begin{macro}{\@begindvi}
+% To support watermarks, we use the |\@begindvi| hook from the output
+% routine. This hook works only once at the beginning of dvi,
+% but some packages (e.g. |hyperref|) also use it for their own needs.
+% So, we redefine it at the beginning of document in such a way to
+% accurately save its behaviour after the first call when it can be
+% redefined by other packages. All the we need from this hook~---
+% to call the |\WMK@insert| command every time when the output
+% routine composes a new page.
+% \begin{macrocode}
+%<*package>
+\AtBeginDocument{
+ \let\WMK@begindvi\@begindvi
+ \def\@begindvi{%
+% \end{macrocode}
+% Apply saved |\@begindvi| hook and then call the
+% |\WMK@insert| command:
+% \begin{macrocode}
+ \WMK@begindvi
+ \WMK@insert
+% \end{macrocode}
+% After that we must redefine the |\@begindvi| hook,
+% because it is already redefined here to the |\@empty| value
+% (or to something else if another package using this hook is loaded).
+% We save its new meaning in the |\WMK@begindvi| command
+% and redefine the |\@begindvi|:
+% \begin{macrocode}
+ \global\let\WMK@begindvi\@begindvi
+ \gdef\@begindvi{\WMK@begindvi\WMK@insert}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\WMK@insert}
+% The command redefines the current header and inserts the
+% |\WMK@hook| at the beginning of header.
+% A box produced by this hook has zero natural sizes.
+% \begin{macrocode}
+\def\WMK@insert{%
+ \let\WMK@head\@thehead
+ \def\@thehead{\WMK@hook\WMK@head}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\WMK@hook}
+% The command applies
+% this watermark (|\WMK@this|), odd watermark (|\WMK@odd|),
+% or even watermark (|\WMK@even|). The watermarks are prepared
+% within the picture environment:
+% \begin{macrocode}
+\def\WMK@hook{%
+ \begin{picture}(0,0)\relax
+ \ifx\WMK@this\relax
+ \if@twoside
+ \ifodd\c@page\WMK@odd\else\WMK@even\fi
+ \else
+ \WMK@odd
+ \fi
+ \else
+ \WMK@this \global\let\WMK@this\relax
+ \fi
+ \end{picture}%
+% \end{macrocode}
+% After that we test the header. At the first, we test the
+% |\WMK@thishead| command. If it is specified, we let
+% |\WMK@head| to |\WMK@thishead|.
+% \begin{macrocode}
+ \ifx\WMK@thishead\relax \else
+ \let\WMK@head\WMK@thishead
+ \global\let\WMK@thishead\relax
+ \fi
+% \end{macrocode}
+% The original |\@thehead| command
+% saved in |\WMK@head| can be defined with |\@oddhead| content
+% or can be let to |\@oddhead| or |\@evenhead|.
+% We test all these cases to recognize when the head is really empty.
+% A head prepared with |\thispageheading| can be also empty.
+% If the empty case is recognized, we insert the |\hfil| command
+% to avoid underfull.
+% \begin{macrocode}
+ \ifx\WMK@head\@empty \hfil
+ \else
+ \def\@tempa{\@oddhead}%
+ \ifx\WMK@head\@tempa
+ \ifx\@oddhead\@empty \hfil \fi
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Set defaults for this heading and watermarks.
+% \begin{macrocode}
+\let\WMK@thishead\relax
+\let\WMK@this\relax
+\let\WMK@odd\@empty
+\let\WMK@even\@empty
+% \end{macrocode}
+%
+% \begin{macro}{\watermark}
+% \begin{macro}{\leftwatermark}
+% \begin{macro}{\rightwatermark}
+% \begin{macro}{\thiswatermark}
+% Define watermark producing commands:
+% \begin{macrocode}
+\newcommand{\watermark}[1]{\leftwatermark{#1}\rightwatermark{#1}}
+\newcommand{\leftwatermark}[1]{\gdef\WMK@even{#1}}
+\newcommand{\rightwatermark}[1]{\gdef\WMK@odd{#1}}
+\newcommand{\thiswatermark}[1]{\gdef\WMK@this{#1}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\thispageheading}
+% Finally, define the |\thispageheading|\marg{heading} command.
+% We especially test the case of empty heading and
+% set |\WMK@thishead| to the |\@empty| value in this case.
+% This allows avoiding underfull in the |\WMK@hook|.
+% \begin{macrocode}
+\newcommand{\thispageheading}[1]{%
+ \def\@tempa{#1}%
+ \ifx\@tempa\@empty
+ \global\let\WMK@thishead\@empty
+ \else
+ \gdef\WMK@thishead{\parbox[t]\textwidth{#1}}%
+ \fi
+}
+%</package>
+% \end{macrocode}
+% \end{macro}
+\endinput