1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
|
%% <PRE>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright (c) 1994--2003 by Waterloo Maple Inc., all rights reserved.
%
% Permission is granted to use this package without charge. It may
% be redistributed providing that it is distributed as is
% and without charge. You may modify these macros for your own use,
% and redistribute them, subject to the following conditions.
%
% 1. The package name used for any modified version of this file is
% different from mapleutil and a file name other than mapleutil.sty
% is used.
%
% 2. You acknowledge this copyright notice and this file as the source.
%
% 3. The new file is redistributed under the same terms and conditions
% as indicated here, including a version of this notice modified to
% refer to the new file and/or package name.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Miscelaneous utilities used to define the main Maple environments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesPackage{mapleutil}[1998/09/19 -- Maple Style Utilities]
\typeout{Defining Maple Utility Macros}
%
% Utilities for changing character codes
%
\def\MakeTab#1{\catcode `#1 = 4 } % &
\def\MakeParameter#1{\catcode `#1 = 6 } % #
\def\MakeSuperScript#1{\catcode `#1 = 7 } % ^
\def\MakeSubScript#1{\catcode `#1 = 8 } % _
\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}}
%
\@ifundefined{dospecials}{%
\gdef\dospecials{\do\ \do\\\do\{\do\}\do\$\do\&\do\#\do\^\do\_\do\%\do\~}%
}{\relax}%
\@ifundefined{postdospecials}{%
\gdef\postdospecials{%
\catcode`\\\z@%
\catcode`\{\@ne%
\catcode`\}\tw@%
\catcode`\ 10%
\catcode`\&11}%
}{\relax}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 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}%
% \def\@MaplePar{\nopagebreak[3]\EveryParZ\@@par}%
%
\newif\if@IgnoreNewLine
\@IgnoreNewLinetrue
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Characters requiring special treatment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-- Spaces
\def\MapleSpace{\ }
\def\@ObeySpaces{\MakeActive{\ }\@@ObeySpaces\relax}
{\MakeActive{\ }\gdef\@@ObeySpaces{\edef {\MapleSpace}}}
%-- BackSlashes
{\catcode`| = 0 |catcode`\\ = 12 |gdef|BackSlash{\}}
%-- 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 Maple Environments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% These Macros are the common elements of the verbatim like environents.
% The spacing above and below the environment should is done in the
% environment preamble instead of here to enable this to be used in a
% variety of such environments.
% \newtoks\MapleIOType \MapleIOType = {a}
\edef\@MapleQuiet{q} % indicates a silent command or result
\edef\@MapleVerbose{a} % The standard behavior in which
% results are generated and displayed.
\edef\@MapleNoPrompt{np} % specify no prompts in environment
\edef\@MaplePrompt{p} % specify prompts for this environment
\edef\@MapleNoInput{ni} % No input appears in output stream.
\edef\@MapleNoOutput{no} % No output appears in outputstream.
% The next macro is used by the verbatim like environments to
% reset character codes, and change the treatment of new lines, etc.
% Actions can be made conditional on the value of \@MapleIOType which
% is always set to 'a' , or to 'q' as in the value of the
% optional parameter used in \begin{mapleinput}[q]
\newtoks\MapleListCorrection \MapleListCorrection={}
\def\@SetupMapleTty#1{%
\par\@endpefalse %% to clear the \@endpetrue done in \mapleinput
\begingroup %% this is the real start of the special environment.
%%% Compute and set tab positions
\setbox 0 = \hbox{\@MapleFont X}
\@MapleTabSize = \wd0
\multiply\@MapleTabSize by \MapleTab
\setbox0 = \hbox{\relax} % Clearing \box 0
%%% paragraph dimensions and line spacing
\rightskip = 0pt
\parindent = 0pt
\parskip = 0pt
\ifnum\@listdepth>0%
\MapleListCorrection={\hskip-\@totalleftmargin\relax }
\LeftMapleSkip= 0em
\else
\MapleListCorrection={\hskip 0ex\relax }
\fi
\setlength{\leftskip}{\LeftMapleSkip}
\addtolength{\leftskip}{\@totalleftmargin}
\parfillskip = 0pt plus 1fil
%
%%% The next two parameters may have been changed
%%% by a \raggedright so they are reset here.
\spaceskip = 0pt \xspaceskip = 0pt
%
%%% Set this flag to 0 if the \begin{...} is to appear on a
%%% separate line of the source file.
\ifnum #1 = 0 \@IgnoreNewLinetrue\else\@IgnoreNewLinefalse\fi%
%
%%% Describe how to handle every paragraph (recall paragraph == line )
%% \@MapleFont%
\everypar = {\EveryParZ}%
\def\EveryParZ{%
\ifMaplePrompt
\the\MapleListCorrection
\the\MaplePromptString
\MaplePromptString = \MaplePromptSecondary
\MapleListCorrection = {\hskip 0pt\relax}
\fi
\setbox0 = \hbox \bgroup
}%
%
%%% Choose the type size and font - The order of these commands
%%% may be important.
\@MapleFont%
\lineskiplimit=0\normalbaselineskip%
\baselineskip=0.85\normalbaselineskip%
\@noligs%
\let\do\@makeother\dospecials%
\catcode ``=\active%
\frenchspacing%
\@ObeySpaces%
\@ObeyTabs%
\@ObeyEol%
}
% Exit the special tty environments
\def\@EndMapleTty{%
\endgroup%% matches the \begingroup inside of @SetupMapleTty
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The following Macros start the various Verbatim like environments
% for special Maple regions. These calls set up the
% scanning for the environment terminator.
%
% A conditional parameter as in \begin{...}[q] etc. denotes a
% special class of Maple Regions.
\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
%
% type a standard (verbose) usage
% type q quiet command
% type np no prompt (imapleinput only at this time...)
% type ni no input
% type no no output
%
% -- Maple Inert Input
|gdef|@BeginIMapleInput#1\end{imapleinput}(%
|MaplePrompttrue%
#1%
|end(imapleinput))%
%
% -- Inert TTY Output
|gdef|@BeginIMapleTtyout#1\end{imaplettyout}(%
|vskip|AboveMapleSkip% extra vspace is needed here
|MaplePromptfalse
#1%
|end(imaplettyout))%
%
% -- Fixed Width
|gdef|@BeginFixedWidth#1\end{FixedWidth}(%
|vskip|AboveMapleSkip% extra vspace is needed here
|MaplePromptfalse
#1%
|end(FixedWidth))%
% -- TTY Input
|gdef|@BeginMapleInput[#1]#2\end{mapleinput}(%
|edef|@MapleIOType(#1)%
|gdef|MapleIOType(#1)%
|ifx|@MapleIOType|@MapleNoPrompt|MaplePromptfalse|fi%
|ifx|@MapleIOType|@MapleNoInput|edef|@MapleIOType(q)|fi%
|ifx|@MapleIOType|@MapleQuiet%
|typeout(.............Quiet Maple Command #1)%
|removelastskip%
|else%
%|typeout(.............Verbose Maple Command)%
#2%
|fi%
|end(mapleinput))%
%
% -- TTY Output
|gdef|@BeginMapleTtyout[#1]#2\end{maplettyout}(%
%%|typeout(TTYout Environment of type #1)%
|edef|@MapleIOType(#1)%
|gdef|MapleIOType(#1)%
|ifx|@MapleIOType|@MaplePrompt|MaplePromptfalse|fi%
|ifx|@MapleIOType|@MapleNoOutput|edef|@MapleIOType(q)|fi%
|ifx|@MapleIOType|@MapleQuiet%
|typeout(.............Quiet Maple Tty Out)%
|else%
#2%
|fi%
|end(maplettyout))%
%
% -- Suppressed Latex Output
|gdef|@GobbleMapleLatex#1\end{maplelatex}(%
|end(maplelatex))%
|endgroup
%
\@ifundefined{]}{\gdef\[{$}}{\relax}
\@ifundefined{[}{\gdef\]{$}}{\relax}
\endinput
%%% </PRE>
|