~ubuntu-branches/ubuntu/oneiric/yacas/oneiric

« back to all changes in this revision

Viewing changes to YacasNotebook/yacas-notebook.sty

  • Committer: Bazaar Package Importer
  • Author(s): Gopal Narayanan
  • Date: 2002-04-23 13:50:51 UTC
  • Revision ID: james.westby@ubuntu.com-20020423135051-bbd6ov4orr8eufmw
Tags: upstream-1.0.51
ImportĀ upstreamĀ versionĀ 1.0.51

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%% Macros needed for EYacas.
 
2
%% Jay Belanger (belanger@truman.edu)
 
3
 
 
4
%% Some of this was taken from Dan Dill's TeX/MMA (in modified
 
5
%% form, of course), and some was taken from other sources.  Some
 
6
%% I may even have written myself.
 
7
 
 
8
\def\Yacas{{\sffamily yacas\/}}
 
9
\def\yacasheadersize{\tiny}
 
10
 
 
11
%% Let's use some local macros
 
12
 
 
13
\catcode`\@=11\relax
 
14
\newdimen\yacasinputbaselineskip
 
15
\newdimen\yacasoutputbaselineskip
 
16
\newdimen\preyacasspace
 
17
 
 
18
%% Here are the values that the user may wish to change.
 
19
%% They can be changed here or in the main TeX file.
 
20
 
 
21
\font\yacasinputfont = cmtt10
 
22
\yacasinputbaselineskip = 10pt
 
23
 
 
24
\font\yacasoutputfont = cmtt10
 
25
\yacasoutputbaselineskip = 14pt
 
26
 
 
27
\preyacasspace = 0pt
 
28
 
 
29
%% First of all, set up some delimiters
 
30
%% The units are in terms of em and ex, so if the font size is
 
31
%% changed, the units will be changed accordingly
 
32
 
 
33
%% To make things line up, we'll need the size of "Initial"
 
34
 
 
35
\font\yac@sheaderfont=cmtt8  scaled 800
 
36
\setbox0=\hbox{\yac@sheaderfont\ Initial}
 
37
\newdimen\in@t
 
38
\in@t = \wd0
 
39
\advance\in@t by 1em
 
40
 
 
41
\def\sm@llsk{\vskip 1ex}
 
42
 
 
43
\def\yac@stop{
 
44
\vskip -1ex
 
45
\hbox to \hsize{\vrule depth 1ex  height .3pt width .4pt
 
46
                \vrule height .4pt depth 0pt width 1.1em 
 
47
                \lower .4ex \hbox{\yacasheadersize\ \Yacas} 
 
48
                \hrulefill 
 
49
                \vrule depth 1ex height .3pt width .4pt}
 
50
\vskip 1ex}
 
51
 
 
52
 
 
53
\def\yac@sinittop{
 
54
\vskip -1ex
 
55
\hbox to \hsize{\vrule depth 1ex  height .3pt width .4pt
 
56
                \vrule height .4pt depth 0pt width 1.1em 
 
57
                \lower .4ex \hbox{\yacasheadersize\ \Yacas} 
 
58
                \hrulefill
 
59
                \lower .4ex \hbox{\yac@sheaderfont\ Initial}
 
60
                \vrule height .4pt depth 0pt width 1em 
 
61
                \vrule depth 1ex height .3pt width .4pt}
 
62
\vskip 1ex}
 
63
 
 
64
\def\yac@sparttop#1{
 
65
\vskip -1ex
 
66
\hbox to \hsize{\vrule depth 1ex  height .3pt width .4pt
 
67
                \vrule height .4pt depth 0pt width 1.1em 
 
68
                \lower .4ex \hbox{\yacasheadersize\ \Yacas} 
 
69
                \hrulefill
 
70
                \lower .4ex \hbox{\yac@sheaderfont\ #1}
 
71
                \hrulefill
 
72
                \vrule height .4pt depth 0pt width \in@t
 
73
                \vrule depth 1ex height .3pt width .4pt}
 
74
\vskip 1ex}
 
75
 
 
76
\def\yac@sinitparttop#1{
 
77
\vskip -1ex
 
78
\hbox to \hsize{\vrule depth 1ex  height .3pt width .4pt
 
79
                \vrule height .4pt depth 0pt width 1.1em 
 
80
                \lower .4ex \hbox{\yacasheadersize\ \Yacas} 
 
81
                \hrulefill
 
82
                \lower .4ex \hbox{\yac@sheaderfont\ #1}
 
83
                \hrulefill
 
84
                \lower .4ex \hbox{\yac@sheaderfont\ Initial}
 
85
                \vrule height .4pt depth 0pt width 1em
 
86
                \vrule depth 1ex height .3pt width .4pt}
 
87
\vskip 1ex}
 
88
 
 
89
 
 
90
\def\yac@soutput{
 
91
        \vskip -1ex
 
92
        \hbox to \hsize{\hskip 1.5em
 
93
                        \vrule height .4pt depth 0pt width 3em
 
94
                        \lower .4ex \hbox{\yac@sheaderfont\ Output}
 
95
                        \hrulefill
 
96
                        \hskip 1.5em
 
97
                        }
 
98
        \vskip 1ex
 
99
}
 
100
 
 
101
\def\yac@stexoutput{
 
102
        \vskip -1ex
 
103
        \hbox to \hsize{\hskip 1.5em
 
104
                        \vrule height .4pt depth 0pt width 3em
 
105
                        \lower .4ex \hbox{\yac@sheaderfont\ \TeX\ Output}
 
106
                        \hrulefill
 
107
                        \hskip 1.5em
 
108
                        }
 
109
        \vskip 1ex
 
110
}
 
111
 
 
112
\def\yac@sgraphicsoutput{
 
113
        \vskip -1ex
 
114
        \hbox to \hsize{\hskip 1.5em
 
115
                        \vrule height .4pt depth 0pt width 3em
 
116
                        \lower .4ex \hbox{\yac@sheaderfont\ Graphics}
 
117
                        \hrulefill
 
118
                        \hskip 1.5em
 
119
                        }
 
120
        \vskip 1ex
 
121
}
 
122
 
 
123
\def\yac@sbottom{
 
124
\hbox to \hsize{\vrule depth 0ex height 1ex width .4pt
 
125
                \hrulefill 
 
126
                \vrule depth 0ex height 1ex width .4pt}
 
127
}
 
128
 
 
129
 
 
130
%% Next, it is necessary to have a verbatim environment for the Yacas
 
131
%% input and output
 
132
 
 
133
%% The verbatim environment for the input  is based mostly on the 
 
134
%% environment from "TeX for the Impatient" and Tim Morgan's verbtim2.tex
 
135
 
 
136
\def\deactivate{%
 
137
        \catcode`\{ = 12
 
138
        \catcode`\} = 12
 
139
        \catcode`\$ = 12
 
140
        \catcode`\& = 12
 
141
        \catcode`\# = 12
 
142
        \catcode`\% = 12
 
143
        \catcode`\~ = 12
 
144
        \catcode`\^ = 12
 
145
        \catcode`\_ = 12
 
146
        \catcode`\  = 12
 
147
}
 
148
 
 
149
{\catcode`\^^M=13
 
150
 {\catcode`\ =13\gdef\verbatimdefs{\def^^M{\ \par}\let =\ }}
 
151
 \gdef\verbatimgobble#1^^M{}}
 
152
 
 
153
\def\yac@sinputverbatim{
 
154
        \begingroup 
 
155
        \setlength{\parskip}{0pt}                     %% added by WMS
 
156
        \everypar{In> }
 
157
        \par
 
158
        \yacasinputfont
 
159
        \deactivate
 
160
        \verbatimdefs
 
161
        \catcode`\ =13 
 
162
        \catcode`\^^M=13
 
163
}
 
164
 
 
165
\let\endyac@sinputverbatim=\endgroup
 
166
 
 
167
%% The verbatim for Yacas output is taken from the TeXbook.  
 
168
%% It allows more symbols, but can't be used for the input
 
169
%% since the input can be ended with more than one delimiter.
 
170
 
 
171
\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
 
172
 
 
173
\chardef\active=13
 
174
\def\obeyspaces{\catcode`\ =\active}
 
175
{\catcode`\^^M=\active %
 
176
 \gdef\obeylines{\catcode`\^^M=\active \let^^M=\par}%
 
177
 \global\let^^M=\par} %
 
