%%
% Standard Maple Environments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ProvidesPackage{mapleenv}[1998/09/19 -- Maple Environments -- mapleenv.sty ] \typeout{Defining Standard Maple Environemnts} \RequirePackage{mapleutil} \usepackage{color} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Copyright (c) 1994--1998 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 mapleenv and the file name used is different from % mapleenv.sty % % 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. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Mapleenv.sty - Environments for Export to LaTeX % % This package defines the environments used by Maple V Release 5's % "Export to Latex" facility. In addition, each of the environments % accepts an optional parameter. For example, for example, % Maple Input lines accept any of: % % \begin{mapleinput}...\end{mapleinput}, (default) % % The contents of such an environment are in terms of mapleinline. % % The "Export to LaTeX" facility of the Maple worksheet does not use any % of the optional parameters. They exist to provide the additional % control needed for reprocessing long LaTeX manuscripts and which is % carried out by a special "Maple Filter". % % Maple output can occur in several forms. Maple's "prettyprint" output, % as well as error messages and warnings, is encapsulated as % % \begin{maplettyout}...\end{maplettyout} % % "Export to Latex" generates LaTeX code for the entire worksheet. % The displayed mathematics output is controlled to fit a % user specified line width and appears inside the environment % % \begin{maplelatex}...\end{maplelatex} % % Maple generated plots are exported as postscript files. % The resulting files are included in the LaTeX document % by using the macro call % % \mapleplot{filename} % % On processing by LaTeX, the postscript code from the % indicated file is read into "dvi" file and a display is % generated at that point in the document. The plot dimensions % are specified as \MaplePlotHeight and \MaplePlotWidth. % % The actual embedding is accomplished using the LaTeX2e graphics % package. This style file has been tested with the following dvi to % PostScript conversion programs: % % dvips % dvipsone % % ---------------------------------------------- % Environments that ignored by the Maple Filter % ---------------------------------------------- % The Maple Filter is a special version of Maple that can read % and update latex files which have been developed using these % macros. There is a need, in such tex files, to display information % in the same manner as the preceding manner and yet guarantee that % the information is not changed by the Maple Filter. % The macros are identical to those describe above, but with each % name preceded by an "i". % % \begin{imapleinput}...\end{imapleinput} like mapleinput % \begin{mapleinput}[p]...\end{imapleinput} as above, default case % \begin{imaplelatex}...\end{imaplelatex} like maplelatex % \imapleplot{filename} like mapleplot % \imaplesepline like \maplesepline, but ignored by the filter. % % ---------------------------------------------- % Implementation Details % ---------------------------------------------- % The mapleinput, and maplettyout environments are similar to % \begin{verbatim}...\end{verbatim} but with several % important differences. % % - The spacing relative to the surrounding environment is different. % % - Page breaks are encouraged before commands, or after results, % and discouraged inbetween. % % - 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. Use \MapleFont % to reset the font. % % - the indentation of the environments can be indented by setting % the value of \LeftMapleSkip . % % - a prompt is automatically generated at the start of each line in % the case of the input environments. % % Much of the spacing and sizing information is parameterized. % The following Macros control most of the spacing for the the % Maple environments. They are all resettable in the preamble of % your document. % % \AboveMapleSkip - space above an environment % \BelowMapleSkip - space below an environment % \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 % \LeftMapleSkip - the amount of left indentation % \MapleFont - The Maple font % \MapleSize - The size of the Maple font in mapleinput and % maplettyout % \MapleLatexSize - The size of the Maple fonts in maplelatex % \MapleFirstLine - controls ingoring first line feed % \MaplePrompttrue - controls insertion of prompt char % \MaplePromptString - defines the prompt string % \MaplePromptSecondary - defines the secondary prompt string % \MapleSkip - amount of glue before and after % displayed text % \MapleTab - number of spaces per tab (8) % % Spacing, dimensions, etc. % % These are all defined and given default values in the file % mapleenv.def Most may be changed in your document preamble. % \input{mapleenv.def} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Define those Maple environments that are to be ignored by % the Maple Filter. % % \begin{imapleinput} ...\end{imapleinput} % \begin{imaplettyout} ...\end{imaplettyout} % \begin{imaplelatex} ...\end{imaplelatex} % \imaplesepline % \imapleplot % % These environments are ignored by the Maple Filter. % % -- imapleinput % \def\imapleinput{ \removelastskip% \MaplePrompttrue% prompt is required in this environment. \if@minipage\removelastskip\vskip-1.3ex% \else\vskip\AboveMapleSkip\fi% \@SetupMapleTty{0}% The 0 indicates ignore first new line \@BeginIMapleInput% } % \def\endimapleinput{% \@EndMapleTty% \removelastskip% \edef\@MapleIOType{\MapleIOType} \ifx\@MapleIOType\@MapleQuiet% \typeout{ .............Quiet Maple Command finished} \else \vskip\BelowMapleSkip% not usually followed by output... \fi% \@endpetrue \ignorespaces } % % -- imaplettyout % \def\imaplettyout{ \removelastskip% \nopagebreak[3]% \MaplePromptfalse % No prompt is required in this environment. \@SetupMapleTty{1} % The 1 indicates "respect first new line" \@BeginIMapleTtyout % np indicates omit prompt } % \def\endimaplettyout{% \@EndMapleTty% \removelastskip \vskip\BelowMapleSkip% \pagebreak[3]% \@endpetrue \ignorespaces }% % % -- imaplelatex % % an inert maple latex environment (ignored by the filter) % \newenvironment{imaplelatex}% {\vskip.5\AboveMapleSkip\vskip\z@\begin{maplelatex}}{\end{maplelatex}}% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Define active mapleinput environments. % % \begin{mapleinput} ...\end{mapleinput} % \begin{maplettyout} ...\end{maplettyout} % \begin{maplelatex} ...\end{maplelatex} % % These parameterized environments are intended for reprocessing % by the Maple Filter. % % The [a] case is used by default. % The [q] is the quiet (suppressed) mode. % The [ni] (no input) behaves the same as [q] % The [no] behaves the same as [a] % % 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. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % -- mapleinput % \newlength\newleftskip% \newbox\mapleinputbox% \newenvironment{mapleinput}{% %\def\@gobblefirst##1{\relax\egroup\par} %\def\@gobblesecond##1##2{##1\egroup\par} \def\@gobblesemicolons##1{##1} \advance\hsize by -\LeftMapleSkip% \global\setbox\mapleinputbox=\vbox\bgroup% \everypar{\the\MaplePromptString\MaplePromptString=\MaplePromptSecondary\ } \leftskip=\z@% \parindent=\z@% \parfillskip=0pt plus 1fil \lineskiplimit=0\normalbaselineskip \baselineskip=.85\normalbaselineskip }{% \egroup% end of vbox \par\removelastskip \vskip\AboveMapleSkip% \newleftskip=\leftskip% \advance\newleftskip by \LeftMapleSkip% \advance\newleftskip by \@totalleftmargin% needed for lists \hbox{\hskip\newleftskip\box\mapleinputbox} \vskip\BelowMapleSkip} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -- maplettyout % \def\maplettyout{ \removelastskip% \vskip 0pt plus 0pt minus 3pt% \nopagebreak[3]% \MaplePromptfalse % No prompt is required in this environment. \@SetupMapleTty{1} % The 1 indicates "respect first new line" \@ifnextchar [{\@BeginMapleTtyout}{\@BeginMapleTtyout[a]}% } % \def\endmaplettyout{% \@EndMapleTty% \edef\@MapleIOType{\MapleIOType} \ifx\@MapleIOType\@MapleQuiet% \typeout{ .............Quiet Maple TTY finished} \else \vskip\BelowMapleSkip% \pagebreak[3]% \@endpetrue \ignorespaces \fi } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % -- maplelatex % % This is essentially a wrapper around a display math environment % It gobbles its content if the [q] or [no] options are in % effect. % \newbox\maplebox \def\maplelatex{\@ifnextchar [{\@maplelatex}{\@maplelatex[a]}} % \def\@maplelatex[#1]{% \edef\@MapleIOType{#1}% \gdef\MapleIOType{#1}%% for \ifx test% \ifx\@MapleIOType\@MapleNoOutput% \typeout{ .............Output Option [no]}% \gdef\MapleIOType{q}%% handle same as \@MapleQuiet \fi% \global\setbox\maplebox=\vbox\bgroup% \MakeSuperScript{^}% Ensure these have normal interpretation \MakeSubScript{_}% }% % \def\endmaplelatex{\egroup% \edef\@MapleIOType{\MapleIOType}% \ifx\@MapleIOType\@MapleQuiet% End the same as the verbatim's \par% %\@endpetrue \else% %\ifvmode\removelastskip\fi% \nopagebreak[3]% \centerline{% \vbox{% \hbox{\vrule height4pt depth0pt width 0pt}% \unvbox\maplebox}}% \vskip\BelowMapleSkip% \everypar{}% \par% %\pagebreak[3]% %\@endpetrue %\ignorespaces \fi% }% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % -- maplesepline % \newcommand{\maplesepline}{\vskip \parskip% \hrule\@height\MapleSepLineHeight\@width\MapleSepLineWidth% \vskip \parskip\relax} % % -- imaplesepline ( the inert form ) % \let\imaplesepline\maplesepline %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % -- \mapleIndent % % - Special Indentation Macro used to format procedures % \newdimen\Tab \Tab=3ex \def\mapleIndent#1{\hbox{\hskip#1\Tab\relax}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Special environments for in-line maple commands. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % \begin{maplegroup} - maple exchange group % ... % ... and \mexpr{sin(x^2)} ... - inline maple code % ... % \mapleinline{Inert}{TwoD}{int(sin(x^2),x);}{% - for maple filter % {mapletex}{$\int{ .... }$} - for latex % ... % ... % \mapleresult - location of inline results % \begin{maplelatex} - actual displayed results % ... % \end{maplelatex} % \end{maplegroup} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % -- \mexpr % % \mexpr{int(sin(x^2),x)} --- \mapleexpr{int(sin(x^2),x)} % % To make { and } visible in this verbatim environment, use \{ and \} % Also, to make \ visible, use \\. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \def\mexpr{\setbox\@inlinebox=\hbox\bgroup\ttfamily\dosetup\let\\\BackSlash\@domexpr} % \def\mapleexpr{\bgroup\ttfamily\dosetup\let\\\BackSlash\@domexpr} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % \@dosetup sets up the character codes, etc. for verbatim % \@domexpr completes the following inline math % \@gobblefirst absorbs the inline math (not displaying it) % \@gobblesecond absorbs the second following argument. % \@gobblesemicolons absorbs semi-colons inside of the 1d mode. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\dosetup{\let\do\@makeother\dospecials\postdospecials} % %\def\@domexpr#1{#1\egroup\fbox{\box\@inlinebox}} \def\@domexpr#1{#1\egroup\box\@inlinebox} % \def\@gobblefirst#1{% \relax\egroup% % \fbox{\box\@inlinebox}% %%% DEBUG %%% \box\@inlinebox% \setbox\@inlinebox=\hbox{}} % \def\@gobblesecond#1#2{% #1\egroup\ignorespaces% % \fbox{\box\@inlinebox}% %%% DEBUG %%% \box\@inlinebox% \setbox\@inlinebox=\hbox{}} % \def\@gobblesemicolons{\MakeActive{;}\@@gobblesemicolons} % {\MakeActive{;}\gdef\@@gobblesemicolons{\edef;{\relax}}} %%% end of mexpr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % -- \mapleinline % % Essentially a four argument macro used to control the % display of inline material generated by Maple. % % \mapleinline % %% "active", or "inert" % % 1d or 2d % % raw maple code as per \mexpr % % latex representation % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % \mapleinline{inert}{2d}{int(sin(x^2),x)}{ % used to generate display % $\int{\sin(x^2),dx}$} % updated by the filter % % Could use \@bsphack ... \@esphack for absorbing unwanted space not % currently used, but spacing inside this macro definition is % very important. % \edef\OneD{1d}\edef\TwoD{2d}% # tokens to identify modes \newif\ifDisplay\Displayfalse \newbox\@inlinebox\setbox\@inlinebox=\hbox{}% \@ifundefined{@skiponetoken}{\gdef\@skiponetoken#1{\relax}}{\relax}% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 2-D output % final output macro for mapleinline. % include spacing above and below to ensure there is % whitespace around the object when it occurs in % a spreadsheet cell. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\@doTwoD#1{\egroup% %\@ifnextchar\cr{\@skiponetoken}{\relax}% \@@doTwoD}% % \newdimen\cellwidth% \def\@@doTwoD#1{% \ignorespaces% \setbox\@inlinebox=\hbox{\textcolor{blue}{#1}}% %\setbox\@inlinebox=\hbox{#1}% \ifMapleTableCell% Used in maplespreadsheet \cellwidth=\wd\@inlinebox% \hbox{$\vcenter{\hsize=\cellwidth% \hbox{\vrule height3pt depth0pt width 0pt}% \box\@inlinebox% \hbox{\vrule height0pt depth 3pt width 0pt}% Actual output }$}% \egroup% \else% Used inline ... %\fbox{\hbox{\unhbox\@inlinebox}}\egroup% Actual output \box\@inlinebox\egroup% \fi% } % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 1-D output % Final output macro for mapleinline for 1-D output. % The raw tokens must be dumped into the output stream so % we use unhbox. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\@doOneD#1{\MakeOther{\ } \textcolor{red}{#1}\egroup\unvbox\@inlinebox\relax\@mgobbleone} %\def\@doOneD#1{\MakeOther{\ } #1\egroup\unvbox\@inlinebox\relax\@mgobbleone} \def\@mgobbleone#1{\relax\egroup} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\mapleinline#1#2{% % ignore first argument (inert or active) \def\[{$}\def\]{$}% % needed for math mode. \edef\DisplayType{#2}% % 1d or 2d \ifx\DisplayType\TwoD% \let\Display\@doTwoD% % display the 2-D representation \global\Displaytrue% \else% \let\Display\@doOneD% % display the 1-D representation \global\Displayfalse% \fi% \bgroup% \global\setbox\@inlinebox=\vbox\bgroup% \obeylines% \everypar{\the\MaplePromptString\MaplePromptString=\MaplePromptSecondary\ } \ttfamily\dosetup\obeyspaces\let\\\BackSlash\Display% }% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % -- \begin{maplegroup} ... \end{maplegroup} % -- \mapleresult % % A environment used to group commands and result together into % one unit. Inside, these are separated by \mapleresult. % The maple filter automatically deletes the part of a maplegroup % which follows \mapleresult and replaces it with new results. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\newenvironment{maplegroup}{}{} \def\maplegroup{\relax} \def\endmaplegroup{\relax} \let\mapleresult\relax \endinput %%% mapleenv.sty %%%