% SEBASE.STY 
% This is a base style for TCI's Style Editor.
% Copyright 1994 TCI Software Research

\typeout{sebase.sty - v 1.1  Base style for Style Editor. 10 Jan 95}
\typeout{NOTICE:  This macro file is NOT proprietary and may be 
freely copied and distributed.}
                                        

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                  %
% 			Utility Macros	    				               %
%												                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}

%
%   Add command to append tokens to the beginning and the
%   end of a macro definition
%
\newtoks\@temptokenb
\long\def\appdef#1#2{%
    \ifx#1\undefined\let#1\@empty\fi
    \@temptokena=\expandafter{#1}%
    \@temptokenb={#2}%
    \edef#1{\the\@temptokena\the\@temptokenb}%
}
\long\def\prepdef#1#2{%
    \ifx#1\undefined\let#1\@empty\fi
    \@temptokena=\expandafter{#1}%
    \@temptokenb={#2}%
 	\edef#1{\the\@temptokenb\the\@temptokena}%
}
\def\SetLineSpace#1{\def\baselinestretch{#1}\huge\normalsize}   % be sure to set font after this.

\def\hangon#1{%
    \setbox0=\hbox{#1}%
	  \hangindent = \wd0%
	  \hangafter = 1\relax%
}

%
\def\MakeParam#1{
	\expandafter\def\csname#1\endcsname##1{%
	    \expandafter\def\csname the#1\endcsname{##1}}
}

%
\def\NameEDef#1{%
	\expandafter\edef\csname #1\endcsname}
\def\NameDef#1{%
   \expandafter\def\csname #1\endcsname}

\def\DEF{\noexpand\def\noexpand}

\def\DEBUG#1{\expandafter\show\csname #1\endcsname}

\def\CALL#1{\expandafter\noexpand\csname#1\endcsname}

\def\NOEXP{\noexpand\noexpand}

\def\SEEXPAND{\expandafter\eatnoexpand}
\def\eatnoexpand#1{}

\def\SEEXPANDINLINE{\expandafter\eatnoexpandinline}
\def\eatnoexpandinline#1{{\eatnoexpand#1}}


\def\LineBreak{} % used only as a flag to the styl editor

\def\eatblanks#1{#1}
\def\QTP#1#2\par{\csname #1\endcsname{\eatblanks#2}}

\def\label#1{
   \@bsphack 
   \if@filesw 
      {\let \thepage \relax 
       \def \protect {\noexpand \noexpand \noexpand }
       \edef \@tempa {\write \@auxout {%
            \string \newlabel {#1}{{\@currentlabel }{\thepage }}}}
      \expandafter 
      }%
      \@tempa
      \if@nobreak 
        \ifvmode 
          \nobreak
        \fi 
      \fi 
   \fi 
   \@esphack
} 

 
\def\refstep#1{%
   \stepcounter{#1}%
   \let\@tempa\protect
   \def\protect{\noexpand\protect\noexpand}%
   \edef\@currentlabel{\csname p@#1\endcsname\csname the#1\endcsname}%
   \let\protect\@tempa}


% These macros handle everypar events.  Right now there is just one - suppress indent
% but later there may be others. Follow same pattern. 

\newdimen\NormalParIndent

\def\ResetEveryPar{%
      \gdef\EveryParIndent{}%
}

\def\InitEveryPar{%
   \everypar = {%
        \EveryParIndent
        \ResetEveryPar}%
}

\def\SuppressNextIndent{%
    \InitEveryPar
    \global\NormalParIndent = \parindent
	  \global\parindent = 0pt
	  \gdef\EveryParIndent{\global\parindent = \NormalParIndent}%
}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                           %
%     The Newfield Environment              %
%                                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\long\def\@readenvir#1#2 \end{%
 \appdef\envirsofar{#2}%
 \@ifnextchar\bgroup{\@checkenvir{#1}}{\@envirenderr}%
}%
%
\def\@envirenderr{%
 \@latexerr{\string\end\space not followed by environment name}\@eha
}%
%


\long\def\firstblank#1{#1}
\long\def\lastblank#1\xxx{#1}
\long\def\debl#1{\lastblank\firstblank#1\xxx}
\long\def\deblank#1{%
     \expandafter\def\expandafter#1\expandafter{\expandafter\debl\expandafter{#1}}}

\def\@checkenvir#1#2{%
   \def\@tempa{#1}%
   \def\@tempb{#2}%
   \ifx\@tempa\@tempb
      \ifx\envirsofar\@blankspace
          \let\envirsofar\@empty
      \fi
      \deblank\envirsofar
      \expandafter\let\csname the@#1\endcsname\envirsofar

      \def\@tempa{\csname @do@#1\endcsname}%
   \else
      \appdef\envirsofar{\end{#2}}%
      \def\@tempa{\@readenvir{#1}}%
   \fi
   \@tempa
}%
%
\def\newfield#1#2{%
 \expandafter\@ifdefinable\csname#1\endcsname{%
     \expandafter\def\csname#1\endcsname{%
         \endgroup
         \let\envirsofar\@empty
         \@readenvir{#1}%
     }%
     \expandafter\let\csname the@#1\endcsname\@empty
     \expandafter\ifx\csname @do@#1\endcsname\relax
         \expandafter\def\csname @do@#1\endcsname{{\csname the@#1\endcsname}}%
     \fi
 }%
}%
%
\def\@blankspace{ }% SciWord's nil field


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%															  %
%  The next group of macros define the various justification  %
%  types used in paragraph item construction				  %
%															  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\Leftjustify{% i.e ragged right - we'll just copy TEXbook
      \rightskip 0pt plus 2em
	  \leftskip 0pt
	  \spaceskip .3333em
	  \xspaceskip .5em}

\def\Rightjustify{% 
      \leftskip = 0pt plus 1 fil
      \rightskip = 0pt
      \parfillskip = 0pt} 
      
\def\Bothjustify{}   % Do nothing - this is the normal mode for TEX 

\def\Centerjustify{%
      \leftskip = 0pt plus 1fil
	  \rightskip = 0pt plus 1 fil
	  \parfillskip = 0pt}

\def\Justification#1{\csname #1justify\endcsname}


% This modification to \begin{document} is made to get our
% default page setup and paragraph setup snuck in, and anything
% else we want to do before processing the document.

\def\StyleEditBeginDoc{%
  \countdef\c@@equationCount=32  % to match up with usual eqncounter
  \@ifundefined{c@@chapterCount}{}{\let\c@chapter=\c@@chapterCount}
	\csname\theGenericPageSetup\endcsname
  \global\NormalParIndent=\parindent
}

% \let\@begindocumenthook=\StyleEditBeginDoc   Experiment later
\appdef{\document}{\csname\theGenericParagraph\endcsname}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% Built-in names for use in component lists		  %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\SpaceVertically{\def\@Space##1{\vskip ##1}}
\def\SpaceHorizontally{\def\@Space##1{\hskip ##1}}
\def\Space{\noexpand\@Space}
\SpaceHorizontally

\def\thepage{\arabic{page}}
\def\PageNum{\noexpand\thepage}
\def\LastLeftMark{\noexpand\leftmark}
\def\FirstRightMark{\noexpand\rightmark}
\def\LeftBracket{[}
\def\RightBracket{]}
\def\PoundSign{\#}
\def\Percent{\%}
\def\Ampersand{\&}
\def\Underscore{\_}
\def\LeftBrace{\{}
\def\RightBrace{\}}
\def\Backslash{\mbox{$\backslash$}}


%\def\Uparrow{\symbol{94}}
\def\Tilde{\symbol{126}}
\def\DollarSign{\noexpand\$}

\def\clearonepage{%
    \if@twocolumn
    \else
       \clearpage
    \fi
}

\def\cleardoublepage{%
    \clearpage
    \ifodd\c@page
    \else
       \if@twocolumn
       \else
         \null\newpage
       \fi
    \fi}

\def\clearemptydoublepage{\newpage\thispagestyle{empty}
     \cleardoublepage}

\def\CurrentHeading{\noexpand\@CurrentHeading}
\def\CurrentShortHeading{\noexpand\@CurrentShortHeading}
\def\StartNextOddpage{\clearemptydoublepage}

\def\Bullet{$\bullet$}
\def\Dash{--}
\def\Star{$\ast$}
\def\Dot{$\cdot$}
\def\LBracket{[}
\def\RBracket{]}

%
% All items will have a \Name parameter	and a \Mode parameter
%

\def\Name#1{\def\theName{#1}}
\def\Mode#1{\def\theMode{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%										%
%    Defs of names that Sciword uses    %
%                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\TableOfContents{\@starttoc{toc}} % SciWord doesn't know this name
\def\ListOfFigures{%
   \bgroup
       \let\ContentsEntry=\LOFEntry
       \@starttoc{lof}%
    \egroup
}
\def\ListOfTables{
    \bgroup
       \let\ContentsEntry=\LOFEntry
       \@starttoc{lot}%
    \egroup
}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 		Style Info 								%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\MakeParam{Version}
\MakeParam{DocumentType}
\MakeParam{StyleDescription}
\def\StyleEditorStyle#1{%
   \relax}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 		Global Parameters						%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   \MakeParam{Mode}
   \MakeParam{FontScheme}
   \MakeParam{PointSize}
   \MakeParam{ThmHeadingFont}
   \MakeParam{GenericPageSetup}
   \MakeParam{GenericParagraph}
   \MakeParam{ExternalFile}
       \def\Empty{}
   \MakeParam{TopNum}
   \MakeParam{BottomNum}
   \MakeParam{TotalNum}
   \MakeParam{TopFrac}
   \MakeParam{TextFrac}
   \MakeParam{BottomFrac}
   \MakeParam{FloatPgFrac}
   \MakeParam{DblTopNum}
   \MakeParam{DblTopFrac}
   \MakeParam{DblFloatPgFrac}
   \MakeParam{FloatSep}
   \MakeParam{TextFloatSep}
   \MakeParam{InTextSep}
   \MakeParam{DblFloatSep}
   \MakeParam{DblTextFloat}
   \MakeParam{TopFigRule}
   \MakeParam{BottomFigRule}
   \MakeParam{DblFigRule}


\def\GlobalParameterSetup{
    \input{\theFontScheme}
    \input{se\thePointSize.clo}
    \ifx\theExternalFile\Empty
    \else \input{\theExternalFile}
    \fi
    \edef\theorem@headerfont{\csname\theThmHeadingFont\endcsname}
    \setcounter{topnumber}{\theTopNum}
    \setcounter{bottomnumber}{\theBottomNum}
    \setcounter{totalnumber}{\theTotalNum}
    \edef\topfraction{\theTopFrac}
    \edef\bottomfraction{\theBottomFrac}
    \edef\textfraction{\theTextFrac}
    \edef\floatpagefraction{\theFloatPgFrac}
    \setcounter{dbltopnumber}{\theDblTopNum}
    \edef\dbltopfraction{\theDblTopFrac}
    \edef\floatsep{\theFloatSep}
    \edef\textfloatsep{\theTextFloatSep}
    \edef\intextsep{\theInTextSep}
    \edef\dblfloatsep{\theDblFloatSep}
    \edef\dbltextfloatsep{\theDblTextFloat}
    %\edef\topfigrule{\theTopFigRule}
    %\edef\botfigrule{\theBottomFigRule}
    %\edef\DblFigRule{\theDblFigRule}
}

\def\GlobalParams#1{%
    %\typeout{In Global Parameters}
    #1\GlobalParameterSetup}
    


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 		Document Variables						%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

% DocumentVariables have a Default and 
% a Frontmatter parameter

\newif\ifFrontmatter 
\def\Frontmatter#1{\expandafter\csname Frontmatter#1\endcsname}
\MakeParam{Default}
\MakeParam{Leadin}

\def\DefineDocVar{%
 	\ifFrontmatter
		\NameEDef{@\theName}{\theDefault}
		\NameEDef{\theName}{\noexpand\noexpand\expandafter\noexpand\csname @\theName\endcsname}
		\NameEDef{Set\theName}##1{%
		   \noexpand\def\expandafter\noexpand\csname @\theName\endcsname{##1}}
	  %\DEBUG{@\theName}
		%\DEBUG{\theName}
		%\DEBUG{Set\theName}
	\else
	  % Newfield case
		\edef\DoNewField{\noexpand\newfield{NF\theName}{\theLeadin}}
    %\DEBUG{DoNewField}%
		\DoNewField
		\NameEDef{@do@NF\theName}{\relax}
		\NameEDef{\theName}{\noexpand\noexpand\expandafter\noexpand\csname the@NF\theName\endcsname}
		%\DEBUG{\theName} 
		%\DEBUG{@do@NF\theName}
    %\DEBUG{NF\theName}
 \fi
}
 
\def\DocumentVariable#1{#1\DefineDocVar}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 		Style Variables  						%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\MakeParam{Value}

\def\DefineStyleVar{%
	\NameEDef{\theName}{\theValue}
	%\DEBUG{\theName}
} 

\def\StyleVariable#1{#1\DefineStyleVar}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 		Counters		  						%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{@Document}

% These two counters are incremented whenever 
% a level one or two division is encountered in
% the document.  They are used to reset equation 
% numbering if desired.

%\newcounter{LevelOneDiv}
%\newcounter{LevelTwoDiv}

\def\BulletA#1{$\noexpand\m@th\bullet$}
\def\BulletB#1{{\noexpand\bfseries --}}
\def\BulletC#1{$\noexpand\m@th\ast$}
\def\BulletD#1{$\noexpand\m@th\cdot$}
\def\BulletE#1{-}

\MakeParam{Appearance}
\MakeParam{RefPrefix}
\MakeParam{ResetOn}
\MakeParam{InitialValue}

\def\DefineCounter{
    \edef\DoNewCounter{\noexpand\newcounter{@\theName}[@\theResetOn]}
    \DoNewCounter
    \edef\DoInitCounter{\noexpand\setcounter{@\theName}{\theInitialValue}}
	  \DoInitCounter
    \NameEDef{\theName}{\noexpand\noexpand\expandafter\noexpand\csname the@\theName\endcsname}
    \NameEDef{the@\theName}{%
         \expandafter\noexpand\csname\theAppearance\endcsname{@\theName}}
    \expandafter\NameDef\expandafter{\expandafter p\expandafter @\expandafter @\expandafter
        \theName\expandafter }\expandafter{\theRefPrefix}
    %
    %\DEBUG{p@@\theName}
    %\DEBUG{\theName}
    %\DEBUG{@\theName}
    %\DEBUG{the@\theName}
}

\def\Counter#1{#1\DefineCounter}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Rules			  						                  %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\MakeParam{Height}
\MakeParam{Length}
\MakeParam{Shift}

\def\Rule#1{#1\DefineRule}

\def\DefineRule{%
   \NameEDef{@\theName}{\noexpand\rule[\theShift]{\theLength}{\theHeight}}
   \NameEDef{\theName}{\noexpand\noexpand\expandafter\noexpand\csname @\theName\endcsname}
   %\DEBUG{@\theName}
   %\DEBUG{\theName}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Fonts			  						                  %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\MakeParam{Family}

	\def\RMFamily{Serif}
	\def\SFFamily{SansSerif}
	\def\TTFamily{Typewriter}
  \def\Inherit{Inherit}

\MakeParam{Shape}
	
	\def\UPShape{Upright}
	\def\ITShape{Italic}
	\def\SLShape{Slant}
	\def\SCShape{SmallCaps}

\MakeParam{Series}

	\def\BFSeries{Bold}
	\def\MDSeries{Medium}

\MakeParam{Size}

\def\FontNFSS#1{#1\DefineFont}

\def\DefineFont{
	\NameEDef{\theName}{%
		\ifx\theFamily\RMFamily
			\noexpand\rmfamily
		\else\ifx\theFamily\SFFamily
			\noexpand\sffamily
		\else\ifx\theFamily\TTFamily
			\noexpand\ttfamily
    \else\ifx\theFamily\Inherit
		\fi\fi\fi\fi
		%
		\ifx\theShape\UPShape
			\noexpand\upshape
		\else\ifx\theShape\ITShape
			\noexpand\itshape
		\else\ifx\theShape\SLShape
		    \noexpand\slshape
		\else\ifx\theShape\SCShape
		    \noexpand\scshape
    \else\ifx\theShape\Inherit
		\fi\fi\fi\fi\fi
		%
		\ifx\theSeries\BFSeries
			\noexpand\bfseries
		\else\ifx\theSeries\MDSeries
		    \noexpand\mdseries
    \else\ifx\theSeries\Inherit
		\fi\fi\fi
		%
    \ifx\theSize\Inherit
    \else
       \expandafter\noexpand\csname\theSize\endcsname
    \fi
    }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Inline Elements	  						            %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\MakeParam{Font}
\MakeParam{Components}
%\MakeParam{FixedWidth}
\newif\ifFixedWidth
\def\FixedWidth#1{\csname FixedWidth#1\endcsname}
\MakeParam{Width}
%\MAkeParam{RightJustified}
\newif\ifRightJustified
\def\RightJustified#1{\csname RightJustified#1\endcsname}


\def\InlineElement#1{#1\DefineInlineElt}

\def\DefineInlineElt{%
  \ifnum\theMode=2
  \else
    \NameEDef{@\theName}{%
   	    {\ifFixedWidth
            \setbox0=\hbox\bgroup
                \noexpand\SpaceHorizontally 
   	            \CALL{\theFont}%
                \theComponents%
            \egroup
            \@tempdima=\theWidth
            \advance\@tempdima by -\wd0
            \ifRightJustified
              \hskip\@tempdima
              \unhbox0
            \else
              \unhbox0
              \hskip\@tempdima
            \fi
         \else
   	        \noexpand\SpaceHorizontally 
   	        \CALL{\theFont}%
   	        \theComponents%
   	     \fi
   	    }%
   	}%
	  \NameEDef{\theName}{{\noexpand\noexpand\CALL{@\theName}}}%
  \fi
	 %\DEBUG{\theName}
	 %\DEBUG{@\theName}
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		DisplayElements	  					            	%
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\MakeParam{EZFont}
\MakeParam{EZJustify}

   \def\RightJust{Right}
   \def\LeftJust{Left}
   \def\CenterJust{Center}

\MakeParam{Components}
\MakeParam{HangOn}
\MakeParam{ParagraphType}
\MakeParam{Font}
\MakeParam{SkipBefore}
\MakeParam{SkipAfter}

\def\DisplayElement#1{#1\DefineDisplayElt}
\def\DefineDisplayElt{
  \ifnum\theMode=0
      \EZDefineDispElt
  \else\ifnum\theMode=1
      \CusDefineDispElt
  \fi\fi
}

\def\EMPTY{}

\def\EZDefineDispElt{
  %\expandafter\let\csname CL\theName\endcsname = \theComponents
  \NameEDef{@\theName}{%
    \vskip 0pt
	  \noexpand\addvspace{\theSkipBefore}
	  \vbox\bgroup
	       \noexpand\SpaceHorizontally
         \CALL{\theParagraphType}
         \ifx\theEZJustify\RightJust
           \noexpand\Rightjustify
         \else\ifx\theEZJustify\CenterJust
           \noexpand\Centerjustify
         \else
           \noexpand\Leftjustify
         \fi\fi
		     \CALL{\theEZFont}
         \par
		     \theComponents
         \noexpand\hangon{\hskip\parindent\theHangOn}%
	  \egroup
    \noexpand\nobreak
	  \noexpand\addvspace{\theSkipAfter}%
	}%
  \NameEDef{\theName}{%
     \noexpand\noexpand
     \expandafter\noexpand\csname @\theName\endcsname}%
  %\DEBUG{@\theName}
  %\DEBUG{\theName}
}

\def\CusDefineDispElt{%
    %\expandafter\let\csname CL\theName\endcsname = \theComponents
	\NameEDef{@\theName}{%
    \vskip 0pt
	  \noexpand\addvspace{\theSkipBefore}
	  \vbox\bgroup
	     \noexpand\SpaceHorizontally
	     \CALL{\theParagraphType}
		   \CALL{\theFont}
	     \par 
		   %\expandafter\noexpand\csname CL\theName\endcsname%
		   \theComponents
       \ifx\theHangOn\EMPTY
       \else
		      \noexpand\hangon{\hskip\parindent\theHangOn}% 
		   \fi
	  \egroup
	  \noexpand\addvspace{\theSkipAfter}
	}%
  \NameEDef{\theName}{\noexpand\noexpand\CALL{@\theName}}%
  %\DEBUG{@\theName}
  %\DEBUG{\theName}
}






%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 		Page Setup		  						%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
% Three part Header and footer stuff
%
\def\@threepart#1#2#3{\SpaceHorizontally\rlap{#1} \hfil {#2} \hfil \llap{#3}}
\def\ps@normal{
   \def\@oddhead{\@threepart{\oddlefthead}{\oddmiddlehead}{\oddrighthead}}
   \def\@oddfoot{\@threepart{\oddleftfoot}{\oddmiddlefoot}{\oddrightfoot}}
   \def\@evenhead{\@threepart{\evenlefthead}{\evenmiddlehead}{\evenrighthead}}
   \def\@evenfoot{\@threepart{\evenleftfoot}{\evenmiddlefoot}{\evenrightfoot}} 
}

\ps@normal

%
% Quick mode parameters
%
\MakeParam{EZMargUnit}
\MakeParam{EZPageSize}

    \def\AFourSize{AFour}
    \def\USLetter{USLetter}
    \def\USLegal{USLegal}
        
\MakeParam{EZTopMargin}
 
\def\EZBottomMargin#1{\def\theEZBottomMargin{#1}}
\def\EZOddLeftMargin#1{\def\theEZOddLeftMargin{#1}}
\def\EZOddRightMargin#1{\def\theEZOddRightMargin{#1}}
      
\def\EZEvenMargins#1{\def\theEZEvenMargins{#1}}

    \def\Same{Same}
    \def\Mirror{Mirror}

\def\EZTwoColumn#1{\csname @twocolumn#1\endcsname} 

\def\QQEmpty{\noexpand\relax}
\def\QQPgNum{\noexpand\thepage}
\def\QQAuthor{\noexpand\@Author}
\def\QQTitle{\noexpand\@Title}
\def\QQPriDiv{\noexpand\leftmark}
\def\QQSecDiv{\noexpand\rightmark}   
\def\Custom{\csname QQCustom\endcsname}
    
\def\EZOddLeftHead#1{\edef\theEZOddLeftHead{\csname QQ#1\endcsname}}     
\def\EZOddMiddleHead#1{\def\theEZOddMiddleHead{\csname QQ#1\endcsname}}
\def\EZOddRightHead#1{\def\theEZOddRightHead{\csname QQ#1\endcsname}}
\def\EZOddLeftFoot#1{\def\theEZOddLeftFoot{\csname QQ#1\endcsname}}
\def\EZOddMiddleFoot#1{\def\theEZOddMiddleFoot{\csname QQ#1\endcsname}}
\def\EZOddRightFoot#1{\def\theEZOddRightFoot{\csname QQ#1\endcsname}}
    
\def\EZEvenLeftHead#1{\def\theEZEvenLeftHead{\csname QQ#1\endcsname}}
\def\EZEvenMiddleHead#1{\def\theEZEvenMiddleHead{\csname QQ#1\endcsname}}
\def\EZEvenRightHead#1{\def\theEZEvenRightHead{\csname QQ#1\endcsname}}
\def\EZEvenLeftFoot#1{\def\theEZEvenLeftFoot{\csname QQ#1\endcsname}}
\def\EZEvenMiddleFoot#1{\def\theEZEvenMiddleFoot{\csname QQ#1\endcsname}}
\def\EZEvenRightFoot#1{\def\theEZEvenRightFoot{\csname QQ#1\endcsname}}

%
% Custom mode parameters
%

\def\TwoColumn#1{\csname @twocolumn#1\endcsname}

\newif\ifCropMarks
\def\CropMarks#1{\csname CropMarks#1\endcsname}
 
\def\PageHeight#1{\def\thePageHeight{#1}}
\def\PageWidth#1{\def\thePageWidth{#1}}
\def\TrimHeight#1{\def\theTrimHeight{#1}}
\def\TrimWidth#1{\def\theTrimWidth{#1}}
\def\OddLeftMargin#1{\def\theOddLeftMargin{#1}}
\def\OddRightMargin#1{\def\theOddRightMargin{#1}}
\def\EvenLeftMargin#1{\def\theEvenLeftMargin{#1}}
\def\EvenRightMargin#1{\def\theEvenRightMargin{#1}}
\def\TopMargin#1{\def\theTopMargin{#1}}
\def\BottomMargin#1{\def\theBottomMargin{#1}}
\def\HeadHeight#1{\def\theHeadHeight{#1}}
\def\HeadSep#1{\def\theHeadSep{#1}}
\def\TopSkip#1{\def\theTopSkip{#1}}
\def\FootSkip#1{\def\theFootSkip{#1}}
\def\ColumnSep#1{\def\theColumnSep{#1}}
\def\ColumnRuleWidth#1{\def\theColumnRuleWidth{#1}}
\def\OddHeaderLeft#1{\def\theOddHeaderLeft{#1}}
\def\OddHeaderRight#1{\def\theOddHeaderRight{#1}}   
\def\OddHeaderMiddle#1{\def\theOddHeaderMiddle{#1}}
\def\OddFooterLeft#1{\def\theOddFooterLeft{#1}}
\def\OddFooterRight#1{\def\theOddFooterRight{#1}}
\def\OddFooterMiddle#1{\def\theOddFooterMiddle{#1}}
\def\EvenHeaderLeft#1{\def\theEvenHeaderLeft{#1}}
\def\EvenHeaderRight#1{\def\theEvenHeaderRight{#1}}
\def\EvenHeaderMiddle#1{\def\theEvenHeaderMiddle{#1}}
\def\EvenFooterLeft#1{\def\theEvenFooterLeft{#1}}
\def\EvenFooterRight#1{\def\theEvenFooterRight{#1}}
\def\EvenFooterMiddle#1{\def\theEvenFooterMiddle{#1}}

\def\FootnoteBodyFont#1{\def\theFootnoteBodyFont{#1}}
\def\FootnoteLineSpacing#1{\def\theFootnoteLineSpacing{#1}}
\def\FootnoteRuleLength#1{\def\theFootnoteRuleLength{#1}}
\def\FootnoteRuleWidth#1{\def\theFootnoteRuleWidth{#1}}
\def\FootnoteSeparation#1{\def\theFootnoteSeparation{#1}}
\def\FootnoteSymbol#1{\def\theFootnoteSymbol{#1}}
\def\MarginParPush#1{\def\theMarginParPush{#1}}
\def\MarginParSep#1{\def\theMarginParSep{#1}}
\def\MarginParWidth#1{\def\theMarginParWidth{#1}}
\def\DefaultParagraph#1{\def\theDefaultParagraph{#1}}

\MakeParam{HorizontalOffset}
\MakeParam{VerticalOffset} 

\long\def\PageSetup#1{%
   #1\DoPageSetup}

\def\DoPageSetup{
	\ifnum\theMode=0
		\EZPageSetup
	\else\ifnum\theMode=2
      % Do nothing should be defined in external file
  \else
    \CustomPageSetup 	    
	\fi
	\fi
}

\def\EZPageSetup{
   \long\NameEDef{\theName}{
	    \ifx\theEZPageSize\AFourSize
          \textwidth=21cm
          \textheight=29.7cm
      \else\ifx\theEZPageSize\USLetter
          \textwidth = 8.5in
          \textheight = 11in
      \else
          \textwidth = 8.5in
          \textheight = 14in
      \fi\fi
   %
      \oddsidemargin = \theEZOddLeftMargin\theEZMargUnit
      \advance\textwidth by -\oddsidemargin
      \advance\oddsidemargin by -1in
      \advance\textwidth by -\theEZOddRightMargin\theEZMargUnit
      \ifx\theEZEvenMargins\Same
          \evensidemargin = \oddsidemargin
      \else
          \evensidemargin = \theEZOddRightMargin\theEZMargUnit
          \advance\evensidemargin by -1in
      \fi
      \topmargin =\theEZTopMargin\theEZMargUnit
      \advance\textheight by -\topmargin
      \advance\topmargin by -1in
      \advance\textheight by -\theEZBottomMargin\theEZMargUnit
      \headheight =\noexpand\normalbaselineskip
      \advance\textheight by -\headheight
      \headsep = \theHeadSep
      \advance\textheight by -\headsep
      \topskip=\noexpand\normalbaselineskip
      \footskip = \theFootSkip
      \advance\textheight by -\footskip
   %
   %
      \ifx\theEZOddLeftHead\Custom
          \DEF\oddlefthead{\theOddHeaderLeft}
      \else
	        \DEF\oddlefthead{\theEZOddLeftHead}
      \fi
    %
      \ifx\theEZOddMiddleHead\Custom
          \DEF\oddmiddlehead{\theOddHeaderMiddle}
      \else
	        \DEF\oddmiddlehead{\theEZOddMiddleHead}
      \fi
   %
      \ifx\theEZOddRightHead\Custom
          \DEF\oddrighthead{\theOddHeaderRight}
      \else
	        \DEF\oddrighthead{\theEZOddRightHead}
      \fi
	 %
      \ifx\theEZOddLeftFoot\Custom
          \DEF\oddleftfoot{\theOddFooterLeft}
      \else
	        \DEF\oddleftfoot{\theEZOddLeftFoot}
      \fi
   %
      \ifx\theEZOddMiddleFoot\Custom
          \DEF\oddmiddlefoot{\theOddFooterMiddle}
      \else
	        \DEF\oddmiddlefoot{\theEZOddMiddleFoot}
      \fi
   %
      \ifx\theEZOddRightFoot\Custom
          \DEF\oddrightfoot{\theOddFooterRight}
      \else
	        \DEF\oddrightfoot{\theEZOddRightFoot}
      \fi
   %
   %
      \ifx\theEZEvenLeftHead\Custom
          \DEF\evenlefthead{\theEvenHeaderLeft}
      \else
	        \DEF\evenlefthead{\theEZEvenLeftHead}
      \fi
   %
      \ifx\theEZEvenMiddleHead\Custom
          \DEF\evenmiddlehead{\theEvenHeaderMiddle}
      \else
	        \DEF\evenmiddlehead{\theEZEvenMiddleHead}
      \fi
   %
      \ifx\theEZEvenRightHead\Custom
          \DEF\evenrighthead{\theEvenHeaderRight}
      \else
	        \DEF\evenrighthead{\theEZEvenRightHead}
      \fi
	 %
      \ifx\theEZEvenLeftFoot\Custom
          \DEF\evenleftfoot{\theEvenFooterLeft}
      \else
	        \DEF\evenleftfoot{\theEZEvenLeftFoot}
      \fi
   %
      \ifx\theEZEvenMiddleFoot\Custom
          \DEF\evenmiddlefoot{\theEvenFooterMiddle}
      \else
	        \DEF\evenmiddlefoot{\theEZEvenMiddleFoot}
      \fi
   %
      \ifx\theEZEvenRightFoot\Custom
          \DEF\evenrightfoot{\theEvenFooterRight}
      \else
	        \DEF\evenrightfoot{\theEZEvenRightFoot}
      \fi
   %
      \columnsep = \theColumnSep
	    \columnseprule = \theColumnRuleWidth
      \footnotesep = \theFootnoteSeparation
	    \DEF\footnoterule{%
	    	\kern-3\p@
	    	\hrule width \theFootnoteRuleLength	height \theFootnoteRuleWidth
	    	\kern 2.6\p@
		  }
      \long\DEF\@makefntext####1{%
        \parindent 1em
        %\parskip 0pt
        \noindent
			  {\hbox to1.8em{\hss$\noexpand\m@th^{\noexpand\@thefnmark}$}%
		 	    \noexpand\SetLineSpace{\theFootnoteLineSpacing}%
		 	    \expandafter\noexpand\csname\theFootnoteBodyFont\endcsname
	     	     ####1%
	      }%
      }
      \marginparsep =  \theMarginParSep
      \marginparpush = \theMarginParPush
		  \marginparwidth = \theMarginParWidth
 	}
  %\DEBUG{\theName}
}



\newdimen\trimmargin
\newdimen\verttrimmargin

\input crop.sty

\def\CustomPageSetup{
	\long\NameEDef{\theName}{
	 	\trimmargin = \thePageWidth
    \noexpand\typeout{PAGEWIDTH = \noexpand\the\noexpand\trimmargin}
		\advance\trimmargin by -\theTrimWidth
		\divide\trimmargin by 2
		\noexpand\typeout{TRIMMAR = \noexpand\the\noexpand\trimmargin}
    \oddsidemargin = \theOddLeftMargin
		\evensidemargin = \theEvenLeftMargin
		\textwidth = \theTrimWidth
		\advance\textwidth by -\oddsidemargin   % left margin
    \advance\textwidth by -\theOddRightMargin % right margin
    \noexpand\typeout{TEXTWIDTH = \noexpand\the\noexpand\textwidth}
    \advance\oddsidemargin by \trimmargin
    \advance\oddsidemargin by -1in  % because 1 inch is automatic
   	\advance\evensidemargin by \trimmargin
		\advance\evensidemargin by -1in
		\noexpand\typeout{ODDSIDEMAR = \noexpand\the\noexpand\oddsidemargin}
		\noexpand\typeout{EVENSIDEMAR = \noexpand\the\noexpand\evensidemargin}
    \verttrimmargin = \thePageHeight
		\advance\verttrimmargin by -\theTrimHeight
		\divide\verttrimmargin by 2
    \noexpand\typeout{VERTTRIMMARGIN = \noexpand\the\noexpand\verttrimmargin}
    \ifCropMarks
        \noexpand\crop{\thePageWidth}{\thePageHeight}{\noexpand\trimmargin}{\noexpand\verttrimmargin}%
    \fi
		\topmargin = \theTopMargin
		\topskip = \theTopSkip
		\headheight = \theHeadHeight
		\headsep = \theHeadSep
		\footskip = \theFootSkip
    \noexpand\typeout{TOPMARGIN = \noexpand\the\noexpand\topmargin}
    \noexpand\typeout{TOPSKIP = \noexpand\the\noexpand\topskip}
    \noexpand\typeout{HEADHEIGHT = \noexpand\the\noexpand\headheight}
    \noexpand\typeout{HEADSEP = \noexpand\the\noexpand\headsep}
		\noexpand\typeout{FOOTSKIP = \noexpand\the\noexpand\footskip}
		\textheight = \theTrimHeight
		\advance\textheight by -\topmargin
		\advance\textheight by -\theBottomMargin
		\advance\textheight by -\headheight
		\advance\textheight by -\headsep
		\advance\textheight by -\footskip
    \noexpand\typeout{TEXTHEIGHT = \noexpand\the\noexpand\textheight}
		\advance\topmargin by \trimmargin
		\advance\topmargin by -1in
		\columnsep = \theColumnSep
		\columnseprule = \theColumnRuleWidth
    \footnotesep = \theFootnoteSeparation
		\DEF\footnoterule{%
	    	\kern-3\p@
	    	\hrule width \theFootnoteRuleLength	height \theFootnoteRuleWidth
	    	\kern 2.6\p@
		}
    \long\DEF\@makefntext####1{%
        	\parindent 1em
        	\noindent
			{\hbox to1.8em{\hss$\noexpand\m@th^{\noexpand\@thefnmark}$}%
		 	 \noexpand\SetLineSpace{\theFootnoteLineSpacing}
		 	 \expandafter\noexpand\csname\theFootnoteBodyFont\endcsname
	     	 ####1%
	        }%
    }
    \marginparsep =  \theMarginParSep
   	\marginparpush = \theMarginParPush
		\marginparwidth = \theMarginParWidth
		%
		\DEF\oddlefthead{\theOddHeaderLeft}
		\DEF\oddmiddlehead{\theOddHeaderMiddle}
		\DEF\oddrighthead{\theOddHeaderRight}
		\DEF\oddleftfoot{\theOddFooterLeft}
		\DEF\oddmiddlefoot{\theOddFooterMiddle}
		\DEF\oddrightfoot{\theOddFooterRight} 
		%
		\DEF\evenlefthead{\theEvenHeaderLeft}
		\DEF\evenmiddlehead{\theEvenHeaderMiddle}
		\DEF\evenrighthead{\theEvenHeaderRight}
		\DEF\evenleftfoot{\theEvenFooterLeft}
		\DEF\evenmiddlefoot{\theEvenFooterMiddle}
		\DEF\evenrightfoot{\theEvenFooterRight}  
 		%
		%\expandafter\noexpand\csname\theDefaultParagraph\endcsname
     }
	 %\DEBUG{\theName}
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 		Paragraph		  						%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


   \MakeParam{ShapeAParIndent}
   \MakeParam{ShapeALeftIndent}
   \MakeParam{ShapeARightIndent}
   \MakeParam{ShapeAParFill}
   \MakeParam{ShapeBParIndent}
   \MakeParam{ShapeBLeftIndent}
   \MakeParam{ShapeBRightIndent}
   \MakeParam{ShapeBParFill}
   \MakeParam{ShapeCParIndent}
   \MakeParam{ShapeCLeftIndent}
   \MakeParam{ShapeCRightIndent}
   \MakeParam{ShapeCParFill}
   \MakeParam{ShapeDParIndent}
   \MakeParam{ShapeDLeftIndent}
   \MakeParam{ShapeDRightIndent}
   \MakeParam{ShapeDParFill}
   \MakeParam{ShapeEParIndent}
   \MakeParam{ShapeELeftIndent}
   \MakeParam{ShapeERightIndent}
   \MakeParam{ShapeEParFill}
   \MakeParam{ShapeFParIndent}
   \MakeParam{ShapeFLeftIndent}
   \MakeParam{ShapeFRightIndent}
   \MakeParam{ShapeFParFill}
   \MakeParam{SpacingABLSkip}
   \MakeParam{SpacingBBLSkip}
   \MakeParam{SpacingCBLSkip}
   \MakeParam{SqueezeALeftIndent}
   \MakeParam{SqueezeARightIndent}
   \MakeParam{SqueezeBLeftIndent}
   \MakeParam{SqueezeBRightIndent}
   \MakeParam{SpreadAParSkip}
   \MakeParam{SpreadBParSkip}

\def\EZParSetup#1{#1}

\def\DefaultParagraphSetup{\relax}
\MakeParam{EZFont}
\MakeParam{Shape}

    
%\MakeParam{Spread}
\newif\ifSpread
\def\Spread#1{\csname Spread#1\endcsname}

%\MakeParam{Squeeze}
\newif\ifSqueeze
\def\Squeeze#1{\csname Squeeze#1\endcsname}

\MakeParam{Spacing}

\MakeParam{Font}
\MakeParam{LineSpacing}
\MakeParam{ParSkip}
\MakeParam{ParIndent}
\MakeParam{LeftIndent}
\MakeParam{RightIndent}
\MakeParam{ParFill}
\MakeParam{HyphenPen}
\MakeParam{InterlinePen}

%\def\LineSkip#1{\def\theLineSkip{#1}}
%\def\NormalLineSkip#1{\def\theNormalLineSkip{#1}}


\def\Paragraph#1{#1\DoParSetup}

\def\DoParSetup{
	\ifnum\theMode=0
		  \EZParagraphSetup
	\else\ifnum\theMode=1
	    \CustomParSetup
	\else
	    \typeout{ERROR}
	\fi\fi
}


\def\EZParagraphSetup{
	 \NameEDef{\theName}{%
      \par
      \parindent = \expandafter\csname the\theShape ParIndent\endcsname
      %\NormalParIndent=\parindent
      \advance\leftskip by \expandafter\csname the\theShape LeftIndent\endcsname
      \advance\rightskip by \expandafter\csname the\theShape RightIndent\endcsname
	  	\parfillskip= \expandafter\csname the\theShape ParFill\endcsname
      %
      \ifSpread
          \parskip = \theSpreadBParSkip
      \else
          \parskip = \theSpreadAParSkip
      \fi
      %
      \ifSqueeze
          \advance\leftskip by \theSqueezeBLeftIndent
          \advance\rightskip by \theSqueezeBRightIndent
      \else
          \advance\leftskip by \theSqueezeALeftIndent
          \advance\rightskip by \theSqueezeARightIndent
      \fi
	  	%\lineskip = \theLineSkip
	  	%\normallineskip = \theNormalLineSkip
      \ifnum\theSpacing=0
          %\DEF\baselinestretch{\theSpacingABLSkip}
          \noexpand\SetLineSpace{\theSpacingABLSkip}
      \else\ifnum\theSpacing=1
          %\DEF\baselinestretch{\theSpacingBBLSkip}
          \noexpand\SetLineSpace{\theSpacingBBLSkip}
      \else
          %\DEF\baselinestretch{\theSpacingCBLSkip}
          \noexpand\SetLineSpace{\theSpacingCBLSkip}
      \fi\fi
	  		  	%\advance\hsize by -\leftskip
	 	  %\advance\hsize by -\rightskip
	  	%
      \CALL{\theEZFont}
    }%
   \NameEDef{end\theName}{\par}
   %\DEBUG{\theName}
}


\def\CustomParSetup{
   	\NameEDef{\theName}{%
      \parskip = \theParSkip
	  	\parindent = \theParIndent
      %\NormalParIndent=\parindent
	  	%\lineskip = \theLineSkip
	  	%\normallineskip = \theNormalLineSkip
	  	\noexpand\SetLineSpace{\theLineSpacing}
	  	\expandafter\noexpand\csname\theFont\endcsname
	  	\leftskip=\theLeftIndent
	  	\rightskip=\theRightIndent
	  	%\advance\hsize by -\leftskip
	 	  %\advance\hsize by -\rightskip
	  	\parfillskip=\theParFill
      %\noexpand\showthe\noexpand\parindent
    }%
   \NameEDef{end\theName}{\par}
}


\def\BodyTextFont{\rmfamily\normalsize}
\def\baselinestretch{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 		Making TOC Entries 						%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\def\StartTOC{\@starttoc{toc}}

\def\@starttoc#1{%
    \begingroup
        \makeatletter
        \@input{\jobname.#1}%
        \if@filesw 
           \expandafter\newwrite\csname tf@#1\endcsname
              \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
        \fi 
        \global\@nobreakfalse 
    \endgroup}
 
 
\let\protect=\relax


% AddContentsLine:
% 
%     #1 = filename e.g. toc, lof, lot
%     #2 = level
%     #3 = number
%     #4 = title
%     
 
\def\AddContentsLine#1#2#3#4{%
   \if@filesw 
      \begingroup
         \let\label\@gobble 
         \let\index\@gobble 
         \let\glossary\@gobble
         \def\protect##1{%
             \string\string\string##1\string\space\space}%
         \@temptokena{\thepage}%
         \edef\@tempa{%
             \write \@auxout{%
                 \string\@writefile{#1}%
                      {\protect\ContentsEntry{#2}{#3}{#4}{\the\@temptokena}}%
             }%
         }%
         \@tempa
         \if@nobreak 
             \ifvmode
                \nobreak
             \fi
         \fi
     \endgroup
  \fi}
 
\long\def\AddToContents#1#2{\if@filesw \begingroup
\let\label\@gobble \let\index\@gobble \let\glossary\@gobble
\def\protect##1{\string\string\string##1\string\space\space}%
\edef\@tempa{\write \@auxout {\string\@writefile{#1}{#2}}}\@tempa
  \if@nobreak \ifvmode\nobreak\fi\fi\endgroup\fi}
 
\def\contentsline#1{\csname l@#1\endcsname}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Division		  						                %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\def\CurrentDivisionTitle{\noexpand\@CurrentHeading}
%\def\CurrentShortDivisionTitle{\noexpand\@CurrentShortHeading}

\MakeParam{Level}

\newif\ifEZEnterTOC
\def\EZEnterInTOC#1{\csname EZEnterInTOC#1\endcsname}


\newif\ifEZPrintNumber
\def\EZPrintNumber#1{\csname EZPrintNumber#1\endcsname}

\newif\ifEnterInTOC
\def\EnterInTOC#1{\csname EnterInTOC#1\endcsname}

\newif\ifSetRightMark
\def\SetRightMark#1{\csname SetRightMark#1\endcsname}

\newif\ifSetLeftMark
\def\SetLeftMark#1{\csname SetLeftMark#1\endcsname}

\newif\ifDisplayedHeading
\def\DisplayedHeading#1{%
   \csname DisplayedHeading#1\endcsname
}

\newif\ifIndentFirstPar
\def\IndentFirstPar#1{\csname IndentFirstPar#1\endcsname}

\MakeParam{Position}
   	
  \def\StartCurrentPage{}
	\def\StartNextPage{\clearpage}
	\def\StartNextOddPage{\clearemptydoublepage}

	


\MakeParam{SkipBefore} 
\MakeParam{UseHeading}
\MakeParam{UseCounter}
\MakeParam{Components}
%\MakeParam{UseExceptPage}
\newif\ifUseExceptPage
\def\UseExceptPage#1{\csname UseExceptPage#1\endcsname}
\MakeParam{ExceptionalPage}


\def\helpera#1#2{\expandafter\helperb\expandafter{#1}{#2}}
\def\helperb#1#2{\expandafter\helperc\expandafter{#2}{#1}}
\def\helperc#1#2{\gdef\@themark{{#2}{#1}}}

\def\markboth#1#2{%
     \helpera{#1}{#2}%
     {\let\protect\noexpand
      \let\label\relax 
      \let\index\relax 
      \let\glossary\relax
      \mark{\@themark}}
      \if@nobreak\ifvmode\nobreak\fi\fi}

\def\markright#1{%
    {\let\protect\noexpand
     \let\label\relax 
     \let\index\relax 
     \let\glossary\relax
     \expandafter\expandafter\expandafter\@markright
         \expandafter\@themark\expandafter{#1}
     \mark{\@themark}%
    }%
    \if@nobreak\ifvmode\nobreak\fi\fi}

\def\markleft#1{%
    {\let\protect\noexpand
     \let\label\relax 
     \let\index\relax 
     \let\glossary\relax
     \expandafter\expandafter\expandafter\@markleft
         \expandafter\@themark\expandafter{#1}
     \mark{\@themark}%
    }%
    \if@nobreak\ifvmode\nobreak\fi\fi}

 
\def\@markright#1#2#3{\gdef\@themark{{#1}{#3}}}
\def\@markleft#1#2#3{\gdef\@themark{{#3}{}}}

\def\leftmark{\expandafter\@leftmark\botmark}
\def\rightmark{\expandafter\@rightmark\firstmark}
 


\def\Division#1{#1\DefineDivision}

\def\DefineDivision{%
	\ifDisplayedHeading
		\DefineDisplayDivision		
	\else
		\DefineInlineDivision
	\fi
}



\def\DefineDisplayDivision{
    \ifnum\theMode=0
        \DefineCusDispDiv
    \else
        \DefineEZDispDiv
    \fi
}

\def\DefineEZDispDiv{
    \NameEDef{\theName}{%
       \noexpand\@dblarg\CALL{@\theName}}

    \NameEDef{@\theName}[##1]##2{%        %
        \ifUseExceptPage
            \CALL{\theExceptionalPage}
        \else
            \CALL{Start\thePosition}
        \fi 
		    \ifnum\theLevel=1              % These counters are used for math reset
			    \noexpand\stepcounter{@LevelOneDiv}
		    \else\ifnum\theLevel=2
			    \noexpand\stepcounter{@LevelTwoDiv}
        \else\ifnum\theLevel=3
          \noexpand\stepcounter{@LevelThreeDiv}
        \else\ifnum\theLevel=4
          \noexpand\stepcounter{@LevelFourDiv}
        \else\ifnum\theLevel=5
          \noexpand\stepcounter{@LevelFiveDiv}
		    \fi\fi\fi\fi\fi
        \noexpand\refstepcounter{@\theUseCounter}
        %\def\noexpand\protect{\noexpand\noexpand}
	      \def\noexpand\@CurrentHeading{##2}
	      \def\noexpand\@CurrentShortHeading{##1}
        \noexpand\@@par
        \penalty\@secpenalty  
	      \noexpand\addvspace{\theSkipBefore}%
        \noexpand\SEEXPAND\CALL{\theUseHeading}%
        \ifSetRightMark
	          \ifSetLeftMark
		            \noexpand\markboth{\CurrentShortHeading}{\CurrentShortHeading}%
		        \else
	     	        \noexpand\markright{\CurrentShortHeading}%
	          \fi
	      \else
	          \ifSetLeftMark 
	              \noexpand\markboth{\CurrentShortHeading}{}%
	          \fi
	      \fi
        \noexpand\nobreak
	      \ifEnterInTOC
	          \noexpand\AddContentsLine%
	              {toc}%
	              {\theLevel}%
			          {\theComponents}%
	              {##1}%
	      \fi
	      \noexpand\nobreak
	      \ifIndentFirstPar\else\noexpand\SuppressNextIndent\fi
	 }%
   %\typeout{DEFINING A SECTIONING COMMAND:}
   %\DEBUG{@\theName}

}

\def\DefineCusDispDiv{
    \NameEDef{\theName}{%
       \noexpand\@dblarg\CALL{@\theName}}

    \NameEDef{@\theName}[##1]##2{%
     %\CALL{Start\thePosition}
     \ifUseExceptPage
            \CALL{\theExceptionalPage}
        \else
            \CALL{Start\thePosition}
     \fi 
     \noexpand\refstepcounter{@\theUseCounter}
     \ifnum\theLevel=1              % These counters are used for math reset
			  \noexpand\stepcounter{@LevelOneDiv}
		 \else\ifnum\theLevel=2
			  \noexpand\stepcounter{@LevelTwoDiv}
     \else\ifnum\theLevel=3
        \noexpand\stepcounter{@LevelThreeDiv}
     \else\ifnum\theLevel=4
        \noexpand\stepcounter{@LevelFourDiv}
     \else\ifnum\theLevel=5
        \noexpand\stepcounter{@LevelFiveDiv}
		 \fi\fi\fi\fi\fi
     \def\noexpand\@CurrentHeading{##2}
	   \def\noexpand\@CurrentShortHeading{##1}
     \noexpand\@@par
     \penalty\@secpenalty 
     \noexpand\addvspace{\theSkipBefore}
     \noexpand\SEEXPAND\CALL{\theUseHeading}%
     \noexpand\nobreak
     %\showboxdepth=10
     %\showboxbreadth=100
     %\showbox1
     %\def\noexpand\protect{\noexpand\noexpand}
     \ifSetRightMark
	      \ifSetLeftMark
		      \noexpand\markboth{\CurrentShortHeading}{\CurrentShortHeading}
		  \else
	     	  \noexpand\markright{\CurrentShortHeading}
	      \fi
	   \else
	      \ifSetLeftMark 
	          \noexpand\markleft{\CurrentShortHeading}
	      \fi
	   \fi
	   \ifEnterInTOC
	      \noexpand\AddContentsLine%
	         {toc}%
	         {\theLevel}%
			     {\theComponents}%
	         {##1}%
	   \fi
	   \noexpand\nobreak
	   \ifIndentFirstPar\else\noexpand\SuppressNextIndent\fi
	 }%
   %\typeout{DEFINING A SECTIONING COMMAND:}
   %\DEBUG{@\theName}
}



% INLINE DIVISIONS

\def\EatPar{%				 % Find a way to not use this macro.
   \def\par{\let\par\@@par}\ignorespaces%
}

\newif\ifIndentHeading
\def\IndentHeading#1{\csname IndentHeading#1\endcsname}

\def\DefineInlineDivision{%
    \NameEDef{\theName}{\noexpand\@dblarg\CALL{@\theName}}%
    \NameEDef{@\theName}[##1]##2{%
	      \def\noexpand\@CurrentHeading{##2}%
	      \def\noexpand\@CurrentShortHeading{##1}%
	      \CALL{Start\thePosition}%
	      \noexpand\refstepcounter{@\theUseCounter}%
        \ifnum\theLevel=1 % These counters are used for math reset
			      \noexpand\stepcounter{@LevelOneDiv}%
		    \else\ifnum\theLevel=2
			      \noexpand\stepcounter{@LevelTwoDiv}%
        \else\ifnum\theLevel=3
            \noexpand\stepcounter{@LevelThreeDiv}%
        \else\ifnum\theLevel=4
            \noexpand\stepcounter{@LevelFourDiv}%
        \else\ifnum\theLevel=5
          \noexpand\stepcounter{@LevelFiveDiv}%
		    \fi\fi\fi\fi\fi
	      \penalty\@secpenalty  
	      \vskip\theSkipBefore\relax
	      \ifIndentFirstPar
	      \else
	        \noexpand\noindent
	      \fi
	      \noexpand\SEEXPANDINLINE\CALL{\theUseHeading}%
	      \ifSetRightMark
	          \ifSetLeftMark
		          \noexpand\markboth{\CurrentShortHeading}{\CurrentShortHeading}%
		        \else
	     	      \noexpand\markright{\CurrentHeading}%
	          \fi
	      \else
	          \ifSetLeftMark 
	              \noexpand\markleft{\CurrentShortHeading}%
	          \fi
	      \fi
	      \ifEnterInTOC
	        \noexpand\AddContentsLine%
	            {toc}%
	            {\theLevel}%
			        {\csname\theUseCounter\endcsname}%
	            {##2}%
	      \fi
	      \noexpand\nobreak
	      \noexpand\EatPar     
	 }%
	 %\typeout{DEFINING A SECTIONING COMMAND:}
   %\DEBUG{@\theName}
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Lists			  						                  %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\EZListSetup#1{#1}

\MakeParam{LevelUp}	 

\MakeParam{Level}
\MakeParam{Components}
\MakeParam{LabelType}
\MakeParam{ParSep}
\MakeParam{LeftMar}
\MakeParam{RightMar}
\MakeParam{LabelWidth}
\MakeParam{LabelSep}
\MakeParam{TopSep}
\MakeParam{ParTopSep}
\MakeParam{ItemSep}
\MakeParam{ItemFont}
%\MakeParam{EZNumbered}
\newif\ifEZNumbered
\def\EZNumbered#1{\csname EZNumbered#1\endcsname}

\MakeParam{EZCounterApp}
\MakeParam{EZLabelApp}
\MakeParam{EZEntrySpacing}
\MakeParam{EZFont}
\MakeParam{EZLineSpacing}

\def\ListType{NoList}

\def\checkdepth{%
    \ifnum \@listdepth >5\relax 
       \@toodeep
    \else 
       \global\advance\@listdepth\@ne 
    \fi
}

\def\setdefaults{%
   	\rightmargin \z@
   	\leftmargin \z@ 
    \listparindent\z@ 
    \itemindent\z@
}


\def\StartListLevel#1{%
    \checkdepth
	  \setdefaults
    \csname #1\@Alph{\@listdepth}\endcsname%
    \if@inlabel 
       \@noparitemtrue 
       \@noparlisttrue
    \else 
       \@noparlistfalse 
       \@topsep\@topsepadd 
    \fi
    \parskip\parsep
    \parindent\listparindent
	  \parfillskip 0pt plus 1fil%
    \advance\linewidth -\rightmargin 
    \advance\linewidth -\leftmargin
	  \advance\leftskip by \leftmargin
	  \advance\rightskip by \rightmargin
	  \@totalleftmargin\leftskip
    \ignorespaces
}


\def\NormalLabelForm{\def\makelabel##1{\hss\llap{##1}}}

\def\DefineListLevel{%
   \ifnum\theMode=0
	   \DefineEZListLevel
	 \else
	   \DefineCusListLevel
	 \fi
}


\def\ItemCount{\noexpand\noexpand\noexpand\@ItemCount}

\def\DefineEZListLevel{%
	 \setcounter{Temp}{\theLevel}
	 \ifEZNumbered
	    \ifx\theEZLabelAppearance\NONE
		    \def\theComponents{\relax}
		  \else
		    \ListLabelApps
	 		  \expandafter\let\expandafter\theComponents\csname ListLabelApps\theEZLabelApp\endcsname
			  %\DEBUG{theEZLabelApp}
			  %\DEBUG{theComponents} 
    	\fi
	 \else
		  \edef\theComponents{\noexpand\expandafter\csname \theName count\endcsname } 
	 \fi
	 %\show\theEZLineSpacing
   \NameEDef{\theName}{%
      \topsep = \theTopSep
      \partopsep= \theParTopSep
      \noexpand\vspace{\theTopSep}
	    \noexpand \usecounter{@\theName count}
	    \def\noexpand\@ItemCount{\expandafter\noexpand\csname the@\theName count\endcsname}
      \def\noexpand\makelabel####1{%
         \noexpand\hss
         \noexpand\llap{%
            {\expandafter\noexpand\csname\theEZFont\endcsname####1}%
         }
      }
		  %\noexpand \NormalLabelForm    % Use the LabelType parameter to adjust this at some point
      \def\noexpand\@itemlabel{\theComponents}  
      \leftmargin=\theLeftMar
      \rightmargin=\theRightMar
      \labelsep = \theLabelSep
      \labelwidth  = \theLabelWidth
		  \itemindent = \theItemIndent
      \advance\labelwidth by -\labelsep
      \parindent = 0pt
      \parsep = \theParSep
      \itemsep = \theItemSep
      %\ifx\theEZEntrySpacing\Tight 
      %    \itemsep = 0pt
      %\else
      %    \itemsep = 6pt
      %\fi
		  \ifnum\theEZLineSpacing = 0
			     \def\noexpand\baselinestretch{\theSpacingABLSkip}
		  \else\ifnum\theEZLineSpacing = 1
		       \def\noexpand\baselinestretch{\theSpacingBBLSkip}
		  \else\ifnum\theEZLineSpacing = 2
		       \def\noexpand\baselinestretch{\theSpacingCBLSkip}
	    \fi\fi\fi
		  \noexpand\small\noexpand\normalsize
		  \expandafter\noexpand\csname\theEZFont\endcsname
     }
     %\DEBUG{\theName}  
}


\def\DefineCusListLevel{%
     \setcounter{Temp}{\theLevel}
     \NameEDef{\theName}{%
        \topsep = \theTopSep
        \partopsep= \theParTopSep
        \noexpand\vspace{\theTopSep}
	      \noexpand \usecounter{@\theName count}%
        \def\noexpand\makelabel####1{%
            \noexpand\hss
            \noexpand\llap{%
                {\expandafter\noexpand\csname\theItemFont\endcsname####1}%
            }
        }
        %\noexpand \NormalLabelForm    % Use the LabelType parameter to adjust this at some point
        \def\noexpand\@itemlabel{\theComponents}%  
        \leftmargin= \theLeftMar
        \rightmargin = \theRightMar
        \labelsep = \theLabelSep
        \labelwidth  = \theLabelWidth
		    \itemindent = \theItemIndent
        \advance\labelwidth by -\labelsep 
        \parsep = \theParSep
        \itemsep = \theItemSep
		    %\expandafter\noexpand\csname\theItemFont\endcsname
		 }
     %\DEBUG{\theName}  
}
    
\def\ListLevel#1{%
   \def\Name##1{\def\theName{##1}}
   #1%
   \DefineListLevel}


\def\List#1{%
   \def\Name##1{\def\@theName{##1}} % save the top level name
   #1%
   \NameEDef{\@theName}{\leavevmode\noexpand\StartListLevel{\@theName}}
   \NameEDef{end\@theName}{\vskip 4pt\noexpand\endlist}
   %\DEBUG{end\@theName}
   %\expandafter\let\csname end\@theName\endcsname=\endlist
   %\DEBUG{\@theName}
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 	    Contents 		  						%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\def\EZTOCSetup#1{\relax}

\def\Contents#1{#1}
%\MakeParam{LevelUp}   % already defined for lists above


\def\ContentsLevel#1{#1\DefineContentsLevel}


% These macros are taken from Bechtolsheims's Tex in Practice
% See vol III p 121...

\newcount\@GenTocEntryLevel

\def\GenTocEntry#1#2#3#4{%
   	 \par
	   \bgroup
	   \global\@GenTocEntryLevel = #1
		 \leftskip = #4
		 \parindent = #2
		 \advance\parindent by -#4
		 \dimen0 = #3
		 \advance\dimen0 by -#2
		 \@GenTocEntry
}

\def\@GenTocEntry#1#2#3#4#5#6#7#8{%
     \rightskip = #1 plus 1in
	   \parfillskip = #2
	   \advance\parfillskip by -#1
	   \csname#7\endcsname
	   \ifdim #3 > 0pt
	      \setbox0 = \hbox to #3{\hfil.\hfil}  
	   \else 
	      \setbox0 = \box\voidb@x
	   \fi
	   \leavevmode
	   \hbox to \dimen0 {#5\hfil}%
	   {#6\unskip}%
	   \ifvoid 0 
	      %\hfill
		    % This was changed to keep some space between 
		    % the text and the page number
		    \hskip 15pt plus 1fill
	   \else
	      \nobreak\leaders\copy0\hskip #4plus 1fil
	   \fi
	   #8%
	   \par
	 \egroup
}

% Here is the part that needs to be edited...

\def\ContentsEntry#1#2#3#4{%
     \par
	 \ifcase #1
	    Hello
     \or
	    \TocEntry{#1}{#2}{#3}{#4}
	 \or 
	    \TocEntryi{#1}{#2}{#3}{#4}
	 \or
	    \TocEntryii{#1}{#2}{#3}{#4}
	 \or
	    \TocEntryiii{#1}{#2}{#3}{#4}
	 \or
	    \TocEntryiv{#1}{#2}{#3}{#4}
	 \or 
	    \TocEntryv{#1}{#2}{#3}{#4}
	 \else
	    \xxx % Generate an error message
	 \fi
}


%\MakeParam{EZIndent}
\newif\ifEZIndent
\def\EZIndent#1{\csname EZIndent#1\endcsname}

\MakeParam{EZEntrySpace}
   \def\Tight{Tight}
   \def\Loose{Loose}

%\MakeParam{EZLeaderDots}
\newif\ifEZLeaderDots
\def\EZLeaderDots#1{\csname EZLeaderDots#1\endcsname}

%\MakeParam{EZPgNmPlace}
\newif\ifEZPgNmPlace
\def\EZPgNmPlace#1{\csname EZPgNmPlace#1\endcsname}

%\MakeParam{EZContinueIndent}
\newif\ifEZContinueIndent
\def\EZContinueIndent#1{\csname EZContinueIndent#1\endcsname}

\MakeParam{EZFont}
\MakeParam{InterItemPenalty}
\MakeParam{InterItemSkip}
\MakeParam{LeftMarginToNumber}
\MakeParam{LeftMarginToText}
\MakeParam{ContinuationIndent}
\MakeParam{RightMarginToNumber}
\MakeParam{RightMarginToText}
\MakeParam{DotSeparation}
\MakeParam{MinDotLength}


\def\ContentsLevel#1{%
   #1
	 \ifnum\theMode=0
	 	  \DefineEZContentsLevel
	 \else\ifnum\theMode=2
	 \else
	    \DefineContentsLevel
	 \fi\fi
}


\newcounter{Temp}

\def\DefineContentsLevel{%
   \setcounter{Temp}{\theLevel}
	 \advance\c@Temp by -1
	 \NameEDef{TocEntry\roman{Temp}}##1##2##3##4{%
	    \noexpand\addpenalty{\theInterItemPenalty}
	    \noexpand\addvspace{\theInterItemSkip}
      \noexpand\GenTocEntry{\theLevel}%
	          {\theLeftMarginToNumber}%
	          {\theLeftMarginToText}%
	          {\theContinuationIndent}%
	          {\theRightMarginToText}%
					  {\theRightMarginToNumber}%
	          {\theDotSeparation}%
	          {\theMinDotLength}%
	          {##2}%
	          {##3}%
	          {\theFont}%
	          {##4}%
	 }
	 %\DEBUG{TocEntry\roman{Temp}}
}


\def\DefineEZContentsLevel{%
     \setcounter{Temp}{\theLevel}
	   \advance\c@Temp by -1
	   \NameEDef{TocEntry\roman{Temp}}##1##2##3##4{%
	       \noexpand\addpenalty{\theInterItemPenalty}
		%
	       \ifx\theEZEntrySpace\Tight
		     \else 
		        \noexpand\addvspace{\theInterItemSkip}
		     \fi
		     \@tempdima=\theLeftMarginToText
		     \@tempdimb=\theLeftMarginToNumber
		     \ifEZIndent
		     \else
 		        \advance\@tempdima by 20pt
			      \advance\@tempdimb by 20pt
		     \fi
         \noexpand\GenTocEntry{\theLevel}%
	          {\@tempdimb}%
	          {\@tempdima}%
	          {\ifEZContinueIndent
	             0pt%
					   \else
					     \@tempdima
	           \fi}%
	          {\theRightMarginToText}%
					  {\ifEZPgNmPlace 
					     0pt plus 1filll
					   \else
					     \theRightMarginToNumber
					   \fi}%
	          {\ifEZLeaderDots 5pt\else 0pt\fi}%
	          {\theMinDotLength}%
	          {##2}%
	          {##3}%
	          {\theEZFont}%
	          {##4}%
	 }
	 %\DEBUG{TocEntry\roman{Temp}}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		EZ Bibliography	Setup   		              %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   \MakeParam{SpacingABLSkip}
   \MakeParam{SpacingBBLSkip}
   \MakeParam{SpacingCBLSkip}
   \MakeParam{SpreadAParSkip}
   \MakeParam{SpreadBParSkip}
   \MakeParam{IndentA}
   \MakeParam{IndentB}
   \MakeParam{IndentC}

   \def\EZBibSetup#1{#1}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Bibliography	  						              %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% BIBLIOGRAPHY

   \MakeParam{EZBibIndent}
      \def\Block{Block}
      \def\Indent{Indent}
      \def\Outdent{Outdent}

   \MakeParam{EZLabelApp}
   \MakeParam{EZEntrySpacing}
   \MakeParam{EZSpacing}      % This one doesn't do anything yet
   \MakeParam{EZFont}
   \MakeParam{CiteComponents}
   \MakeParam{CiteFont}
   \MakeParam{LabelComponents}
   \MakeParam{LabelFont}
   \MakeParam{LabelSep}
   \MakeParam{LabelWidth}
   \MakeParam{EntryFont}
   \MakeParam{ItemIndent}
   \MakeParam{ItemSep}
   \MakeParam{LeftMar}
   \MakeParam{RightMar}
   \MakeParam{LineSpacing}


\def\Bibliography#1{#1\DefineBibliography}

\def\DefineBibliography{
	\ifnum\theMode=0
 	   \DefineEZBib
	\else
     \DefineCusBib
	\fi
}


\def\SetSfcode{\sfcode`\.=1000\relax}

\def\NormalLabelForm{\def\makelabel##1{\hss\llap{##1}}}

\def\DefineEZBib{%
     \BibLabelApps
     \edef\thebibliography##1{
	      \noexpand \usecounter{@bibitemCount}
        \noexpand \NormalLabelForm   
        \ifx\theEZLabelApp\NONE
           \let\LabelComponents=\relax
	      \else
           %\noexpand\DEBUG{BibLabelApps\theEZLabelApp}
	 	       \let\noexpand\theLabelComponents
	 	          =\expandafter\noexpand\csname BibLabelApps\theEZLabelApp\endcsname
        \fi
        \def\noexpand\@itemlabel{%
            {\expandafter\noexpand\csname\theLabelFont\endcsname
             \noexpand\theLabelComponents}}%
        %\noexpand\DEBUG{theLabelComponents}
        \leftmargin= \theLeftMar
        \rightmargin = \theRightMar
        \labelsep = \theLabelSep
        \labelwidth  = \leftmargin
        \advance\labelwidth by -\labelsep 
        \itemsep = \theItemSep
        \def\noexpand\newblock{\hskip .11em plus.33em minus.07em}%
        \noexpand\sloppy
        \clubpenalty4000
        \widowpenalty4000
        \noexpand\SetSfcode
		    \noexpand\@trivlist
        \ifx\theEZEntrySpacing\Loose	% Need to hook this to F2-dialog
          \itemsep = \theSpreadBParSkip
        \else
          \itemsep = \theSpreadAParSkip
        \fi 
        \parindent\listparindent
        \advance\linewidth -\rightmargin 
        \advance\linewidth -\leftmargin
        \advance\@totalleftmargin \leftmargin
        \ifx\theEZBibIndent\Block
		       \itemindent = \theIndentA  
		    \else\ifx\theEZBibIndent\Indent
           \itemindent = \theIndentB
        \else\ifx\theEZBibIndent\Outdent
           \itemindent = \theIndentC
        \fi\fi\fi
        \ifnum\theEZSpacing=0
           \noexpand\SetLineSpace{\theSpacingABLSkip}
        \else\ifnum\theEZSpacing=1
           \noexpand\SetLineSpace{\theSpacingBBLSkip}
        \else
           \noexpand\SetLineSpace{\theSpacingCBLSkip}
        \fi\fi
		    \CALL{\theEZFont}
        \parshape \@ne \@totalleftmargin \linewidth
        \ignorespaces
     }
     \def\endthebibliography{%
        \def\@noitemerr{\@warning{Empty `thebibliography' environment}}%
		    \endlist
     }
     %\DEBUG{thebibliography}
     %\DEBUG{endthebibliography}
}


\def\DefineCusBib{%
     \edef\thebibliography##1{%
	    \noexpand \usecounter{@bibitemCount}
        \noexpand \NormalLabelForm    % Use the LabelType parameter to adjust this at some point
        \def\noexpand\@itemlabel{%
            {\expandafter\noexpand\csname\theLabelFont\endcsname
             \theLabelComponents}}%
        %\noexpand\DEBUG{@itemlabel}  
        \leftmargin= \theLeftMar
        \rightmargin = \theRightMar
        \labelsep = \theLabelSep
        \labelwidth  = \leftmargin
        \advance\labelwidth by -\labelsep 
        %\parsep = \theParSep
        %\topsep = \theTopSep
        %\partopsep= \theParTopSep
        \def\noexpand\newblock{\hskip .11em plus.33em minus.07em}%
        \noexpand\sloppy
        \clubpenalty4000
        \widowpenalty4000
        \noexpand\SetSfcode
		    \noexpand\@trivlist
        \parskip\parsep 
        \parindent\listparindent
        \advance\linewidth -\rightmargin 
        \advance\linewidth -\leftmargin
        \itemsep = \theItemSep
		    \itemindent = \theItemIndent
        \advance\@totalleftmargin \leftmargin
        \parshape \@ne \@totalleftmargin \linewidth
        \ignorespaces
		    \CALL{\theEntryFont}
     }
     \def\endthebibliography{%
        \def\@noitemerr{\@warning{Empty `thebibliography' environment}}%
		    \endlist
     }
     %\DEBUG{thebibliography}	       
}


    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 		Math			  						%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   \MakeParam{EZLabelAppearance}
   \MakeParam{EZReset}  % This should be taken out 
   \MakeParam{EZLabelPosition}
   \def\Left{Left}
   \def\Right{Right}
  
   \MakeParam{EZEquationPosition}
   \def\Center{Center}

   \MakeParam{UseCounter}
   \MakeParam{Label}
   \MakeParam{LabelFont}

   %\MakeParam{EquationsFlushLeft}
   \newif\ifEquationsFlushLeft
   \def\EquationsFlushLeft#1{\csname EquationsFlushLeft#1\endcsname}

   %\MakeParam{LabelsOnRight}
   \newif\ifLabelsOnRight
   \def\LabelsOnRight#1{\csname LabelsOnRight#1\endcsname}

   \MakeParam{MathIndent}
   \MakeParam{Jot}
   \MakeParam{ArrayStretch}
   \MakeParam{BeforeSkip}
   \MakeParam{BeforeShortSkip}
   \MakeParam{AfterSkip}
   \MakeParam{AfterShortSkip}
   \MakeParam{ArrayColSep}
   \MakeParam{ArrayRuleWidth}

% Displayed equations

% We redefine \equation to use \theCounter rather than c@equation....


% Flush left equation option
\def\fleqn{%
   \def\[{\relax
          \ifmmode
             \@badmath
          \else
             \begin{trivlist}%
                \@beginparpenalty\predisplaypenalty
                \@endparpenalty\postdisplaypenalty
                \item[]\leavevmode
                \hbox to\linewidth\bgroup $\m@th\displaystyle
                \hskip\mathindent\bgroup
          \fi}

   \def\]{\relax
       \ifmmode 
            \egroup $\hfil \egroup 
            \end{trivlist}
       \else 
            \@badmath 
       \fi}

   \def\equation{%
      \@beginparpenalty\predisplaypenalty
      \@endparpenalty\postdisplaypenalty
      \refstepcounter{@equationCount}         
      \trivlist \item[]\leavevmode
      \hbox to\linewidth\bgroup $\m@th% $ TO MAKE DOLLAR NESTING OK
      \displaystyle
      \hskip\mathindent}

   \def\endequation{$\hfil
      \displaywidth\linewidth\@eqnnum\egroup \endtrivlist}


   \def\eqnarray{%
       \stepcounter{equationCount}
       \let\@currentlabel=\theequationCount
       \global\@eqnswtrue
       \global\@eqcnt\z@\tabskip\mathindent\let\\=\@eqncr
       \abovedisplayskip\topsep
       \ifvmode\advance\abovedisplayskip\partopsep\fi
       \belowdisplayskip\abovedisplayskip
       \belowdisplayshortskip\abovedisplayskip
       \abovedisplayshortskip\abovedisplayskip
       $$\m@th\halignto\linewidth\bgroup\@eqnsel\hskip\@centering$\displaystyle\tabskip\z@
       {####}$&\global\@eqcnt\@ne \hskip 2\arraycolsep \hfil${####}$\hfil
       &\global\@eqcnt\tw@ \hskip 2\arraycolsep $\displaystyle{####}$\hfil
       \tabskip\@centering&\llap{####}\tabskip\z@\cr}


   \def\endeqnarray{\@@eqncr\egroup
      \global\advance\c@equation\m@ne$$\global\@ignoretrue
   }
}%  End of fleqn

\newdimen\mathindent
\mathindent = \leftmargini

\def\Math#1{#1\DoEquationSetup}

\def\DoEquationSetup{
		\ifnum\theMode=0
			\EZMathSetup
		\else
		    \CustomMathSetup
		\fi
}


\def\EZMathSetup{
    \MathLabelApps
    \ifx\theEZLabelAppearance\NONE
	  \else
	 	  \expandafter\let\expandafter\theLabel\csname MathLabelApps\theEZLabelAppearance\endcsname
		%\DEBUG{theEZLabelAppearance}
		%\DEBUG{theLabel} 
    \fi
    \edef\equation{$$ % $$ BRACE MATCHING HACK
    \noexpand\refstepcounter{@equationCount}}
    %\DEBUG{equation}
    \ifx\theEZEquationPosition\Left
	   	\fleqn
       	\mathindent = \theMathIndent
    \fi
	\def\DefineEqnNum##1{
		\ifx\theEZLabelPosition\Right
	   		\def\@eqnnum{{\BodyTextFont ##1}}
		\else
	   		\def\@eqnnum{\hbox to 0.1pt{}\rlap{\hskip -\displaywidth{\BodyTextFont ##1}}}
		\fi
	}
	\expandafter\DefineEqnNum\expandafter{\theLabel}
	\abovedisplayskip = \theBeforeSkip
	\abovedisplayshortskip = \theBeforeShortSkip
	\belowdisplayskip = \theAfterSkip
	\belowdisplayshortskip = \theAfterShortSkip
	\arraycolsep = \theArrayColSep
	\arrayrulewidth = \theArrayRuleWidth
}

\def\CustomMathSetup{
    \edef\equation{$$ % $$ BRACE MATCHING HACK
          \noexpand\refstepcounter{@equationCount}}
    %\DEBUG{equation}
    \ifEquationsFlushLeft
	   \fleqn
       \mathindent = \theMathIndent
    \fi
	\ifLabelsOnRight
	   \edef\@eqnnum{\theLabel}
	\else
	   \edef\@eqnnum{\hbox to 0.1pt{}\rlap{\hskip -\displaywidth\theLabel}}
	\fi
	\abovedisplayskip = \theBeforeSkip
	\abovedisplayshortskip = \theBeforeShortSkip
	\belowdisplayskip = \theAfterSkip
	\belowdisplayshortskip = \theAfterShortSkip
	\arraycolsep = \theArrayColSep
	\arrayrulewidth = \theArrayRuleWidth
}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												%
% 		Theorem Statements 						%
%												%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\Theorem#1{#1\DefineTheorem}

   %\MakeParam{UseWithin}
   \newif\ifUseWithin
   \def\UseWithin#1{\csname UseWithin#1\endcsname}

   \MakeParam{CounterRef}
   \MakeParam{Style}

   \MakeParam{BodyFont}
   \MakeParam{SkipBeforet}
   \MakeParam{SkipAfter}
   \MakeParam{LeadIn}


\input theorem.sty
\def\it{\itshape}

\def\TheDocument{Document}

\def\DefineTheorem{
   \expandafter\theoremstyle\expandafter{\theStyle}
   \expandafter\theorembodyfont\expandafter{\csname\theBodyFont\endcsname}
   \ifUseWithin
       \ifx\theCounterRef\TheDocument
	      \edef\defineit{\noexpand\newtheorem{\theName}{\theLeadIn}}
       \else
          \edef\defineit{\noexpand\newtheorem{\theName}{\theLeadIn}[@\theCounterRef Count]}
	   \fi
   \else
       \edef\defineit{\noexpand\newtheorem{\theName}[\theCounterRef]{\theLeadIn}}
   \fi
   %\DEBUG{defineit}
   \defineit 
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Exceptional pages 						            %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   \MakeParam{LeftFoot}
   \MakeParam{LeftHead}
   \MakeParam{MidFoot}
   \MakeParam{MidHead}
   \MakeParam{RightFoot}
   \MakeParam{RightHead}
   \MakeParam{VerticalMaterial}
   %\MakeParam{AllowText}
   \newif\ifAllowText
   \def\AllowText#1{\csname AllowText#1\endcsname}
   \MakeParam{Start}
      \def\NextPage{NextPage}
      \def\NextOddPage{NextOddPage}

\def\Exception#1{#1\DefineException}

\def\DefineException{%
   \NameEDef{\theName}{%
 	     \ifx\theStart\NextOddPage
           \noexpand\clearemptydoublepage
			 \else
           \noexpand\clearonepage
       \fi
	     \noexpand\thispagestyle{\theName}
			 \noexpand\begingroup  
          \noexpand\global\noexpand\@topnum= 0
          \noexpand\SpaceVertically 
          \if@twocolumn
             \noexpand\twocolumn[\theVerticalMaterial]
          \else
             \noexpand\null
             \theVerticalMaterial
          \fi
			    \noexpand\endgroup
			 \ifAllowText\else\clearpage\fi
	  }%
  %\DEBUG{\theName}
  \NameEDef{ps@\theName}{%
    \def\noexpand\@oddhead{%
       \noexpand\@threepart%
                 {\theLeftHead}%
                 {\theMidHead}%
                 {\theRightHead}}%
   \let\noexpand\@evenhead=\noexpand\@oddhead
   \def\noexpand\@oddfoot{%
      \noexpand\@threepart
                 {\theLeftFoot}%
                 {\theMidFoot}%
                 {\theRightFoot}}
   \let\noexpand\@evenfoot=\noexpand\@oddfoot   
}

}



    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Environments	  						              %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\def\Environment#1{#1\DefineEnvironment}

   \MakeParam{Prefix}
   \MakeParam{ParagraphType}
   \MakeParam{Suffix}


\def\DefineEnvironment{
  \edef\DefineIt{%
	    \noexpand\newenvironment{\theName}%
	         {\noexpand\SpaceVertically
            \thePrefix%
	          \CALL{\theParagraphType}%
            \par}%
		       {\par\theSuffix}
  }
	%DEBUG{DefineIt}
  \DefineIt
	%\DEBUG{\theName}
  %\DEBUG{end\theName}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Label Appearance  						            %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	\MakeParam{LabelA}
	\MakeParam{LabelB}
	\MakeParam{LabelC}
	\MakeParam{LabelD}
	\MakeParam{LabelE}

	\def\NONE{NONE}

\def\LabelAppSet#1{#1\DefineLabelAppSet}

\def\DefineLabelAppSet{
	\NameEDef{\theName}{%
		\def\csname \theName LabelA\endcsname{\theLabelA}
		\def\csname \theName LabelB\endcsname{\theLabelB}
		\def\csname \theName LabelC\endcsname{\theLabelC}
		\def\csname \theName LabelD\endcsname{\theLabelD}
		\def\csname \theName LabelE\endcsname{\theLabelE}
    }
	%\DEBUG{\theName}
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Text Tags         						            %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\MakeParam{Red}
\MakeParam{Green}
\MakeParam{Blue}
\MakeParam{ScreenFace}

\def\TextTag#1{#1\DefineTextTag}

\def\DefineTextTag{%
   \NameEDef{\theName}{\CALL{\theFont}}
   %\DEBUG{\theName}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Shell Descriptor  						            %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\def\ShellDescriptor#1{\relax}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Vertical Material  						            %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\MakeParam{Material}

\def\Vertical#1{#1\DefineVertical}

\def\DefineVertical{%
    \NameEDef{\theName}{%
       \theMaterial
    }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%												                        %
% 		Index  					            	            %
%												                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\MakeParam{ItemIndent}
\MakeParam{SubitemIndent}
\MakeParam{Initials}
\MakeParam{NumColumns}

\def\Index#1{#1\DefineIndex}

\def\DefineIndex{
  \newenvironment{theindex}
               {\columnseprule \z@
                \columnsep 35\p@
                \parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\@idxitem
                \begin{multicols}{\theNumColumns}%
               }%
               {\end{multicols}}
  \newcommand\@idxitem  {\par\hangindent \theItemIndent}
  \newcommand\subitem   {\par\hangindent \theSubitemIndent}
  \newcommand\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
  \newcommand\indexspace{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}
}







% These counters are defined for every style


\Counter{
   \Name{LevelFiveDiv}
   \Mode{0}
   \ResetOn{Document}
   \Appearance{Roman}
   \RefPrefix{}
   \InitialValue{0}
}
\Counter{
   \Name{LevelFourDiv}
   \Mode{0}
   \ResetOn{Document}
   \Appearance{Roman}
   \RefPrefix{}
   \InitialValue{0}
}
\Counter{
   \Name{LevelOneDiv}
   \Mode{0}
   \ResetOn{Document}
   \Appearance{Roman}
   \RefPrefix{}
   \InitialValue{0}
}
\Counter{
   \Name{LevelThreeDiv}
   \Mode{0}
   \ResetOn{Document}
   \Appearance{Roman}
   \RefPrefix{}
   \InitialValue{0}
}
\Counter{
   \Name{LevelTwoDiv}
   \Mode{0}
   \ResetOn{Document}
   \Appearance{Roman}
   \RefPrefix{}
   \InitialValue{0}
}


% Tables and figures are hard-wired in here 
% for the time being.
\def\figurename{Figure}
\def\tablename{Table}
\newcounter{figure}
\renewcommand\thefigure{\@arabic\c@figure}
\def\fps@figure{tbp}
\def\ftype@figure{1}
\def\ext@figure{lof}
\def\fnum@figure{\figurename~\thefigure}
\newenvironment{figure}
               {\@float{figure}}
               {\end@float}
\newenvironment{figure*}
               {\@dblfloat{figure}}
               {\end@dblfloat}
\newcounter{table}
\renewcommand\thetable{\@arabic\c@table}
\def\fps@table{tbp}
\def\ftype@table{2}
\def\ext@table{lot}
\def\fnum@table{\tablename~\thetable}
\newenvironment{table}
               {\@float{table}}
               {\end@float}
\newenvironment{table*}
               {\@dblfloat{table}}
               {\end@dblfloat}
\newlength\abovecaptionskip
\newlength\belowcaptionskip
\setlength\abovecaptionskip{10\p@}
\setlength\belowcaptionskip{0\p@}
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \setbox\@tempboxa\hbox{#1: #2}%
  \ifdim \wd\@tempboxa >\hsize
    #1: #2\par
  \else
    \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}

% More hard-wired stuff
\tabcolsep = 6pt
\let\center\@undefined
\labelsep=6pt % For theorem statements
\doublerulesep=2pt

\def\BodyTextFont{\relax}
\def\ContentsName{Contents}

\def\ContentsSection#1{
   \vskip 5mm
   {\noindent\Large\bfseries \ContentsName}
   \vskip 2mm
}

\def\tableofcontents{%
   \ContentsSection{\ContentsName}%
   \@starttoc{toc}%
} % SciWord knows this name



\def\descriptionlabel#1{\hspace\labelsep \bf #1}
\def\description{\list{}{%
    \topsep 6pt
    \itemsep 6pt
    \parsep 6pt
    \labelwidth\z@ 
    \itemindent-\leftmargin
    \let\makelabel\descriptionlabel}}

\let\enddescription\endlist


\@twocolumnfalse
\@twosidetrue
\markboth{}{}

%\countdef\c@equation\count10 % should be same as equationCount

% Style editor style needs special endproof

\def\endproof{\mbox{\ \rule{.1in}{.1in}}\ifmmode\else\par\fi}