178
 
 
179
 
 
180
\def\setupyac@sverbatim{\yacasoutputfont
 
181
\obeylines \uncatcodespecials \obeyspaces}
 
182
{\obeyspaces\global\let =\ }
 
183
 
 
184
 
 
185
\def\yac@soutputverbatim{\par\begingroup
 
186
        \baselineskip = \yacasoutputbaselineskip
 
187
        \setupyac@sverbatim\doyac@sverbatim}      
 
188
{\catcode`\|=0 \catcode`\\=12 %
 
189
 |obeylines|gdef|doyac@sverbatim^^M#1\endyacas{#1|endgroup|yac@sbottom|par|vskip 1.5ex|par|endgroup}}
 
190
 
 
191
%% Now we need to set up the actual environments.
 
192
%% We will need some "if"s to tell us where we are
 
193
 
 
194
\newif\ifyac@sinput
 
195
\newif\ifyac@soutput
 
196
\newif\ifyac@stexoutput
 
197
\newif\ifyac@sgraphics
 
198
 
 
199
\def\not@k{}
 
200
 
 
201
%% The top delimiter depends on whether or not it is an initial cell,
 
202
%% etc.
 
203
 
 
204
\def\yacas{
 
205
     \begingroup
 
206
     \par  \vskip \preyacasspace \par
 
207
     \baselineskip = \yacasinputbaselineskip
 
208
     \yac@sinputtrue
 
209
     \futurelet\nextchar\yac@s
 
210
}
 
211
 
 
212
\def\yac@s{
 
213
     \ifx\nextchar [%
 
214
         \let\next = \yac@sinit
 
215
     \else
 
216
         \ifx\nextchar <%
 
217
              \let\next = \yac@spart
 
218
         \else
 
219
               \let\next = \yac@sstart
 
220
         \fi
 
221
     \fi
 
222
     \next
 
223
}
 
224
 
 
225
\def\yac@sinit[#1]{
 
226
     \futurelet\nextchar%
 
227
     \yac@s@nit}
 
228
 
 
229
\def\yac@s@nit{
 
230
     \ifx\nextchar <%
 
231
          \let\next = \yac@sinitpart
 
232
     \else
 
233
          \let\next = \yac@sinitonly
 
234
     \fi
 
235
     \next
 
236
}
 
237
 
 
238
 
 
239
\def\yac@sinitonly{
 
240
     \par
 
241
     \vskip 1.5ex
 
242
     \par
 
243
     \yac@sinittop
 
244
     \sm@llsk
 
245
     \yac@sinputverbatim
 
246
}
 
247
 
 
248
 
 
249
\def\yac@sstart{
 
250
     \par
 
251
     \vskip 1.5ex
 
252
     \par
 
253
     \yac@stop
 
254
     \sm@llsk
 
255
     \yac@sinputverbatim
 
256
}
 
257
 
 
258
 
 
259
\def\yac@spart<#1:#2>{
 
260
     \par
 
261
     \vskip 1.5ex
 
262
     \par
 
263
     \def\testt@k{#2}
 
264
     \ifx\testt@k\not@k
 
265
         \def\yac@sparttext{Definition of package #1}
 
266
     \else
 
267
         \def\yac@sparttext{<#1:#2>}
 
268
     \fi
 
269
     \yac@sparttop\yac@sparttext
 
270
     \futurelet\nextchar\yac@sp@rt
 
271
}
 
272
 
 
273
\def\yac@sp@rt{
 
274
     \sm@llsk
 
275
     \yac@sinputverbatim
 
276
}
 
277
 
 
278
 
 
279
\def\yac@sinitpart<#1:#2>{
 
280
     \par
 
281
     \vskip 1.5ex
 
282
     \par
 
283
     \def\testt@k{#2}
 
284
     \ifx\testt@k\not@k
 
285
         \def\yac@sparttext{Definition of package #1}
 
286
     \else
 
287
         \def\yac@sparttext{<#1:#2>}
 
288
     \fi
 
289
     \yac@sinitparttop\yac@sparttext
 
290
     \futurelet\nextchar\yac@sp@rt
 
291
}
 
292
 
 
293
 
 
294
%% Now to take care of the various types of output
 
295
 
 
296
\def\output{
 
297
     \endyac@sinputverbatim
 
298
     \sm@llsk
 
299
     \yac@sinputfalse
 
300
     \yac@soutputtrue
 
301
     \yac@soutput
 
302
%     \sm@llsk
 
303
     \yac@soutputverbatim
 
304
}      
 
305
 
 
306
\def\outputtex{
 
307
     \endyac@sinputverbatim
 
308
     \sm@llsk
 
309
     \yac@sinputfalse
 
310
     \yac@stexoutputtrue
 
311
     \yac@stexoutput
 
312
     \sm@llsk
 
313
     \begingroup
 
314
     \def\par{}
 
315
     $$
 
316
}      
 
317
 
 
318
\def\@ndtexoutput{
 
319
    $$
 
320
    \endgroup
 
321
    \yac@stexoutputfalse
 
322
    \par
 
323
}
 
324
 
 
325
%% If the output is graphics, we'll need to load epsf.tex, but there's
 
326
%% no need to load it if there are no graphics, and there is no need
 
327
%% to load it more than once.
 
328
 
 
329
\newif\ifnogr@phics
 
330
\nogr@phicstrue
 
331
\def\outputgraphics{
 
332
    \endyac@sinputverbatim
 
333
    \sm@llsk
 
334
    \yac@sinputfalse
 
335
    \yac@sgraphicstrue
 
336
    \ifnogr@phics
 
337
        \input epsf.tex
 
338
        \nogr@phicsfalse
 
339
    \fi
 
340
    \yac@sgraphicsoutput    
 
341
    \sm@llsk
 
342
}
 
343
 
 
344
\def\@ndoutputgraphics{}
 
345
 
 
346
%% We'll need to have a macro for the graphics
 
347
 
 
348
\def\mgraphics#1#2{
 
349
    \centerline{ \epsfxsize = #1 \epsfbox{#2}}
 
350
}
 
351
 
 
352
 
 
353
\def\endyacas{
 
354
     \ifyac@sinput 
 
355
         \endyac@sinputverbatim
 
356
         \yac@sinputfalse
 
357
      \else
 
358
         \ifyac@stexoutput
 
359
             \@ndtexoutput
 
360
         \else
 
361
            \ifyac@sgraphics
 
362
                \@ndoutputgraphics
 
363
            \fi
 
364
         \fi
 
365
     \fi
 
366
     \sm@llsk
 
367
     \yac@sbottom
 
368
     \par
 
369
     \vskip 1.5 ex
 
370
     \par
 
371
     \endgroup
 
372
}
 
373
 
 
374
% Finally, to help with backslashes,
 
375
\def\bs{$\backslash$}
 
376
 
 
377
\catcode`\@=12\relax
 
378
 
 
379
 
 
380
 
 
381
 
 
382
 
 
383