% AddMaple.sty
% These are the environments used to generate Maple Input and Output in the
% CalcLabs with Maple style.  This is a modification of 
% mapleenvs.sty, maplems.sty, and lamaple,sty.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright (c) 1994 by Waterloo Maple Software, all rights reserved.
%
% Permission is granted to use this style without charge. It may
% also be redistributed providing that they are distributed as is
% and without charge.  You may modify these macros for your own use,
% and redistributed subject to the following condition:
%
% 1. The style name used for any modified version of this file is 
%    different from mapleenv.sty. 
%
% 2. You acknowledge this file as the source.
%
% 3. It is redistributed under the same terms and conditions 
%    as indicated here.
%
% Please send recommendations or requests for changes to:
%
% 	support@maplesoft.on.ca
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This latex style file defines environments suitable for 
% processing the latex documents exported from Maple worksheets.
% In particular, it defines each of:
%
%   maple commands,   \begin{mapleinput}...\end{mapleinput}, 
%
%   maple text output, \begin{maplettyout}...\end{maplettyout}, 
%
%   maple generated latex, \begin{maplelatex}...\end{maplelatex}
% 
%   maple separator lines, \maplesepline
%
%   maple plots , \mapleplot{filename}
%
% The mapleinput, and maplettyout environments are similar to 
% \begin{verbatim}...\end{verbatim} in effect.  
% but there are several important differences.
%
% - the spacing relative to the surrounding environment is different.
%
% - page breaks are encourages before commands, or after results.
%
% - maplettyout and maplelatex environments are assumed to follow
% mapleinput regions and so have less space above.  This allows us to
% reduce the space between adjacent Maple regions without any
% elaborate mechanism to detect when there have been intervening
% paragraphs of text.
%
% - the size of the font for text regions is definable.
%
% - the  indentation of the environments can be indented by setting 
% the value of \LeftMapleSkip  .
%
% The current definition of \mapleplot is appropriate for use with 
% the psfig macros and has been tested with psfig Version 1.9. It
% assumes that the plot is in landscape mode, but parameters can be
% changed to deal with rotation, etc.
%%
% J. S. Devitt,  February, 1994.
%
% The User Definable parameters are
% \AboveMaplePlot	- space above a Maple Plot 
% \BelowMaplePlot	- space below a Maple Plot
% \MaplePlotHeight	- vertical space reserved for a plot
% \MaplePlotWidth	- width reserved for a plot
% \MaplePlotAngle	- angle of rotatation
% \AboveMapleSkip	- space above an environment
% \BelowMapleSkip	- space below an environment
% \LeftMapleSkip 	- the amount of left indentation
% \MapleFont 		- The Maple font 
% \MapleSize 		- The size of the Maple font 
% \MapleFirstLine	- controls ingoring first line feed
% \MaplePrompttrue 	- controls insertion of prompt char
% \MaplePromptString	- defines the prompt character
% \MapleSkip		- amount of glue before and after
%			displayed text
% \MapleTab		- number of spaces per tab (8)
% \MapleParCount	- counter used to detect adjacent Maple
%			regions.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Definitions of dimensions, etc.  Those which can be reset are "set" to 
% specific values in the following section.  CHANGE THEIR VALUES THERE.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newskip\AboveMaplePlot
\newskip\BelowMaplePlot
\newskip\AboveMapleSkip
\newskip\BelowMapleSkip
\newdimen\LeftMapleSkip 
\newdimen\MaplePlotHeight 
\newdimen\MaplePlotWidth 
% \newcount\MaplePlotAngle 
\newdimen\MapleSepLineWidth 
\newdimen\MapleSepLineHeight \MapleSepLineHeight = 0.01in
\newif\ifMaple		\Maplefalse
\newif\ifMapleFirstLine
\newif\ifMaplePrompt
\newcount\MapleTab	\MapleTab = 8
\newcount\MapleParCount   \MapleParCount=0 
\newtoks\MaplePromptString \MaplePromptString = {}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set All User-Setable Parameters in this section 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\MaplePromptString = {\raise 1pt \hbox{$\scriptstyle>$\space}}
%
%  output environment spacing
\AboveMapleSkip = 1ex plus 2 pt minus 1 pt
\BelowMapleSkip = \AboveMapleSkip
\LeftMapleSkip  = 5ex		  % environment spacing
%
%  plot parameters
\AboveMaplePlot = 2\AboveMapleSkip
\BelowMaplePlot = 2\AboveMapleSkip
\MaplePlotHeight = 40ex 
\MaplePlotWidth = 60ex
\edef\MaplePlotAngle{270}		  % plots in landscape mode
%
% separator line parameters
\let\MapleSepLineWidth\linewidth  % \let so it will be redefined 
				  % properly for narrow environments.
