<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{nccmath}
         [2002/03/16 v1.03 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}
%
% Extends the amsmath package adding some math commands used in NCC-LaTeX.
% All options are passed to the parent package. The leqno, reqno, and fleqn
% options affect to equations prepared in the NCC-LaTeX's style.
%
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsmath}}
\ProcessOptions\relax
\RequirePackage{amsmath}[2000/07/18]
%
% \mrel{UP \\ DOWN} -- macro for composing new math relations
%
% \underrel{base}{bottom} -- twin to \overrel
%
\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}}}}
\newcommand{\underrel}[2]{\mathrel{\mathop{#1}\limits_{#2}}}
%
% Redefine \maketag@@@ to produce display formula tags in \mathrm
% font instead of \textrm.
%
\def\maketag@@@#1{\hbox{\normalfont$\m@th\mathrm{#1}$}}
%
% Redefine AMS's \intertext{text} to \intertext[SKIP]{text}. Optional SKIP
% means the vertical space inserted below and after the text. If it is
% omitted, the default \belowdisplayskip and \abovedisplayskip spaces are
% inserted.
%
\renewcommand*{\intertext}[1][]{\@amsmath@err{\Invalid@@\intertext}\@eha}
\def\intertext@{%
  \def\intertext{%
    \ifvmode\else\\\@empty\fi
    \noalign{\ifnum0=`}\fi
      \@ifnextchar[{\NCC@intertext}{\NCC@intertext[]}%
  }%
}
\long\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}%
}
%
% \useshortskip command changes an above skip for nearest display formula
% to \abovedisplayshortskip.
%
\newif\ifNCC@shortskip \NCC@shortskipfalse
\newcommand{\useshortskip}{\global\NCC@shortskiptrue}
%
% This command removes extra vertical space before display formula
% if it starts from a new paragraph and changes a skip before
% display formula to \abovedisplayshortskip if \useshortskip command
% was applied.
%
\def\NCC@ignorepar{%
  \ifNCC@shortskip
    \abovedisplayskip\abovedisplayshortskip
    \global\NCC@shortskipfalse
  \fi
  \RIfM@ \else \ifvmode
    \addvspace{\abovedisplayskip}%
    \abovedisplayskip\z@skip
    \abovedisplayshortskip\z@skip
    \belowdisplayshortskip\belowdisplayskip
    \noindent
  \fi\fi
}
%
% We insert now the \NCC@ignorepar command at the beginning of all
% AMS-LaTeX display equations.
%
\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}
%
% Bug fix in the amsmath package: the \displaybreak has no effect in
% ordinary dislpay equation with a tag. This is because the changing
% of \postdisplaypenalty is done after the \eqno. Fixed version of
% the following command at first changes the \postdisplaypenalty and
% after that prints a tag.
%
\def\endmathdisplay@a{%
  \ifnum\dspbrk@lvl&gt;\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
}
%
% \nr has the same syntax as \\ but adds 0.5ex extra vertical space
% between lines.
%
\newcommand{\nr}{%
  \let\NCC@temp\NCC@cr@@@
  \let\NCC@cr@@@\NCC@nr
  \NCC@cr
}
\def\NCC@nr#1{%
  \let\NCC@cr@@@\NCC@temp
  \@tempskipa#1\relax \advance\@tempskipa .5ex
  \edef\@tempa{[\the\@tempskipa]}%
  \ifNCC@star \def\next@{\\*}\else \def\next@{\\}\fi
  \expandafter\next@\@tempa
}
%
% darray is the simplified array environment which prints array in
% the display style and inserts \jot between lines as in other display
% math environments. The preamble of darray may contain l, c, r, *, and
% @ commands only. The intercolumn separation is equal to
% \thickmuskip. Skips before the first and after the last column
% are not inserted. To insert them manually, use @{...}.
%
\newenvironment{darray}[2][c]{%
  \null\,%
  \if #1t\vtop \else \if#1b \vbox \else \vcenter \fi \fi \bgroup
    \NCC@default@cr
    \spread@equation % no-op if already called
    \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
}
%
% Makes preamble for darray.
% Classes:
% 0 - lcr
% 1 - @-arg
% 2 - @
%
\def\NCC@mkpream#1{%
  \@lastchclass\@ne \@firstamptrue
  \settowidth\alignsep@{$\m@th\mskip\thickmuskip$}%
  \let\@sharp\relax
  \let\@preamble\@empty
  \let\protect\@unexpandable@protect
  \let\@tempa\@empty \let\reserved@a\@empty
  \@xexpast #1*0x\@@
  \edef\@tempa{\@tempa\reserved@a}%
  \expandafter \@tfor \expandafter \@nextchar
   \expandafter :\expandafter =\@tempa \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
}
%
% Simplified version of \\ used in some commands of NCC-LaTeX
% The low level command \NCC@cr@@@{SKIP} is redefinable.
%
\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}}
\def\NCC@default@cr{\let\\\NCC@cr \let\NCC@cr@@@\NCC@aligncr}
%
% NCC-LaTeX EQUATIONS.
%
% The following commands are equivalent to the equation environment:
%
%   \eq{formula}  - numbered equation
%   \eq*{formula} - equation without number
%
% The following commands are equivalent to the darray in the equation
% environment:
%
%   \eqalign[cols]{formulas}  - formulas with number
%   \eqalign*[cols]{formulas} - formulae without number
%
% The additional parameter [cols] defines the number and justification
% of the columns of formulas. Default is [rcl].
%
% The following commands are equivalent to the eqnarray environment,
% but also have an optional parameter:
%
%   \eqs[skip]{formulas}  - works as eqnarray
%   \eqs*[skip]{formulas} - works as eqnarray*
%
% The optional [skip] is the intercolumn space.
%
\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}}
\newcommand{\eqalign}{\@ifstar{\st@rredtrue\NCC@eqa}{\st@rredfalse\NCC@eqa}}
\newcommand*{\NCC@eqa}[2][rcl]{%
  \ifst@rred \def\next@{\NCC@eqx}\else \def\next@{\NCC@eq}\fi
  \next@{\begin{darray}{#1}#2\end{darray}}%
}
\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}
%
% Emulate \fleqn and \ceqn for use in eqnarray-like formulas only.
%
\newcommand*{\fleqn}[1][\z@]{%
  \@tempskipa#1\relax
  \edef\NCC@eqsindent{\the\@tempskipa}%
}
\newcommand{\ceqn}{\let\NCC@eqsindent\@empty}
\ceqn
%
% Basic commands for eqnarray-like formulas.
% The skip between columns is reduced to thick skip appearing in
% relations.
%
\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
  \ifx\NCC@eqsindent\@empty
    \tabskip\@mathmargin
  \else
    \tabskip\NCC@eqsindent\relax
  \fi
  \@ifempty{#1}{\settowidth\alignsep@{$\m@th\mskip\thickmuskip$}}%
               {\alignsep@ #1\relax}%
  \halign to \displaywidth\bgroup
    \strut@ \global\column@\z@ \hfil$\displaystyle{##}$\tabskip\z@skip
   &amp;\column@plus \hskip\alignsep@ \hfil$\displaystyle{##}$\hfil
   &amp;\column@plus \hskip\alignsep@ $\displaystyle{##{}}$\hfil
    \tabskip\@centering
   &amp;\column@plus \llap{##}\tabskip\z@skip\cr
}
\def\NCC@eqcr{%
  \let\@tempa\relax
  \ifcase\column@ \def\@tempa{&amp;&amp;&amp;}\or \def\@tempa{&amp;&amp;}\or\def\@tempa{&amp;}%
  \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
}
\def\NCC@eeqs{\math@cr\egroup$$}
\endinput
</pre></body></html>