|
From: Jay B. <bel...@us...> - 2001-11-08 22:22:11
|
Update of /cvsroot/maxima/maxima-pre59/emacs
In directory usw-pr-cvs1:/tmp/cvs-serv10524
Added Files:
emaxima.sty
Log Message:
Initial commit of EMaxima style file (for LaTeX).
--- NEW FILE: emaxima.sty ---
%% Macros needed for EMaxima.
%% Jay Belanger (bel...@tr...)
%%
%% Some of this was taken from Dan Dill's TeX/MMA (in modified
%% form, of course), and some was taken from other sources. Some
%% I may even have written myself.
%% A macro for writing Maxima in the ``proper'' font -- added by WMS
\def\Maxima{{\sffamily\slshape Maxima\/}}
\def\maximaheadersize{\tiny}
%% An if to allow the lines to be turned on and off
\newif\ifmaximalines
\maximalinestrue
%% Let's use some local macros
\catcode`\@=11\relax
\newdimen\maximainputbaselineskip
\newdimen\maximaoutputbaselineskip
\newdimen\premaximaspace
\newdimen\postmaximaspace
%% Here are the values that the user may wish to change.
%% They can be changed here or in the main TeX file.
\font\maximainputfont = cmtt10
\maximainputbaselineskip = 10pt
\font\maximaoutputfont = cmtt10
\maximaoutputbaselineskip = 14pt
\premaximaspace = 0pt
\postmaximaspace = 1.5ex
%% First of all, set up some delimiters
%% The units are in terms of em and ex, so if the font size is
%% changed, the units will be changed accordingly
%% To make things line up, we'll need the size of "Initial"
\font\m@ximaheaderfont=cmtt8 scaled 800
\setbox0=\hbox{\m@ximaheaderfont\ Initial}
\newdimen\in@t
\in@t = \wd0
\advance\in@t by 1em
\def\sm@llsk{\vskip 1ex}
\def\m@ximatop{
\vskip -1ex
\hbox to \hsize{\vrule depth 1ex height .3pt width .4pt
\vrule height .4pt depth 0pt width 1.1em
\lower .4ex \hbox{\maximaheadersize\ \Maxima}
\hrulefill
\vrule depth 1ex height .3pt width .4pt}
\vskip 1ex}
\def\m@ximainittop{
\vskip -1ex
\hbox to \hsize{\vrule depth 1ex height .3pt width .4pt
\vrule height .4pt depth 0pt width 1.1em
\lower .4ex \hbox{\maximaheadersize\ \Maxima}
\hrulefill
\lower .4ex \hbox{\m@ximaheaderfont\ Initial}
\vrule height .4pt depth 0pt width 1em
\vrule depth 1ex height .3pt width .4pt}
\vskip 1ex}
\def\m@ximaparttop#1{
\vskip -1ex
\hbox to \hsize{\vrule depth 1ex height .3pt width .4pt
\vrule height .4pt depth 0pt width 1.1em
\lower .4ex \hbox{\maximaheadersize\ \Maxima}
\hrulefill
\lower .4ex \hbox{\m@ximaheaderfont\ #1}
\hrulefill
\vrule height .4pt depth 0pt width \in@t
\vrule depth 1ex height .3pt width .4pt}
\vskip 1ex}
\def\m@ximainitparttop#1{
\vskip -1ex
\hbox to \hsize{\vrule depth 1ex height .3pt width .4pt
\vrule height .4pt depth 0pt width 1.1em
\lower .4ex \hbox{\maximaheadersize\ \Maxima}
\hrulefill
\lower .4ex \hbox{\m@ximaheaderfont\ #1}
\hrulefill
\lower .4ex \hbox{\m@ximaheaderfont\ Initial}
\vrule height .4pt depth 0pt width 1em
\vrule depth 1ex height .3pt width .4pt}
\vskip 1ex}
\def\m@ximaoutput{
\vskip -1ex
\hbox to \hsize{\hskip 1.5em
\vrule height .4pt depth 0pt width 3em
\lower .4ex \hbox{\m@ximaheaderfont\ Output}
\hrulefill
\hskip 1.5em
}
\vskip 1ex
}
\def\m@ximatexoutput{
\vskip -1ex
\hbox to \hsize{\hskip 1.5em
\vrule height .4pt depth 0pt width 3em
\lower .4ex \hbox{\m@ximaheaderfont\ \TeX\ Output}
\hrulefill
\hskip 1.5em
}
\vskip 1ex
}
\def\m@ximagraphicsoutput{
\vskip -1ex
\hbox to \hsize{\hskip 1.5em
\vrule height .4pt depth 0pt width 3em
\lower .4ex \hbox{\m@ximaheaderfont\ Graphics}
\hrulefill
\hskip 1.5em
}
\vskip 1ex
}
\def\m@ximabottom{
\hbox to \hsize{\vrule depth 0ex height 1ex width .4pt
\hrulefill
\vrule depth 0ex height 1ex width .4pt}
}
%% Next, it is necessary to have a verbatim environment for the Maxima
%% input and output
%% The verbatim environment for the input is based mostly on the
%% environment from "TeX for the Impatient" and Tim Morgan's verbtim2.tex
\def\deactivate{%
\catcode`\{ = 12
\catcode`\} = 12
\catcode`\$ = 12
\catcode`\& = 12
\catcode`\# = 12
\catcode`\% = 12
\catcode`\~ = 12
\catcode`\^ = 12
\catcode`\_ = 12
\catcode`\ = 12
}
{\catcode`\^^M=13
{\catcode`\ =13\gdef\verbatimdefs{\def^^M{\ \par}\let =\ }}
\gdef\verbatimgobble#1^^M{}}
\def\m@ximainputverbatim{
\begingroup
\setlength{\parskip}{0pt} %% added by WMS
\par
\maximainputfont
\deactivate
\verbatimdefs
\catcode`\ =13
\catcode`\^^M=13
}
\let\endm@ximainputverbatim=\endgroup
%% The verbatim for Maxima output is taken from the TeXbook.
%% It allows more symbols, but can't be used for the input
%% since the input can be ended with more than one delimiter.
\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
\chardef\active=13
\def\obeyspaces{\catcode`\ =\active}
{\catcode`\^^M=\active %
\gdef\obeylines{\catcode`\^^M=\active \let^^M=\par}%
\global\let^^M=\par} %
\def\setupm@ximaverbatim{\maximaoutputfont
\obeylines \uncatcodespecials \obeyspaces}
{\obeyspaces\global\let =\ }
\def\m@ximaoutputverbatim{\par\begingroup
\baselineskip = \maximaoutputbaselineskip
\setupm@ximaverbatim\dom@ximaverbatim}
{\catcode`\|=0 \catcode`\\=12 %
|obeylines|gdef|dom@ximaverbatim^^M#1\endmaxima{#1|endgroup|ifmaximalines|m@ximabottom|fi|par|vskip 1.5ex|par|endgroup}}
%% Now we need to set up the actual environments.
%% We will need some "if"s to tell us where we are
\newif\ifm@ximainput
\newif\ifm@ximaoutput
\newif\ifm@ximatexoutput
\newif\ifm@ximagraphics
\def\not@k{}
%% The top delimiter depends on whether or not it is an initial cell,
%% etc.
\def\maxima{
\begingroup
\par \vskip \premaximaspace \par
\baselineskip = \maximainputbaselineskip
\m@ximainputtrue
\futurelet\nextchar\m@xima
}
\def\m@xima{
\ifx\nextchar [%
\let\next = \m@ximainit
\else
\ifx\nextchar <%
\let\next = \m@ximapart
\else
\let\next = \m@ximastart
\fi
\fi
\next
}
\def\m@ximainit[#1]{
\futurelet\nextchar%
\m@xima@nit}
\def\m@xima@nit{
\ifx\nextchar <%
\let\next = \m@ximainitpart
\else
\let\next = \m@ximainitonly
\fi
\next
}
\def\m@ximainitonly{
\par
\vskip 1.5ex
\par
\ifmaximalines\m@ximainittop\fi
\sm@llsk
\m@ximainputverbatim
}
\def\m@ximastart{
\par
\vskip 1.5ex
\par
\ifmaximalines\m@ximatop\fi
\sm@llsk
\m@ximainputverbatim
}
\def\m@ximapart<#1:#2>{
\par
\vskip 1.5ex
\par
\def\testt@k{#2}
\ifx\testt@k\not@k
\def\m@ximaparttext{Definition of package #1}
\else
\def\m@ximaparttext{<#1:#2>}
\fi
\ifmaximalines\m@ximaparttop\m@ximaparttext\fi
\futurelet\nextchar\m@ximap@rt
}
\def\m@ximap@rt{
\sm@llsk
\m@ximainputverbatim
}
\def\m@ximainitpart<#1:#2>{
\par
\vskip 1.5ex
\par
\def\testt@k{#2}
\ifx\testt@k\not@k
\def\m@ximaparttext{Definition of package #1}
\else
\def\m@ximaparttext{<#1:#2>}
\fi
\ifmaximalines\m@ximainitparttop\m@ximaparttext\fi
\futurelet\nextchar\m@ximap@rt
}
%% Now to take care of the various types of output
\def\output{
\endm@ximainputverbatim
\sm@llsk
\m@ximainputfalse
\m@ximaoutputtrue
\ifmaximalines\m@ximaoutput\fi
% \sm@llsk
\m@ximaoutputverbatim
}
\def\outputtex{
\endm@ximainputverbatim
\sm@llsk
\m@ximainputfalse
\m@ximatexoutputtrue
\ifmaximalines\m@ximatexoutput\fi
\sm@llsk
\begingroup
% \def\par{}
% $$
}
\def\@ndtexoutput{
% $$
\endgroup
\m@ximatexoutputfalse
\par
}
%% If the output is graphics, we'll need to load epsf.tex, but there's
%% no need to load it if there are no graphics, and there is no need
%% to load it more than once.
\newif\ifnogr@phics
\nogr@phicstrue
\def\outputgraphics{
\endm@ximainputverbatim
\sm@llsk
\m@ximainputfalse
\m@ximagraphicstrue
\ifnogr@phics
\input epsf.tex
\nogr@phicsfalse
\fi
\ifmaximalines\m@ximagraphicsoutput\fi
\sm@llsk
}
\def\@ndoutputgraphics{}
%% We'll need to have a macro for the graphics
\def\mgraphics#1#2{
\centerline{ \epsfxsize = #1 \epsfbox{#2}}
}
\def\endmaxima{
\ifm@ximainput
\endm@ximainputverbatim
\m@ximainputfalse
\else
\ifm@ximatexoutput
\@ndtexoutput
\else
\ifm@ximagraphics
\@ndoutputgraphics
\fi
\fi
\fi
\sm@llsk
\ifmaximalines\m@ximabottom\fi
\par
\vskip \postmaximaspace
\par
\endgroup
}
% Finally, to help with backslashes,
\def\bs{$\backslash$}
\catcode`\@=12\relax
\endinput
|