\MapleSepLineHeight = 1pt
%\let\MapleFont\tt
%\let\MapleFont\sf
%\newcommand{\mif}{\MapleFont}
%\newcommand{\mif}{\sffamily\bfseries}  % JCS modified this line
\newcommand{\mif}{%
   \sffamily\bfseries
   \MakeActive{"}\ObeyQuote
   \MakeActive{>}\ObeyGr
   \MakeActive{_}\ObeyUnderscore
}
\newcommand{\MapleFont}{\sffamily\bfseries}
\let\MapleSize\small
\MapleFirstLinefalse  % Ignore first \cr after \begin{mapleinput}  
\MaplePrompttrue      % Include the prompt string for each input line.
\MapleTab = 8
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Utilities used to define the main environments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\makeatletter
% Utilities for changing character codes
\def\MakeLetter#1{\catcode `#1 = 11 }
\def\MakeOther#1{\catcode `#1 = 12 }
\def\MakeActive#1{\catcode `#1 = \active\relax }
\def\MakeTabActive{\MakeActive{\^^I}}
\def\MakeEolActive{\MakeActive{\^^M}}
% Flag to control treatment of first new line char in maple envs
\newif\if@IgnoreNewLine
\@IgnoreNewLinetrue
%
% In a Maple tty environment every line is treated as a paragraph.
% The behavior at the end of every Maple paragraph (line) is given
% by, thereby inhibiting page breaks in such environments.
\def\@MaplePar{\nopagebreak[3]\par\@@par}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Characters requiring special treatment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Spaces
%%%%%%%%%%%%%%%%%%%%%%%
\def\MapleSpace{\ }
\def\@ObeySpaces{\MakeActive{\ }\@@ObeySpaces\relax}
{%
\MakeActive{\ }\gdef\@@ObeySpaces{\edef {\MapleSpace}}%
}%

% JCS included the following trick to get a > while in a 
% non tt font.
\font\foo=cmtt10  % This works
%\font\foo=cmmib10
%\font\foo=courbd
\def\GreaterThan{\raise -.8pt\hbox{{\noexpand\foo >}}}
%\def\GreaterThan{{\foo\char62}}
{%
  \MakeActive{>}\gdef\ObeyGr{\edef>{\GreaterThan}}%
}%

\def\LessThan{\raise -.8pt\hbox{{\noexpand\foo <}}}
{%
  \MakeActive{<}\gdef\ObeyLess{\edef<{\LessThan}}%
}%


\def\Underscore{{{\noexpand\foo \_}}}
{%
  \MakeActive{_}\gdef\ObeyUnderscore{\edef_{\Underscore}}%
}%

\def\DoubleQuote{{\noexpand\foo "}}
{%
  \MakeActive{"}\gdef\ObeyQuote{\edef"{\DoubleQuote}}%
}

{%
  \catcode`\<=1
  \catcode`\>=2
  \catcode`\{=11
  \catcode`\}=11
  \gdef\LeftBrace<<<\noexpand\foo {>>>
  \gdef\RightBrace<<<\noexpand\foo }>>>
  <%
    \MakeActive<{>%
    \gdef\ObeyLeftBrace<\edef{<\LeftBrace>>%
    \MakeActive<}>%
    \gdef\ObeyRightBrace<\edef}<\RightBrace>>%
  >%
>%



%%%%%%%%%%%%%%%%%%%%%%%
% Tabs
%%%%%%%%%%%%%%%%%%%%%%%
\newdimen\@MapleTabSize
\def\@ObeyTabs{\MakeTabActive\@@ObeyTabs\relax}
{%
\MakeTabActive\gdef\@@ObeyTabs{\def^^I{\@MapleTab}}  
}%
\def\@MapleTab{%
  \leavevmode   % ensure that we are in horizontal mode
  \egroup      % Terminate box register 0
  \dimen0=\wd0 % store its length and round up to next stop
  \divide\dimen0 by \@MapleTabSize
  \advance\dimen0 by 1sp
  \multiply \dimen0 by \@MapleTabSize
  \wd0 = \dimen0
  \box0
  \setbox0 = \hbox\bgroup
}
%%%%%%%%%%%%%%%%%%%%%%%
% End of Line Character
%%%%%%%%%%%%%%%%%%%%%%%
\def\@ObeyEol{\MakeEolActive\@@ObeyEol\relax}%
{%
  \MakeEolActive %
  \gdef\@@ObeyEol{%
    \let^^M=\@MapleEol%
  }%
}
\def\@MapleEol{%
  \if@IgnoreNewLine
  \else
    \leavevmode%
    \egroup%
    \box 0%
    \@MaplePar%
  \fi
  \@IgnoreNewLinefalse
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Definitions of Utilities for the Main Environments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Macro for setting up the verbatim like environents
% This is executed in the preamble to the corresp latex environment.
% The spacing above and below the environment is done in the
% preamble instead of here to enable this to be used in a variety
% of such environments.
\def\@SetupMapleTty#1{%
\begingroup
  %%%  Compute and set tab positions
  \setbox 0 = \hbox{\MapleSize\MapleFont X}
  \@MapleTabSize = \wd0
  \multiply\@MapleTabSize by \MapleTab
  \setbox0 = \hbox{\relax}  % Clearing \box 0
  %
  %%% set paragraph dimensions and line spacing
  \rightskip = 0pt 
  \parindent=0pt
  \parskip = 0pt 
  \leftskip=\LeftMapleSkip
  \parfillskip = 0pt plus 1fil
  %
  %%%  The next two parameters could have been changed 
  %%%  by a \raggedright so they are reset here.
  \spaceskip = 0pt   \xspaceskip = 0pt
  %
%%%  Should the first new line of the environment
%%%  be ignored?  Allows \begin... to be on a separate line
\ifnum #1 = 0 \@IgnoreNewLinetrue\else\@IgnoreNewLinefalse\fi%
%
%%% Get ready to handle every paragraph (recall paragraph == line )
\everypar = {\EveryParZ}%
\def\EveryParZ{%
  \ifMaplePrompt
    \the\MaplePromptString
  \fi
    \setbox0 = \hbox \bgroup
}%
%
%%%  Choose the type size and font - order is important
\MapleSize\MapleFont%
\lineskiplimit=0\normalbaselineskip
%\baselineskip=0.8\normalbaselineskip
\@noligs%
%\MakeAllActive%
\let\do\@makeother \dospecials
\catcode ``=\active
\frenchspacing%
\@ObeySpaces% 
\@ObeyTabs%
\@ObeyEol%
\MakeActive{>}%
\ObeyGr       %      These added by JCS 
\MakeActive{<}%
\ObeyLess
\MakeActive{_}%
\ObeyUnderscore
\MakeActive{\{}%
\ObeyLeftBrace
\MakeActive{\}}%
\ObeyRightBrace
\MakeActive{"}%
\ObeyQuote
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Behavior on exiting of special environments
\def\@EndMapleInput{%
  \endgroup  %% matches the \begingroup inside of @SetupMapleInput
}
%
\let\@EndMapleTtyout\@EndMapleInput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Macros executed to start Verbatim like environments
% for special Maple regions.  These calls do all the work
% of scanning for the environment terminator.
\def\ignorenext#1{\relax}
\begingroup
  \catcode`| = 0  % becomes the escape character
  \catcode`( = 1  % becomes a begin group
  \catcode`) = 2  % becomes an end group
  \catcode`@ = 11 % becomes a regular character (for macro names)
  \catcode`\{ = 12 % becomes an other character
  \catcode`\} = 12 % becomes a other character
  \catcode`\\ = 12 % becomes a other character
  %|gdef|@BeginMapleInput#1\end{mapleinput}(#1|end(mapleinput))%
  |gdef|@BeginMapleInput#1\end(#1|end(mapleinput)|ignorenext)%
  |gdef|@BeginMapleTtyout#1\end(#1|end(maplettyout)|ignorenext)%
|endgroup
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Definition of actual mapleinput environment.
% \begin{mapleinput} ...\end{mapleinput}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Page breaks are inhibited immediately following the input
% environment.  This assumes that no extra space is 
% required below the region as it is followed by some
% form of Maple output region.
%
\def\mapleinput{
%%%  Include Extra Spacing at top of display
\@MaplePar%
\if@minipage\removelastskip\vskip-1.3ex
\else\vskip\AboveMapleSkip\fi%
\@SetupMapleTty{0}% The 0 indicates ignore first new line
\@BeginMapleInput
}
%%%
\def\endmapleinput{
  \@EndMapleInput
  %\vskip\BelowMapleSkip
  \nopagebreak[3]
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Definition of the actual \maplettyout environment
% usage: \begin{maplettyout} ... \end{maplettyout}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This can use almost exactly the same setup and exit as for input. 
% The main difference is the treatment of prompts, and in page breaking
% Page breaks are inhibited before, and encouraged after.
\def\maplettyout{
  \MaplePromptfalse	  % No prompt is required in this environment.
  \nopagebreak[3]\@MaplePar
  \removelastskip
  \@SetupMapleTty{0}   % A 1 would indicate "respect first new line"
  \@BeginMapleTtyout
}
%%%
\def\endmaplettyout{
  \@EndMapleTtyout	
  \vskip\BelowMapleSkip
  \pagebreak[3]
  \par
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Maple Latex Environment
% \begin{maplelatex} ....\end{maplelatex}
% This environment is basically a wrapper around a display
% math environment.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Spacing is slightly different in a minipage, page breaks are
% encourages after the region, and inhibited before.
\newenvironment{maplelatex}{
  % \if@minipage\fi% 
  \parindent=0pt
  \parskip = 0pt 
  \parfillskip = 0pt plus 1fil
  \lineskiplimit=0\normalbaselineskip
  %\baselineskip=0.6\normalbaselineskip
  \abovedisplayskip=.4\AboveMapleSkip
  \belowdisplayskip=.4\AboveMapleSkip
  \def\arraystretch{1.5}
  \removelastskip
  \nopagebreak[3]\@@par
}{%
\baselineskip=\normalbaselineskip%
\pagebreak[3]\relax}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Separator Lines
% \maplesepLine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The %'s at the end of the lines are important here to
% avoid inserting uwanted newlines in the output stream.
\newcommand{\maplesepline}{\vskip \parskip%
\hrule\@height\MapleSepLineHeight\@width\MapleSepLineWidth%
\vskip \parskip\relax}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plots
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The following assumes you have already installed the psfig 
% macros on your system.  These are available without charge 
% from:
%
\input psfig.sty
\psrotatefirst
\def\mapleplot#1{
   \vskip\AboveMaplePlot
   \centerline{\vbox{\psfig{figure=#1,%
     height=\MaplePlotHeight,%
     width=\MaplePlotWidth,%
     angle=\MaplePlotAngle}}}
     \vskip\BelowMaplePlot
}
%
\makeatother



%% $Source: /u/maple/research/tex/inputs/RCS/maplems.sty,v $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (c) 1994 by Waterloo Maple Software, all rights reserved.
%
% Permission is granted to use this style without charge. It may
% also be redistributed providing that they are distributed as is
% and without charge.  You may modify these macros for your own use,
% and redistributed subject to the following condition:
%
% 1. The style name used for any modified version of this file is 
%    different from mapleenv.sty. 
%
% 2. You acknowledge this file as the source.
%
% 3. It is redistributed under the same terms and conditions
%    as indicated here.
%
% Please send recommendations or requests for changes to:
%
%       support@maplesoft.on.ca
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% This is a sample LaTeX style file to assist with printing 
% Maple Work Sheets, as produced by Maple's "Export to Latex".  This 
% can be used as part of the document style as in:
%
% 	\documentstyle[maplems]{article}
%
% It automatically includes the macros defined in mapleenv.sty
% Simply place mapleenv.sty and maplems.sty in the same directory as 
% your document, (or in a location indicated by your TEXINPUTS search 
% path).
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Change entries in this next section in order to change the way page 
% headings are handled.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \pagestyle{noheadings}
% \pagestyle{plain}
%\pagestyle{myheadings}
%\markright{\protect\rule[-5pt]{\linewidth}{1pt}\hspace{-\linewidth}%
%{\protect\large Maple V\ \  Release 3}%
%}
%}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The common user-settable parameters for documents are found in the 
% next section.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% main document settings  
%
%\topmargin=-.2in
%\textheight=8.75in
%\textwidth=6in
%\headheight=2.5ex
%\headsep=.17in
%\oddsidemargin=0.25in
%\evensidemargin=\oddsidemargin
%\parsep=2ex			  % space between item paragraphs
%\parskip=1.5ex  		  % space between paragraphs
%
% parameters controlling the special maple environments
%
%\input mapleenv.sty
\MaplePrompttrue      % generate a prompt at start of each line?
\MaplePromptString = {\raise 1pt \hbox{$\scriptstyle>$\space}}
\AboveMapleSkip = 1ex plus 2 pt minus 1 pt
\BelowMapleSkip = \AboveMapleSkip
\LeftMapleSkip  = 5ex
\AboveMaplePlot = 2\AboveMapleSkip
\BelowMaplePlot = 2\AboveMapleSkip
\MaplePlotHeight = 25ex
\MaplePlotWidth = 1.3\MaplePlotHeight
\edef\MaplePlotAngle{270}
\let\MapleSepLineWidth\linewidth  % \let so that it will be redefined 
				  % properly for narrow environments.
\MapleSepLineHeight = 1pt
%\let\MapleFont\tt     % font used for input and ttyout
%\let\MapleFont\sf     % font used for input and ttyout
\def\MapleFont{\sffamily\bfseries}
\let\MapleSize\small  % font size for input and ttyout
\MapleFirstLinefalse  % hides first \cr of \mapleinput
\MapleTab = 8	      % spaces used by the tab character.
%%% psfig macros (if used)
% \psdraft
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\def\maplesepline{\vskip 4mm}

\input grey.sty

\newif\ifInGrayBox \InGrayBoxfalse
\def\maplesepline{%
   \ifInGrayBox
      \vspace{1mm}
      \end{boxitpara}
      \InGrayBoxfalse
   \else
      \InGrayBoxtrue
      \begin{boxitpara}
   \fi
}

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

\lineskiplimit=2pt
\lineskip=2pt

\AboveMapleSkip=2pt
\BelowMapleSkip=2pt

\newdimen\axislen
\axislen=.7in
\def\AXES{%
  \setbox2=\vbox{%
    \setbox0=\hbox{%
        \noindent\null
        \hskip\axislen\hskip 1mm
        \rule{.4pt}{2\axislen}%
    }
    \wd0=0pt \ht0=0pt \dp0=0pt
    \vskip 2\axislen
    \vskip -\baselineskip\box0\vskip \baselineskip\vskip -2\axislen
%
    \setbox1=\vbox{%
       \noindent
       \vskip\axislen\vskip -1.7\baselineskip
       \rule{2\axislen}{.4pt}%
    }
    \wd1=0pt \ht1=0pt \dp1=0pt
    \box1
  }%
  \ht2=0pt \wd2=0pt \dp2=0pt
  \box2
}

\makeatletter
\def\ps@intro{
  \def\@oddhead{\@threepart{{\sffamily Introduction}}{\oddmiddlehead}{\oddrighthead}}
  \def\@oddfoot{\@threepart{\oddleftfoot}{\oddmiddlefoot}{\oddrightfoot}}
  \def\@evenhead{\@threepart{\evenlefthead}{\evenmiddlehead}{{\sffamily Introduction}}}
  \def\@evenfoot{\@threepart{\evenleftfoot}{\evenmiddlefoot}{\evenrightfoot}}
}

\def\ps@contents{
  \def\@oddhead{\@threepart{{\sffamily Contents}}{\oddmiddlehead}{\oddrighthead}}
  \def\@oddfoot{\@threepart{\oddleftfoot}{\oddmiddlefoot}{\oddrightfoot}}
  \def\@evenhead{\@threepart{\evenlefthead}{\evenmiddlehead}{{\sffamily Contents}}}
  \def\@evenfoot{\@threepart{\evenleftfoot}{\evenmiddlefoot}{\evenrightfoot}}
}

\def\ps@commands{
  \def\@oddhead{\@threepart{{\sffamily Common Maple Commands}}{\oddmiddlehead}{\oddrighthead}}
  \def\@oddfoot{\@threepart{\oddleftfoot}{\oddmiddlefoot}{\oddrightfoot}}
  \def\@evenhead{\@threepart{\evenlefthead}{\evenmiddlehead}{{\sffamily Common Maple Commands}}}
  \def\@evenfoot{\@threepart{\evenleftfoot}{\evenmiddlefoot}{\evenrightfoot}}
}

\def\ps@index{
  \def\@oddhead{\@threepart{{\sffamily Index}}{\oddmiddlehead}{\oddrighthead}}
  \def\@oddfoot{\@threepart{\oddleftfoot}{\oddmiddlefoot}{\oddrightfoot}}
  \def\@evenhead{\@threepart{\evenlefthead}{\evenmiddlehead}{{\sffamily Index}}}
  \def\@evenfoot{\@threepart{\evenleftfoot}{\evenmiddlefoot}{\evenrightfoot}}
}

\makeatother