source: git/Singular/LIB/latex.lib @ 8942a5

spielwiese
Last change on this file since 8942a5 was 8942a5, checked in by Gert-Martin Greuel <greuel@…>, 23 years ago
* GMG: Kosmetik git-svn-id: file:///usr/local/Singular/svn/trunk@4982 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 81.5 KB
RevLine 
[ae4196]1///////////////////////////////////////////////////////////////////////////////
[8942a5]2version="$Id: latex.lib,v 1.13 2000-12-22 14:11:33 greuel Exp $";
[fd3fb7]3category="Visualization";
[651b46]4info="
[8942a5]5LIBRARY: latex.lib    Typesetting of Singular-Objects in LaTex2e
[f34c37c]6AUTHOR: Christian Gorzel, gorzelc@math.uni-muenster.de
7
8PROCEDURES:
[ae4196]9 closetex(fnm);       writes closing line for TeX-document
10 opentex(fnm);        writes header for TeX-file fnm
11 tex(fnm);            calls LaTeX2e for TeX-file fnm
12 texdemo([n]);        produces a file explaining the features of this lib
13 texfactorize(fnm,f); creates string in TeX-Symbolformat for factors of poly f
14 texmap(fnm,m,r1,r2); creates string in TeX-Symbolformat for map m:r1->r2
15 texname(fnm,s);      creates string in TeX-Symbolformat for identifier
16 texobj(l);           creates string in TeX-Symbolformat for any (basic) type
17 texpoly(f,n[,l]);    creates string in TeX-Symbolformat for poly
18 texproc(fnm,p);      creates string in TeX-Symbolformat of text from proc p
19 texring(fnm,r[,l]);  creates string in TeX-Symbolformat for ring/qring
20 rmx(s);              removes .aux and .log files of TeXfile s
21 xdvi(s);             calls xdvi for dvi-file s
22         (parameters in square brackets [] are optional)
[917fb5]23
24GLOBAL VARIABLES:
[ae4196]25  TeXwidth, TeXnofrac, TeXbrack, TeXproj, TeXaligned, TeXreplace, NoDollars
[8942a5]26  are used to control the typesetting
27  Call example texdemo; to become familiar with the features of latex.lib
[ae4196]28
29  TeXwidth      : int: -1,0,1..9, >9  controls the breaking of long polynomials
[651b46]30  TeXnofrac     : (int) flag,  write 1/2 instead of \frac{1}{2}
31  TeXbrack      : string: possible values {,(,<,|, the empty string
[ae4196]32                          controls brackets around ideals and matrices
33  TeXproj       : (int) flag, write : instead of , in intvecs and vectors
34  TeXaligned    : (int) flag, write maps (and ideals) aligned
35  TeXreplace    : list, entries twoelemented list for replacing symbols
[651b46]36  NoDollars     : (int) flag, suppresses surrounding $ signs
37";
[ae4196]38
39///////////////////////////////////////////////////////////////////////////////
40
[917fb5]41proc closetex(string fname, list #)
[651b46]42"USAGE:   closetex(fname[,style]); fname,style = string
[ae4196]43RETURN:  nothing; writes a LaTeX2e closing line into file fname
[917fb5]44NOTE:    style overwrites the default setting latex2e; maybe latex,amstex,tex
45         preceeding >> end ending \".tex\" may miss in fname;
[ae4196]46         overwriting an existing file is not possible
47EXAMPLE: example closetex; shows an example
[651b46]48"
[ae4196]49{
[917fb5]50  string default = "latex2e";
[ae4196]51  string s;
52  int i = 1;
53  int flag;
54
55  if (size(#)) { default = #[1];}
56
[917fb5]57  if (default=="latex2e" or default == "latex")
[ae4196]58   {  s = "\\end{document}"; flag = 1;}
59  if (default=="amstex") {s = "\\enddocument"; flag = 1;}
60  if (default=="tex") {s = "\\bye"; flag = 1;}
[917fb5]61  if (not(flag)) { s = "";}
[ae4196]62
[917fb5]63  if (size(fname))
[ae4196]64  {
65   while (fname[i]==">"){i++;}
66   fname = fname[i,size(fname)-i+1];
[917fb5]67
[ae4196]68   if (size(fname)>=4)               // check if filename is ending with ".tex"
69   { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
70   }
71   else {fname = fname + ".tex";}
72   write(fname, s);
[917fb5]73   write(fname," - Thanks latex.lib and Singular - ");
[ae4196]74  }
[917fb5]75  else {return(s);}
[ae4196]76}
77example
78{ "EXAMPLE:"; echo=2;
79   opentex("exmpl");
80   texobj("exmpl","{\\large \\bf hello}");
81   closetex("exmpl");
82}
83///////////////////////////////////////////////////////////////////////////////
84
85proc tex(string fname, list #)
[651b46]86"USAGE:   tex(fname[,style]); fname,style = string
[ae4196]87RETURN:  nothing; calls latex2e for compiling the file fname
[917fb5]88NOTE:    style overwrites the default setting latex2e; maybe latex,amstex,tex
89         ending ".tex" may miss in fname
[ae4196]90EXAMPLE: example tex; shows an example
[651b46]91"
[917fb5]92{
[ae4196]93  string default = "latex2e";
[917fb5]94  int retval;
[ae4196]95  int i=1;
96
97  if (size(#)) {default = string(#[1]);}
98
99  if (size(fname))
100  {
101   while (fname[i]==">"){i++;}
102   fname = fname[i,size(fname)-i+1];
[917fb5]103
[ae4196]104   if (size(fname)>=4)               // check if filename is ending with ".tex"
105   { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
106   }
107   else {fname = fname + ".tex";}
108   "calling ",default, " for :",fname,newline;
[917fb5]109
[ae4196]110   retval = system("sh",default + " " +  fname);
111  }
112  else
113  { " -- Need a filename ";
114    return();
115  }
116}
117example
118{ "EXAMPLE:"; echo =2;
119  ring r;
[8afd58]120  LIB "inout.lib";
[ae4196]121  ideal I = maxideal(7);
122  opentex("exp001");              // defaulted latex2e document
123  texobj("exp001","An ideal ",I);
124  closetex("exp001");
125  tex("exp001");
126
127  opentex("exp002","tex");       // create a texdocument
128  texobj("exp002","An ideal",I);
129  closetex("exp002");
130  tex("exp002","tex");
131  echo = 0;
[917fb5]132  pause("the created files will be deleted after pressing <RETURN>");
[ae4196]133  echo = 2;
[b2c82d]134  system("sh","rm exp00?.*");
[ae4196]135}
136///////////////////////////////////////////////////////////////////////////////
137
[917fb5]138proc opentex(string fname, list #)
[651b46]139"USAGE:   opentex(fname[,style]); fname,style = string
[ae4196]140RETURN:  nothing; writes as LaTeX2e header into a new file fname
141NOTE:    suffix .tex may miss in fname
[917fb5]142         style overwrites the default setting latex2e; may be latex,amstex,tex
[ae4196]143EXAMPLE: example opentex; shows an example
[651b46]144"
[917fb5]145{
[ae4196]146  string default = "latex2e";
147  string s;
148  int i =1;
149  int flag;
150
151  if (size(#)) { default = #[1];}
152
[917fb5]153  if (default == "latex2e")          // the default  latex2e header
154  { s =
[ae4196]155      "\\documentclass[12pt]{article}" + newline +
156   //   "\\usepackage{fullpage,amsmath,amscd,amsthm,amssymb,amsxtra,latexsym,epsfig}" + newline +
157      "\\usepackage{amsmath,amssymb}" + newline +
[917fb5]158      "\\parindent=0pt" + newline +
159      "\\newcommand{\\C}{{\\Bbb C}}" + newline +
160      "\\newcommand{\\F}{{\\Bbb F}}" + newline +
[ae4196]161      "\\newcommand{\\N}{{\\Bbb N}}" + newline +
162   // "\\newcommand{\\P}{{\\Bbb P}}" + newline +
[917fb5]163      "\\newcommand{\\Q}{{\\Bbb Q}}" + newline +
[ae4196]164      "\\newcommand{\\R}{{\\Bbb R}}" + newline +
165      "\\newcommand{\\T}{{\\Bbb T}}" + newline +
166      "\\newcommand{\\Z}{{\\Bbb Z}}" + newline + newline +
167      "\\begin{document}";
168    flag = 1;
169  }
170  if (default == "latex")
[917fb5]171  { s =
[ae4196]172      "\\documentstyle[12pt,amstex]{article}" + newline +
173      "\\parindent=0pt" + newline +
[917fb5]174      "\\newcommand{\\C}{{\\Bbb C}}" + newline +
175      "\\newcommand{\\F}{{\\Bbb F}}" + newline +
[ae4196]176      "\\newcommand{\\N}{{\\Bbb N}}" + newline +
177   // "\\newcommand{\\P}{{\\Bbb P}}" + newline +
[917fb5]178      "\\newcommand{\\Q}{{\\Bbb Q}}" + newline +
[ae4196]179      "\\newcommand{\\R}{{\\Bbb R}}" + newline +
180      "\\newcommand{\\T}{{\\Bbb T}}" + newline +
181      "\\newcommand{\\Z}{{\\Bbb Z}}" + newline + newline +
182      "\\begin{document}";
183    flag = 1;
[917fb5]184  }
185  if (default == "amstex")
186  { s =
[ae4196]187     "\\documentstyle{amsppt} " + newline + newline +
188     "\\document";
[917fb5]189    flag = 1;
[ae4196]190  }
191
[917fb5]192  if (default == "tex")
193  { s =
194     "";
[ae4196]195    flag = 1;
196  }
197  if (default == "own")            // the proper own header
198  { s = "";
199    flag = 1;
200  }
201  if (not(flag)) { s = "";}
202
[917fb5]203  if (size(fname))
[ae4196]204  {
205   while (fname[i]==">"){i++;}
206   fname = fname[i,size(fname)-i+1];
207
208   if (size(fname)>=4)               // check if filename is ending with ".tex"
209   { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
210   }
211   else {fname = fname + ".tex";}
212   fname = ">" + fname;
213   write(fname,s);
214  }
[917fb5]215  else {return(s);}
[ae4196]216}
217example
218{ "EXAMPLE:"; echo=2;
219   opentex("exmpl");
220   texobj("exmpl","hello");
221   closetex("exmpl");
222}
223///////////////////////////////////////////////////////////////////////////////
224
[917fb5]225proc texdemo(list #)
[651b46]226"USAGE:   texdemo();
[ae4196]227RETURN:  nothing; generates automatically a LaTeX2e file called: texlibdemo.tex
[651b46]228         explaining the  features of latex.lib and its gloabl variables
[917fb5]229NOTE:    this proc takes a minutes
[ae4196]230EXAMPLE: example texdemo; executes the generation
[651b46]231"
[ae4196]232{ int TeXdemostart = system("pid");
233  string fname = "texlibdemo";
234
[917fb5]235  if (size(#))
236  { if (typeof(#[1])=="int") {TeXdemostart = #[1];}
[ae4196]237  }
[212d09]238  system("--random",TeXdemostart);
[917fb5]239
[ae4196]240  if (size(#) ==2)
241  { if (typeof(#[2]) == "string") { fname = #[2];}
242  }
243
244    if (size(fname))
245    {
246     if (size(fname)>=4)           // check if filename is ending with ".tex"
247     { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
248     } else {fname = fname + ".tex";}
249    }
250
251
252   part0(fname);
253   part1(fname);
254   part2(fname);
255   part3(fname);
256   print(" Demofile generated ...");
257   if (size(fname))
258   {
259    print(" call latex now by tex(\"" + fname + "\");" );
260    print(" .log and .aux files may be deleted with rmx(\"texlibdemo\");");
261   }
262  return();
263}
264example
265{ "EXAMPLE:";
266  texdemo();
267}
268///////////////////////////////////////////////////////////////////////////////
269
[917fb5]270proc texfactorize(string fname, poly f, list #)
[651b46]271"USAGE:   opentex(fname,f); fname = string; f = poly
[ae4196]272RETURN:  string, the poly as as product of its irreducible factors
273                 in TeX-typesetting if fname == empty string;
[917fb5]274         otherwise append this to file fname.tex; return nothing
275NOTE:    preceeding >> end ending \".tex\" may miss in fname
[ae4196]276EXAMPLE: example texfactorize; shows an example
[651b46]277"
[ae4196]278{
279  def @r = basering;
280  list l;
281  int i,j,k,Tw,TW,ND;;
282  intvec v;
283  string s,t;
284  string D = "$";
285  poly g;
286
287  ND = defined(NoDollars);
288  if (!(ND)) {int NoDollars; export NoDollars;}
289  else { D = ""; }
290  TW = defined(TeXwidth);
[917fb5]291  if (TW) {Tw = TeXwidth; TeXwidth = -1;}
[ae4196]292  else {int TeXwidth = -1; export TeXwidth;}
293
294  if (f==0) {s= D + "0" + D;}
295  else
296  {
297   l = factorize(f);      // sollte auch fuer f== 0 direkt funktionieren
298   if (l[1][1]<>1){s = texpoly("",l[1][1]);}
299   for(i=2;i<=size(l[1]);i++)
300   {
301    if(size(s)){s = s+"\\cdot ";}
302    g = l[1][i];
303    v = leadexp(g);
304    k=0;
305    for(j=1;j<=size(v);j++){k = k + v[j];}
306    if(size(g)>1 or (size(g)==1 and k>1))
307    { t = "(" + texpoly("",l[1][i]) + ")";}
[917fb5]308    else { t =  texpoly("",l[1][i]);}
[ae4196]309    if (l[2][i]>1)
310    { t = t+"^{" +string(l[2][i]) + "}";}
311    s = s + t;
312   }
313   if (!(ND)) { kill NoDollars;}
314   s = D + s + D;
315   if (TW) {TeXwidth = Tw;}
316  }
[917fb5]317  if(size(fname))
[ae4196]318  { i=1;
319    while (fname[i]==">"){i++;}
320    fname = fname[i,size(fname)-i+1];
321
322    if (size(fname)>=4)             // check if filename is ending with ".tex"
323    { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
324    }
325    else {fname = fname + ".tex";}
326    write(fname,s);
327  }
328  else{return(s);}
329}
330example
331{ "EXAMPLE:"; echo=2;
332  ring r2=13,(x,y),dp;
333  poly f = (x+1+y)^2*x3y*(2x -2y)*y12;
334  texfactorize("",f);
335  ring R49 = (7,a),x,dp;
336  minpoly = a2 +a +3;
337  poly f = (a24x5 + x3)*a2x6*(x+1)^2;
[917fb5]338  f;
[ae4196]339  texfactorize("",f);
340}
341///////////////////////////////////////////////////////////////////////////////
342
343proc texmap(string fname, def m, def @r1, def @r2, list #)
[651b46]344"USAGE:   texmap(fname,f); fname = string; m = string/map, @r1,@r2 = ring
[ae4196]345RETURN:  string, the map m from @r1 to @r2 preeceded by its name if m = string
346                 in TeX-typesetting if fname == empty string;
[917fb5]347         otherwise append this to file fname.tex; return nothing
348NOTE:    preceeding >> end ending \".tex\" may miss in fname
[ae4196]349EXAMPLE: example texmap; shows an example
[651b46]350"
[917fb5]351{
[ae4196]352  int saveDollars= defined(NoDollars);
353  int TX = defined(TeXwidth);
354  int Tw;
355  int i,n;
356  string r1str,r2str, varr1str, varr2str;
357  string mapname,t,s;
358  string D,DD,vrg = "$","$$",",";
359  def @r = basering;
360  def themap;
361  list l1,l2;
362  string rr1,rr2 = "@r1","@r2";
363
364  proc rp(string s)
365  { int i;
366
[917fb5]367    for(i=1;i<=size(TeXreplace);i++)
[ae4196]368    { if (TeXreplace[i][1]==s) {s= TeXreplace[i][2]; break;}}
369    return(s);
370  }
[917fb5]371
[ae4196]372// --- store all actual informations
373  if(TX) { Tw = TeXwidth; TeXwidth = -1;}
374  else { int TeXwidth = -1; export TeXwidth;}
375  if (!(saveDollars)) { int  NoDollars; export NoDollars;}
376  if (defined(TeXproj)) {vrg = ":";}
377
378  if (size(#))
379  { if (typeof(#[1])=="list")
380    { l1 = #[1];
381      if(size(#)==2) { l2 = #[2];}
382    }
383    else {l1=#; l2 =#;}
384  }
385// --- tex the information in preimring r1
386
387  setring(@r1);
388  r1str = texring("",@r1,l1);
389// --- avoid an execute; hence construct an ideal
390
391  n = nvars(@r1);
392  if (n>1) { t = "\\left(";}
393  ideal @I = var(1);
394  t = t + texpoly("",var(1));
395  for(i=2;i<=n;i++)
396  { @I = @I + var(i);
397    t = t + vrg + texpoly("",var(i));
398  }
399  if (n>1) { t = t + "\\right)";}
400  varr1str = t;
401
402// --- now the things in ring ring r2
403
404  setring(@r2);
405 // listvar();
406
407  if (typeof(m)=="string")
408  { themap = `m`;
409    mapname = m;
410    if (defined(TeXreplace))
411    { mapname = rp(mapname);   // rp ausschreiben !
412    }
413    mapname = mapname + ":";
414  }
415  if (typeof(m)=="map") { themap = m;}
416
417  r2str = texring("",@r2,l2);
418  ideal @J  = themap(@I);
419  n = size(matrix(@J));
420  if (n>1) { t = " \\left(";}
421  if (!(defined(TeXaligned)) and (n>1))
422      { t = t + newline + "\\begin{array}{c}" + newline;}
423  t = t + texpoly("",@J[1]);
424  for (i=2;i<=n; i++)
[917fb5]425  {if(defined(TeXaligned))
[ae4196]426   { t = t + vrg + texpoly("",@J[i]); }
427   else { t = t + "\\\\" + newline + texpoly("",@J[i]);}
428  }
429  if (!(defined(TeXaligned)) and (n>1))
430      { t = t + newline + "\\end{array}" + newline;}
431  if (n>1) {t = t + "\\right)";}
432  varr2str = t;
433
434// --- go back to  ring r1 to kill @I
435
436  setring(@r1);
437  kill @I;
438
439// --- now reset the old settings and stick all the information together
440
441  setring(@r);
442  if (!(saveDollars)) { kill NoDollars;}
443  if (TX) {TeXwidth = Tw;}
444  else { kill TeXwidth;}
445  if (defined(NoDollars))
446  { D,DD = "",""; }
447
448  if (defined(TeXaligned))
449  { s = D + mapname;
450    s =  s + r1str + "\\longrightarrow" + r2str + ", \\ " +
451        varr1str + "\\longmapsto" + varr2str + D; }
452  else
453  { s = DD;
454    s = s + newline + "\\begin{array}{rcc}" +  newline;
455    s = s + mapname + r1str + " & \\longrightarrow & " +  r2str + "\\\\[2mm]"
456          + newline;
457    s = s + varr1str + " & \\longmapsto & " +  newline + varr2str + newline;
458    s = s + "\\end{array}" + newline;
459    s = s +  DD;
460  }
461
462  if (size(fname))
463  { i=1;
464    while (fname[i]==">"){i++;}
465    fname = fname[i,size(fname)-i+1];
466
467    if (size(fname)>=4)          // check if filename is ending with ".tex"
468    { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
469    }
470    else {fname = fname + ".tex";}
471    write(fname,s);
472  }
473  else {return(s);}
474}
[917fb5]475example
[ae4196]476{ "EXAMPLE:"; echo = 2;
477  string fname = "tldemo";
[d6cc54]478  ring r1=0,(x,y,z),dp;
479  if(system("with","Namespaces")) { exportto(Current, r1); }
480  else { export r1; }
[ae4196]481  ring r2=0,(u,v),dp;
482  map phi =(r1,u2,uv -v,v2); export phi;
483  list TeXreplace;
484  TeXreplace[1] = list("phi","\\phi");
485  export TeXreplace;
486  texmap("","phi",r1,r2);
487  int TeXaligned; export TeXaligned;
488  texmap("",phi,r1,r2,"\\C");
489  kill r1,r2,TeXreplace,TeXaligned;
[917fb5]490}
[ae4196]491///////////////////////////////////////////////////////////////////////////////
492
[917fb5]493proc texname(string fname, string s)
[651b46]494"USAGE:   texname(fname,s);  fname,s = string
495RETURN:  the string s if fname == the empty string
[917fb5]496         otherwise append s to file fname.tex; return nothing
497NOTE:    preceeding >> end ending \".tex\" may miss in fname
[ae4196]498EXAMPLE: example texname; shows an example
[651b46]499"
[ae4196]500{
501  string st, extr;
502  int i,anf,end,op,bigch;
503  int n;
504
505  if (s[1]=="{") { return(s[2,size(s)-2]);}
506  if (s=="") { return(s);}
507  s = s + newline;             // add a terminating sign
508  anf=1;
509  while(s[i]!=newline)
510  {
511   i =anf;
512
513  while(s[i]<"0" or s[i]>"9" and s[i]!="'" and s[i]!= "_" and s[i]!="~" and
514        s[i]!="(" and s[i]!=")" and s[i]!= "[" and s[i]!=newline) {i++;}
515  if (s[i]==newline){st = st + s[anf,i-anf]; n = n +10*(i-anf); return(st);}
516  st = st + s[anf,i-anf];                        // the starting letters
517 if (s[anf]>="A" and s[anf]<="Z") {bigch=1;}
518  if (s[i]=="'") { st = st + "'";i++;}
519  if (s[i]=="~") { st = "\\tilde{" + st + "}"; i++;}
520  if (s[i]=="_") { i++;}
521  if (s[i]=="(") { op =1;i++;}
522  if (s[i]=="[") { anf = i+1;
523   while(s[i]!="]"){i++;}                    // matrices and vectors
[917fb5]524    st = st + "_{" + s[anf,i-anf] + "}"; n = n+ 5*(i-anf); i++;
[ae4196]525  // besser: while s[i]<> nwline : scan forward: end, return
526  }
527  if (s[i]==newline) {return(st);}
528  anf =i;
529  while (s[i]>="0" and s[i]<="9") {i++;}  // parse the number after the letters
530  if (bigch and not(op)) { st = st + "^{" + s[anf,i-anf] + "}"; bigch =0;}
531  else { st = st + "_{" + s[anf,i-anf] + "}";}
532  n = n+5*(i-anf);
533  anf =i;            // the next text in ( , ) as exponent
[917fb5]534  if (op) { if (s[i]== ","){anf = anf+1;}
[ae4196]535   while(s[i] !=")"){ i++;}
536   if (i<>anf){st = st + "^{" + s[anf,i-anf] + "}"; n = n +5*(i-anf);}
537  i++;
538  }
539  anf =i;
540  }
541  if (size(fname))
542  { i=1;
543    while (fname[i]==">"){i++;}
544    fname = fname[i,size(fname)-i+1];
545
546    if (size(fname)>=4)            // check if filename is ending with ".tex"
547    { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
548    }
549    else {fname = fname + ".tex";}
550    write(fname,st);
551  }
552  else {return(st);}
553}
554example
555{ "EXAMPLE:"; echo =2;
556   ring r = 0,(x,y),lp;
557   poly f = 3xy4 + 2xy2 + x5y3 + x + y6;
558   texname("","{f(10)}");
559   texname("","f(10) =");
560   texname("","n1");
561   texname("","T1_12");
562   texname("","g'_11");
563   texname("","f23");
564   texname("","M[2,3]");
565   texname("","A(0,3);");
566   texname("","E~(3)");
567}
568///////////////////////////////////////////////////////////////////////////////
569
570proc texobj(string fname, list #)
[651b46]571"USAGE:   texobj(fname,l); fname = string,l = list of Singular dataypes
[ae4196]572RETURN:  string, the objects in TeX-typesetting if fname == empty string;
[917fb5]573         otherwise append this to file fname.tex; return nothing
574NOTE:    preceeding ">>" end ending ".tex" may miss in fname;
[ae4196]575EXAMPLE: example texobj; shows an example
[651b46]576"
[ae4196]577{
578 int i,j,k,nr,nc,linear,Tw,Dollars;
579 int ND = defined(NoDollars);
580 int TW = defined(TeXwidth);
581
582 if(defined(basering)){ poly g,h; matrix M;}
583 string s,t,l,ineq,sg,Iname;
584 string sep= ",";
585 string D,DA,DE = "$","\\begin{equation*}" + newline,
586                     "\\end{equation*}"+ newline;
[917fb5]587 string OB,CB = "(",")";
[ae4196]588 if (defined(TeXbrack))
589 {// if (TeXbrack=="(") {OB = "("; CB = ")";}
590   if (TeXbrack=="<") {OB = "<"; CB = ">";}
591   if (TeXbrack=="{") {OB = "{"; CB = "}";}
592   if (TeXbrack=="|") {OB = "|"; CB = "|";}
593   if (TeXbrack=="" ) {OB = "."; CB = ".";}
594 }
595
596
597 if (!(TW)) { int TeXwidth = -1; export TeXwidth; }
598 Tw = TeXwidth;
599
600 if (defined(TeXproj)){ sep = ":";}
601 if(ND) { D,DA,DE="","","";}
602 else {int NoDollars; export NoDollars;}
603
604 proc absterm(poly f)
605 { int k;
[917fb5]606
[ae4196]607   for (k=1; k<=nvars(basering); k++)
608   { f = subst(f,var(k),0); }
609   return(f);
610 }
611
612
613 if (size(#)==1)
[917fb5]614 { if (typeof(#[1])=="int" or typeof(#[1])=="intvec" or typeof(#[1])=="vector"
[ae4196]615   or typeof(#[1])=="number" or defined(TeXaligned)) { DA = D; DE = D; } }
616
617 s = DA;
618
619 for (k=1; k<=size(#); k++)
620 { def obj = #[k];
[917fb5]621   if (typeof(obj) == "string")
[ae4196]622   { if (defined(`obj`))
[917fb5]623     { if (typeof(`obj`)=="ideal")
[ae4196]624       { Iname = obj; def e = `obj`;
625         kill obj; def obj = e; kill e;}
626       else {s = s + obj + newline;}
627    }
628    else { s = s + obj + newline;}
629   }
630   if (typeof(obj) == "int") { s = s + "  " + string(obj) + "  ";}
[917fb5]631
632   if (typeof(obj) == "intvec")
[ae4196]633   { s = s + "  (";
634     for(j=1; j<size(obj);j++) { s = s + string(obj[j]) + sep;}
635     s = s +  string(obj[j]) + ")  ";
636   }
637
[917fb5]638   if (typeof(obj) == "number" )
[ae4196]639   { s = s + texpoly("",obj) + newline;
640   }
641
642   if (typeof(obj) == "poly")
643   { int TeXdisplay; export TeXdisplay;
644     s = s + "\\begin{split}" + newline;
645     s = s + texpoly("",obj) + "\\\\" + newline;
646     s = s + "\\end{split}" + newline;
647    kill TeXdisplay;
648   }
649
[917fb5]650   if (typeof(obj) == "vector")
[ae4196]651   { if (obj==0) { s = s  + "0" ;}
652     else
653     { if (Tw==0) { TeXwidth = -1;}
654      s = s + "\\left" + OB;
655      for(j=1; j<nrows(obj); j++) {s = s + texpoly("",obj[j]) + sep;}
656      s = s + texpoly("",obj[j])  + "\\right" + CB + newline;
657      TeXwidth = Tw;
658     }
659    }
660
[917fb5]661   if (typeof(obj) == "ideal")
[ae4196]662   { if (size(Iname))   // verwende hier align
663     { if (Tw==0) {TeXwidth = -1;}
664
665      // Lasse hier TeXwidth == 0 zu !
666      // if (!(defined(TeXaligned)))
667      //  { untereinander }
668      // else { hintereinander }
[917fb5]669      //
670      //
671      //  s = s + Iname + "=" + texpoly("",obj,",");
[ae4196]672      //  siehe ebenso noch einmal am Ende : ! (TeXwidth <> 0 !? )
673
674       s =  s + "\\begin{array}{rcl}" + newline;
675       for (i=1;i<=size(matrix(obj));i++)
[917fb5]676       { s =  s + Iname+ "_{" + string(i) + "} & = & "
[ae4196]677               + texpoly("",obj[i]);
678         if (i<size(matrix(obj))){ s = s  + "\\\\" + newline;}
679       }
680       s = s + newline;
681       s = s + "\\end{array}" + newline;
682       TeXwidth = Tw;
683       Iname ="";
684     }
[917fb5]685     else
686     {
687      if (TeXwidth==0)
[ae4196]688      { TeXwidth = -1;
689        obj= simplify(obj,2);
690        linear = 1;
691        for (j=1;j<=size(obj);j++)
692        { if (deg(obj[j])>1){linear =0; break;}
693        }
694        if (!(linear))
695        { s = s + "\\begin{array}{rcl}" + newline;
696          for(j=1;j<=size(obj);j++)
697          { h = absterm(obj[j]);
698            ineq = attrib(obj[j],"ineq");
699            if(!(size(ineq))) { ineq = "=" ; }
700            l = texpoly("",obj[j]-h) + " & " + ineq + " & " + texpoly("",-h);
701            if(j<size(obj)) { l = l + " \\\\";}
702            s =s+ l + newline;
703           }
704          s = s + "\\end{array}" + newline;
705        }
706        else   // linear
[917fb5]707        { s = s +
[ae4196]708   "\\begin{array}{*{" + string(2*nvars(basering)-1) + "}{c}cr}" + newline;
[917fb5]709           for(j=1; j<=size(obj);j++)
710           { h = absterm(obj[j]);
[ae4196]711             ineq = attrib(obj[j],"ineq");
712             if(!(size(ineq))) { ineq = "=" ; }
713              l = ""; nc = 0;
714              for (i=1; i<=nvars(basering);i++)
715              { t = " "; sg ="";
716                g = obj[j]-subst(obj[j],var(i),0);
717                if (g!=0) { t = texpoly("",g);}
718                if (i>1)
719                { if (t[1]!="-" and t[1]!= " " and nc ){sg = "+";}
720                  if  (t[1]=="-") { sg = "-"; nc =1; t=t[2,size(t)-1];}
[917fb5]721                  if (t==" ") {sg ="";}
[ae4196]722                  l = l + " & " + sg + " & " + t;
723                }
724                else { l = t;}
725                if (g!=0) {nc = 1;}
726               }
727
728               l = l + " & " + ineq + " & " + texpoly("",-h);
729             if (j < size(obj)) { l = l + " \\\\";}
730             s = s + l + newline;
731            } // end for (j)
732          s = s + "\\end{array}";
733         }  // end else linear
734        TeXwidth = 0;
735       } // end TeXwidth == 0
736   else // TeXwidth <> 0
737   { s =  s + "\\left"+ OB;
738     if (defined(TeXaligned))
739     { s = s + texpoly("",obj,",");
[917fb5]740     }
[ae4196]741     else
742     { s = s + newline + "\\begin{array}{c}" + newline +
[917fb5]743               texpoly("",obj,", \\\\" + newline) +
[ae4196]744                newline + "\\end{array}" + newline;
745     }
746    s = s + "\\right" + CB;
[917fb5]747    } // end TeXwidth <> 0
[ae4196]748   }  // not Iname
749// s;
750  }
751
[917fb5]752   if (typeof(obj) == "module")
[ae4196]753   { M = matrix(obj);
754     if (Tw ==0 or Tw > 9) { TeXwidth = -1;}
755     s = s + "\\left" + OB + newline;
756     if (!(defined(TeXaligned)))
757     {  // Naechste Zeile nicht notwendig !
[917fb5]758     // s = s + "\\begin{array}{*{"+ string(ncols(M)) + "}{c}}" + newline;
759      for(j=1;j<=ncols(M);j++)
[ae4196]760      { l = "\\left" + OB + newline + "\\begin{array}{c}" + newline;
761        l = l + texpoly("",ideal(M[1..nrows(M),j]), " \\\\" + newline)
762              + newline + "\\end{array}" +newline + "\\right" + CB + newline;
763        if (j< ncols(M)) { l = l + " , " + newline;}
764        s = s + l ;
765      }
766     }
767     else    // TeXaligned
[917fb5]768     {
769      for(j=1;j<=ncols(M);j++)
[ae4196]770      { s = s + "\\left" + OB + newline +
771           texpoly("",ideal(M[1..nrows(M),j]),",") + newline + "\\right" + CB;
772        if (j<ncols(M)) { s = s + "," + newline; }
773      }
774     }
775    s = s  + "\\right" + CB + newline;
776   } // module part
777
778
779   if (typeof(obj) == "matrix")
780   { if (Tw==0 or Tw > 9) {TeXwidth = -1;}
781     l = "";
782   //  M = transpose(obj);
[917fb5]783     s = s + "\\left" + OB + newline +
[ae4196]784             "\\begin{array}{*{"+ string(ncols(obj)) + "}{c}" + "}"+ newline;
785     for(i=1;i<=nrows(obj);i++)
786     { l = l + texpoly("",ideal(obj[i,1..ncols(obj)])," & ");
787       if (i<nrows(obj)) { l = l + " \\\\" + newline;}
788     }
789     l = l + newline;
[917fb5]790     s = s + l + "\\end{array}" + newline +
[ae4196]791                 "\\right" + CB + newline;
792    TeXwidth = Tw;
793  }
[917fb5]794
[ae4196]795   if (typeof(obj) == "intmat")
796   { nr,nc = nrows(obj),ncols(obj);
797     l = "";
[917fb5]798     l =  "\\left" + OB + newline +
[ae4196]799          "\\begin{array}{*{"+ string(nc) + "}{r}}"+ newline;
800     for(i=1;i<=nr;i++)
[917fb5]801     { for(j=1;j<=nc;j++)
[ae4196]802       { l = l + string(obj[i,j]);
803         if (j <nc ) { l = l + " & ";}
804         else {if( i < nr) { l = l + "\\\\" + newline;}}
805       }
806     }
[917fb5]807     l = l + newline + "\\end{array}" + newline +
[ae4196]808             "\\right" + CB + newline;
[917fb5]809    s = s + l;
[ae4196]810  }
811
812  if (typeof(obj) == "ring" or
813      typeof(obj) == "qring") { s = s + D + texring("",obj) + D + newline;}
814
815  kill obj;
816 }
817
818 s = s +  DE + newline;
819
820 if(!(ND)) { kill NoDollars;}
821
822// s;
823 if(size(fname))
824 { i=1;
825  while (fname[i]==">"){i++;}
826  fname = fname[i,size(fname)-i+1];
827  if (size(fname)>=4)               // check if filename is ending with ".tex"
828  { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
829  }
830  else {fname = fname + ".tex";}
831  write(fname,s);
832 }
833 else {return(s);}
834}
835example
836{ "EXAMPLE:"; echo =2;
837   ring r = 0,(x,y),lp;
838   poly f = 3xy4 + 2xy2 + x5y3 + x + y6;
839   ideal G = jacob(f);
840   texobj("",G);
841   matrix J = jacob(G);
842   texobj("",J);
843   intmat m[3,4] = 9,2,4,5,2,5,-2,4,-6,10,-1,2,7;
844   texobj("",m);
845   ring r0 = 0,(x,y,z),dp;
846   ideal I = 2x2-4yz3+2-4,zy2+2x,y5z-6x2+7y4z2 +5;
847}
848///////////////////////////////////////////////////////////////////////////////
849
[917fb5]850proc texproc(string fname,string pname)
[651b46]851"USAGE:   opentex(fname,pname); fname,pname = string
[917fb5]852RETURN:  string, the proc in a verbatim environment in TeX-typesetting
[ae4196]853                 if fname == empty string;
[917fb5]854         otherwise append this to file fname.tex; return nothing
855NOTE:    preceeding >> end ending \".tex\" may miss in fname;
856CAUTION: texproc cannot applied on itself correctly
[ae4196]857EXAMPLE: example texproc; shows an example
[651b46]858"
[ae4196]859{
860  int i,j=1,1;
861  string p,s,t;
862
863  if (defined(pname))
864  { if (typeof(`pname`)=="proc")
865    { p = string(`pname`);
866      s = "\\begin{verbatim}" + newline;
867      s = s + "proc " + pname + "(";
868      i = find(p,"parameter");       // collecting the parameters
869      while(i)
870      { j=find(p,";",i);
871        t = p[i+10,j-i-10];
872        if(i>1){s = s + ",";};
873        s = s + t;
874        i = find(p,"parameter",j);
875      }
876      s = s + ")" + newline;
877     j++;                      // skip one for the newline
878     i = find(p,"return();",j);
879     if (!(i))
880     { i = find(p,";RETURN();",j); }  // j kann hier weg
881     s = s + "{" + p[j,i-j-1] + "}" + newline;
882     s = s + "\\end{verbatim}" + newline;
883   }
884  }
885  else
886  { print(" --Error: No such proc defined");
887    return();
888  }
889  if(size(fname))
890  { i=1;
891    while (fname[i]==">"){i++;}
892    fname = fname[i,size(fname)-i+1];
893    if (size(fname)>=4)        // check if filename is ending with ".tex"
894    { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
895    }
[917fb5]896    else {fname = fname + ".tex";}
[ae4196]897    write(fname,s);
898  }
[917fb5]899  else{return(s);}
[ae4196]900}
901example
902{ "EXAMPLE:"; echo=2;
903  proc exp(int i,int j,list #)
904  { string s;
905
906    if (size(#))
907    {
908     for(i;i<=j;i++)
909     { s = s + string(j) + string(#); }
910    }
911   return(s);
912  }
913  export exp;
[917fb5]914  texproc("","exp");
[ae4196]915}
916
917///////////////////////////////////////////////////////////////////////////////
918
[917fb5]919proc texring(string fname, def r, list #)
[651b46]920"USAGE:   texring(fname, r[,l]); fname = string; r = ring;
921         l=list of strings : controls the symbol for
[917fb5]922         coefficient field etc. see example texdemo();
[ae4196]923RETURN:  string, the ring in TeX-typesetting if fname == empty string;
[917fb5]924         otherwise append this to file fname.tex; return nothing
925NOTE:    preceeding >> end ending \".tex\" may miss in fname;
[ae4196]926EXAMPLE: example texring; shows an example
[651b46]927"
[917fb5]928{
[ae4196]929  int i,galT,flag,mipo,nopar,Dollars,TB,TA;
930  string ob,cb,cf,en,s,t,savebrack; //opening bracket, closing br, coef.field
931  intvec v;
932
933
934  proc tvar(intvec v)
[917fb5]935  {
[ae4196]936    int i,j,ldots;
937    string s;
[917fb5]938
[ae4196]939    j = 1;
940    s = texpoly("",var(1));
[917fb5]941
[ae4196]942    if (nvars(basering)==1) { return(s);}
943    if (nvars(basering)==2) { return(s + "," + texpoly("",var(2)));}
944    if (size(v)==1 and v[1] == 1)
945       {return(s + ",\\ldots,"+ texpoly("",var(nvars(basering))));}
946    if (v[1]==1 and size(v) >1) {j++;}
947
948    for(i=2;i<nvars(basering);i++)
949    { if (i<v[j]  and !(ldots))
950      { s = s + ",\\ldots";
951        ldots =1;
952      }
[917fb5]953      if (i== v[j])
[ae4196]954      { s = s + "," + texpoly("",var(i));
955        ldots =0;
956        if (j< size(v)) {j++;}
957      }
958    }
959   if (v[j]<nvars(basering)-1) { s = s + ",\\dotsc";}
960   return(s + "," + texpoly("",var(nvars(basering))));
961  }
962
963
964  setring r;
965  if (!(defined(NoDollars))){ Dollars = 1; int NoDollars; export NoDollars;}
966  ob,cb = "[","]";
967  if (find(ordstr(r),"s")) { ob,cb="\\{","\\}";}
968  if(char(r)==0){cf="\\Q";}
969  if(charstr(r)=="real"){cf="\\R";}
970  if(char(r)==prime(char(r))){cf="\\Z_{"+string(char(r))+"}";}
971  if(char(r)>0)
972  { i = find(charstr(r),",");
973    if(i)
974    { t= charstr(r)[1,i-1];
975      galT = (t <> string(char(r)));
976      if (galT) { cf = "\\F_{"+ t + "}";}
977    }
978  }     // all other cases are cover already by char(r)=? prime(char)
979
980  if (size(#))
981  { if (typeof(#[1])=="list") { # = #[1];}
[917fb5]982  }
[ae4196]983  for (i=1;i<=size(#);i++)
984  { flag =0;
985    if(typeof(#[i])=="string")
986    {
987     if(#[i][1]=="^" or #[i][1]=="_"){en=en+#[i];flag = 1;}
988     if(#[i]=="mipo"){mipo=1; flag = 1;}
989     if(#[i]=="{"){ob,cb="\\{","\\}";flag=1;}
990     if(#[i]=="{{"){ob,cb="\\{\\{","\\}\\}";flag=1;}
991     if(#[i]=="["){ob,cb="[","]";flag=1;}
992     if(#[i]=="[["){ob,cb="[[","]]";flag=1;}
993     if(#[i]=="<"){ob,cb="<",">";flag=1;}
994     if(#[i]=="<<"){ob,cb="{\\ll}","{\\gg}";flag=1;}
995     if(#[i]=="C"){cf="\\C";flag=1;}
996     if(#[i]=="Q"){cf="\\Q";flag=1;}
997     if((#[i]=="k" or #[i]=="K" or #[i]=="R") and !(galT))
998                   {cf=#[i]; flag=1; nopar=1;}
999     if (flag!=1) {cf = #[i];}  // for all the cases not covered here e.g Z_(p)
1000    }                           // or Q[i]
1001
1002    if ((typeof(#[i])=="intvec") or
1003        (typeof(#[i])=="int")){v=#[i];}
1004   }
1005  s = cf;
1006 // now the parameters
1007 // t;
1008  if(npars(r) and ((t==string(char(r))) or char(r)==0) and !(nopar))
1009  {
1010   s = s + "(";                      // !! mit ideal !!
1011   for(i=1;i<npars(r);i++) {s = s + texpoly("",par(i)) + ",";}
1012   s = s + texpoly("",par(npars(r))) + ")";
1013  }                               // parameters done
[917fb5]1014  if (!(galT) and mipo and minpoly!=0)
[ae4196]1015  { s = s + "/" + list(parsp(string(minpoly),0))[1];}
1016  s = s + ob;
1017  if (v!=0 and nvars(r)>3)
1018  { s = s + tvar(v);}
1019  else
1020  { s = s + texpoly("",maxideal(1),","); }
1021   s = s + cb + en;
1022
1023  if (typeof(r)=="qring")
1024  { ideal @I = ideal(r);
[917fb5]1025    if (defined(TeXbrack))
[ae4196]1026    {
[917fb5]1027      TB =1; savebrack = TeXbrack;
[ae4196]1028      if (TeXbrack!= "<" and TeXbrack!="(") { TeXbrack = "<";}
1029    }
1030    TA = defined(TeXaligned);
1031    if (!(TA)) { int TeXaligned; export TeXaligned; }
1032    t = texobj("",@I);
1033 //   @I;
1034 //   t;
1035    if (TB) { TeXbrack = savebrack;}
1036    if (!(TA)) { kill TeXaligned;}
1037    s = s + "/" + t;
1038  }
1039
[917fb5]1040  if (Dollars)
[ae4196]1041  { kill NoDollars;
1042    s =  "$" + s + "$";
1043  }
1044  if (size(fname))
1045  { i=1;
1046     while (fname[i]==">"){i++;}
1047     fname = fname[i,size(fname)-i+1];
1048
1049     if (size(fname)>=4)           // check if filename is ending with ".tex"
1050     { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
1051     }
1052     else {fname = fname + ".tex";}
1053     write(fname,s);
1054  }
1055  else{return(s);}
[917fb5]1056}
[ae4196]1057example
1058{ "EXAMPLE:"; echo=2;
1059  ring r0 = 0,(x,y,z),dp;       // short varnames polynomial ordering
1060  texring("",r0);
[917fb5]1061  ring r7 =0,(x(0..2)),ds;      // char =7, long varnames
[ae4196]1062  texring("",r7);
1063  ring r1 = 0,(x1,x2,y1,y2),wp(1,2,3,4);
1064  texring("",r1);
1065  ring r2= 0,(x_10,x_11),M(1,2,3,4);
1066  texring("",r2);
1067  ring rr = real,(x),dp;        // real numbers
1068  texring("",rr);
1069  ring r;
[917fb5]1070  texring("",r);
[ae4196]1071  ring rabc =(0,t1,t2,t3),(x,y),dp;  // parameters
1072  texring("",rabc);
1073  ring ralg = (7,a),(x1,x2),(ds,dp);  // algebraic extension
1074  minpoly = a2-a+3;
1075  texring("",ralg);
1076  texring("",ralg,"mipo");
1077  ring r49=(49,a),x,dp;              // Galoisfield
[917fb5]1078  texring("",r49);
[ae4196]1079  setring r0;
1080  ideal i = x2-z,xy2+1;
1081  qring q = std(i);
1082  q;
1083  texring("",q);
1084  // -------- additional features -------------
1085  ring r10 =0,(x(0..10)),dp;
1086  texring("",r10,1);
1087  ring rxy = 0,(x(1..5),y(1..6)),ds;
1088  intvec v = 5,6;
1089  texring("",rxy,v);
[917fb5]1090  texring("",r0,"C","{");
[ae4196]1091  texring("",ralg,"k");
1092  texring("",r7,"^G");
1093  list TeXreplace;
1094  TeXreplace[1] = list("x","\\xi");
1095  TeXreplace[2] = list ("t","\\lambda");
1096  export TeXreplace;
1097  texring("",rabc);
1098  texring("",r7);
1099  kill TeXreplace;
1100}
1101
1102///////////////////////////////////////////////////////////////////////////////
1103
1104proc rmx(string fname)
[651b46]1105"USAGE:   rmx(fname); fname = string
[917fb5]1106RETURN:  nothing; removes .log and .aux files associated to file <fname>
[651b46]1107         removes tex and xdvi file too, if suffix \".tex\" or \".dvi\" is given
[917fb5]1108NOTE:    if fname ends by .dvi or .tex
1109         fname.dvi or fname.dvi and fname.tex will be deleted, too
[ae4196]1110EXAMPLE: example rmx; shows an example
[651b46]1111"
[ae4196]1112{
1113  int i,suffix= 1,0;
[917fb5]1114  int retval;
[ae4196]1115
1116  if (size(fname))
1117  {
1118   while (fname[i]==">"){i++;}
1119   fname = fname[i,size(fname)-i+1];
1120   if (size(fname)>4)
1121   { if (fname[size(fname)-3,4]==".tex") { suffix = 2;}
1122     if (fname[size(fname)-3,4]==".dvi") { suffix = 1; }
1123     if (suffix) { fname = fname[1,size(fname)-4]; }
[917fb5]1124   }
[ae4196]1125   retval = system("sh","rm " + fname + ".aux");
1126   retval = system("sh","rm " + fname + ".log");
1127   if (suffix==2) {retval = system("sh","/bin/rm -i " + fname +".tex");}
1128   if (suffix>=1) {retval = system("sh","/bin/rm -i " + fname +".dvi");}
1129  }
1130  else
1131  {" -- Need a filename ";
1132    return();
[917fb5]1133  }
[ae4196]1134}
1135example
1136{ "EXAMPLE:"; echo =2;
[8afd58]1137  LIB "inout.lib";
[ae4196]1138  ring r;
1139  poly f = x+y+z;
1140  opentex("exp001");              // defaulted latex2e document
1141  texobj("exp001","A polynom",f);
1142  closetex("exp001");
1143  tex("exp001");
1144  rmx("exp001");   // removes aux and log file of exp001
1145
1146  opentex("exp002","tex");       // create a texdocument
1147  texpoly("exp002",f);
1148  closetex("exp002");
1149  tex("exp002","tex");
1150  rmx("exp002.tex");  // removes aux, log, dvi and tex file of exp002
1151  echo = 0;
[917fb5]1152  pause("remaining files will be deleted after pressing <RETURN>");
[ae4196]1153  echo = 2;
1154  system("sh","rm -i exp00?.*");
1155}
1156///////////////////////////////////////////////////////////////////////////////
1157
1158proc xdvi(string fname, list #)
[651b46]1159"USAGE:   xdvi(fname[,style]); fname,style = string
[ae4196]1160RETURN:  nothing; displays dvi-file fname.dvi with previewer xdvi
1161NOTE:    ending .dvi may miss in fname
1162         style overwrites the default setting xdvi
[651b46]1163EXAMPLE: example xdvi; shows an example
1164"
[ae4196]1165{
1166  int i=1;
1167  int retval;
[917fb5]1168  string default = "xdvi";
1169
[ae4196]1170  if (size(#)) {default = string(#[1]);}
[917fb5]1171
[ae4196]1172  if (size(fname))
1173  {
1174   while (fname[i]==">") {i++;}
1175   fname = fname[i,size(fname)-i+1];
1176
1177   if (size(fname)>=4)
1178   { if(fname[size(fname)-3,4]==".tex") {fname = fname[1,size(fname)-4];}}
[917fb5]1179
1180   "calling ",default, " for :",fname,newline;
1181
[ae4196]1182   retval = system("sh",default + " " +  fname + " &");
1183  }
1184  else
1185  { " -- Need a filename ";
1186    return();
1187  }
1188}
1189example
1190{ "EXAMPLE:"; echo = 2;
[8afd58]1191  LIB "inout.lib";
[ae4196]1192  ring r;
1193  ideal i = maxideal(7);
1194  opentex("exp001");              // defaulted latex2e document
1195  texobj("exp001","An ideal",i);
1196  closetex("exp001");
1197  tex("exp001");
1198  xdvi("exp001");
1199  echo = 0;
[917fb5]1200  pause("the created files will be deleted after pressing <RETURN>");
[ae4196]1201  echo = 2;
[917fb5]1202  system("sh","rm -i exp00?.*");
[ae4196]1203}
1204///////////////////////////////////////////////////////////////////////////////
1205
1206proc texpoly(string fname,def p,list #)
[651b46]1207"USAGE:   texpoly(fname,p[,l]); fname = string; p = poly,ideal; l formation str
1208RETURN:  string, the objects in TeX-typesetting if fname == empty string;
[917fb5]1209         otherwise append this to file fname.tex; return nothing
1210NOTE:    preceeding ">>" end ending ".tex" may miss in fname;
[afcf7d]1211EXAMPLE: example texpoly; shows an example
[651b46]1212"
[917fb5]1213{
[ae4196]1214  def @r = basering;
1215
1216  poly f,monom;
1217  ideal I;
1218  number cfm;
1219  string sign,cfmt,pt,s,bg,t,monomt,  lnbreak;
1220  string sep = newline;
[917fb5]1221  int i,b,b2,n, msz,linesz, count,k;
[ae4196]1222  int realT, parT, galT;
1223  int C = 2 + defined(TeXdisplay);
1224
1225  string notvalid = "intvec intmat vector matrix module map ";
1226
1227  if (typeof(p) == "int") { return(p);}
1228  if (typeof(p)  == "ring" or typeof(p) == "qring")
1229  { " -- Call  texring  instead "; return();}
[917fb5]1230  if (find(notvalid,typeof(p)))
[ae4196]1231  { " -- Call  texobj  instead "; return();}
1232  if (typeof(p)  == "map")
1233  { " -- Call  texmap  instead "; return();}
1234  if (typeof(p)  == "proc")
1235  { " -- Call  texmap  instead "; return();}
1236  if (typeof(p)  == "link" or typeof(p) == "list" or typeof(p) == "resolution")
1237  { " -- Object can not translated into tex "; return();}
1238
1239  if (!(defined(TeXdisplay))){ lnbreak = "\\\\[2mm]" + newline;}
1240  else { lnbreak = "\\\\" + newline;}
1241
1242  proc parsr(string s)                     // parse real
[917fb5]1243  { string t;
1244
1245    if (s=="      Inf") { return("\\infty",3);}
[ae4196]1246    if (s=="     -Inf") { return("\\-infty",6);}
1247    if (s[7]=="-"){t ="-";}
1248    if (s[8]<>"0"){t = t + s[8];}
1249    if (s[9]<>"0" or s[8]<>"0"){t = t + s[9];}
[917fb5]1250    if (size(t))
[ae4196]1251    { if (t=="1") {return(s[1,5]+"*10",21);}
1252      if (size(t)>1) {return(s[1,5]+"*10^{"+t+"}",21+2*size(t));}
1253      else {return(s[1,5]+"*10^"+t,23);}
1254    }
1255    else {return(s[1,5],12);}
1256  }
1257
1258  proc parsg(string s)                  // parse Galoisfield
1259  { int i,j = 1,1;
1260    string t;
[917fb5]1261
[ae4196]1262    if (short)
[917fb5]1263    { t =s[1];
[ae4196]1264     if(size(s)>1) {return(t+"^{" + s[2,size(s)-1] + "}",3+2*(size(s)-1));}
[917fb5]1265     else{return(t,5);}
[ae4196]1266    }
1267    else
1268    { return(parselong(s+"!"));}
1269  }
[917fb5]1270
[ae4196]1271  if (defined(TeXdisplay)) { bg = "& ";}
1272  if (!(defined(TeXwidth))) { int TeXwidth = -1; export TeXwidth;}
1273
1274
1275// -- Type check
[917fb5]1276
[ae4196]1277 if (typeof(p)=="string")
1278  { if(defined(`p`))
[917fb5]1279    { pt = p + " = ";
1280      p = `p`;
[ae4196]1281    }
1282  }
1283  if (typeof(p)=="poly" or typeof(p)=="number") {I = p;}
[917fb5]1284
1285  if (typeof(p)=="ideal")
[ae4196]1286  { I = p;
1287    if(size(#)){ sep = #[1];}
1288  }
1289
[917fb5]1290  if (I==0)
[ae4196]1291  { if (!(defined(NoDollars))){return("$0$");}
1292    else {return("0");}
1293  }
1294
[917fb5]1295// -- Type check ende
[ae4196]1296
[917fb5]1297//---------------------
[ae4196]1298
1299
1300//------- set flags: --------------------------------------------------------
[917fb5]1301
[ae4196]1302  if (size(#))
1303  { if (typeof(#[1])=="int") { linesz = #[1];}
1304 //   if (typeof(#[1])=="string") { linesz = #[1];}
1305  }
1306
1307  parT = npars(@r);
1308  realT = (charstr(@r)=="real");
1309  i = find(charstr(@r),",");
1310  if (i)
1311  { t = charstr(@r)[1,i-1];
1312    galT = (t <> string(char(@r)));  // the char is not the same as the ...
[917fb5]1313  }
[ae4196]1314  i = 0;
[917fb5]1315
[ae4196]1316//------- parse the polynom
1317  pt = bg;
[917fb5]1318
[ae4196]1319 for(k=1;k<=size(matrix(I));k++)
1320 { i = 0; linesz = 0; count =0;
[917fb5]1321   sign ="";
[ae4196]1322   f = I[k];
1323   if (f==0) { pt = pt + "0";}
1324  while(f<>0)
1325  { count++; msz = 0;
1326
1327// ------ tex the coefficient
[917fb5]1328    monom = lead(f);
1329    f = f - monom;
[ae4196]1330    cfm = leadcoef(monom);
1331    if (cfm*1 != 0) { monom = monom/cfm;} // the normalized monom
1332    s = string(monom) + "!";              // add a terminating sign
1333    cfmt = "";
[917fb5]1334
[ae4196]1335    if (defined(TeXreplace)) { short =0;}  // this is essential
1336    cfmt = string(cfm);
1337    if (size(cfmt)>1)                   // check if sign is < 0
1338    { if (cfmt[2]=="-") { cfm = (-1) *cfm; sign = "-";}}
1339    if (cfmt[1] == "-") { cfm = (-1) * cfm; sign = "-";}
1340    if  (cfm!=1 or monom==1) {cfmt = string(cfm);}
1341    else {cfmt="";}
1342
1343    if (defined(TeXwidth) and TeXwidth > 0 and TeXwidth <9 and count> TeXwidth)
1344    { pt = pt + sign + "\\dotsb"; break;}
1345   // ----------------------------------------  linesz ??
1346
1347    if (size(cfmt))                            // parse the coefficient
1348    {
1349     monomt = cfmt;                   // (already a good choice for integers)
1350     msz = 3*size(cfmt);
1351
1352     if(realT) { monomt,msz = parsr(cfmt);}
1353     if (galT) { monomt,msz = parsg(cfmt);}
1354     b = find(cfmt,")/(");                     // look if fraction
1355     b2 = find(cfmt,"/");
1356     if (b) {b++;}
1357     n = size(cfmt);
[917fb5]1358     if (!(parT) and  !(realT) and !(galT))
1359     { if( !(b2) or defined(TeXnofrac))
[ae4196]1360       { monomt = cfmt; msz = 3*size(monomt);}
1361       else
1362       { monomt = "\\frac{" + cfmt[1,b2-1] + "}{" + cfmt[b2+1,n-b2] + "}";
1363          if (n-2*b2>0) {msz = C*(n-b2);}
1364          else {msz = C*b2;}
1365       }
1366     }
1367     if (parT and !(galT))
1368     { monomt,msz = parsp(cfmt,b);}
1369    }
1370
1371// -- now parse the monom
1372    if (monom <> 1)
[917fb5]1373    { i = 1;
[ae4196]1374      if(short)
1375      { while(s[i]<>"!")
[917fb5]1376        { monomt = monomt + s[i]; i++;
[ae4196]1377          b = i;
1378          msz = msz + 3; // it was a single lettered var
1379          while(s[i]!="!" and s[i]>="0" and s[i]<="9"){i++;}
1380          if (i-b)
1381          { monomt = monomt + "^{" + s[b,i-b] + "}";
1382            msz = msz + 2*(i-b);
1383          }
1384        }
1385      }
1386      else          //  not short
1387      { t,i = parselong(s);
1388        monomt = monomt + t;
1389        msz = msz + i;
1390      }
1391    }
[917fb5]1392
[ae4196]1393
1394
1395   msz = msz + 6*size(sign);   // Wieso mal 6 ??
1396//  string(msz) + "  ," + string(linesz) + "  " + string(cfm*monom);
1397
1398   if (TeXwidth > 10 and (linesz + msz > 3*TeXwidth) and linesz)
[917fb5]1399   { pt = pt + lnbreak + bg;
1400     linesz = msz;
[ae4196]1401   }
[917fb5]1402   else { linesz = linesz + msz; }  // 3 for sign
[ae4196]1403    pt = pt + sign + monomt;
1404   sign = "+";
1405   monomt = "";
1406  }
1407
1408  if (k<size(matrix(I))){ pt = pt + sep;}
1409 }
1410
1411  if (TeXwidth==0 and typeof(p)=="poly"){ pt = pt + "= 0";}
1412  if (not(defined(NoDollars))) { pt = "$"+pt+"$";}
1413
1414  if (size(fname))
1415  { i=1;
1416    while (fname[i]==">"){i++;}
1417    fname = fname[i,size(fname)-i+1];
1418
1419    if (size(fname)>=4)         // check if filename is ending with ".tex"
1420    { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; }
1421    }
1422    else {fname = fname + ".tex";}
1423    write(fname,pt);
1424   }
1425  else {return(pt);}
[917fb5]1426}
[ae4196]1427example
1428{ "EXAMPLE:"; echo =2;
1429  ring r0=0,(x,y,z),dp;
1430  poly f = -1x^2 + 2;
1431  texpoly("",f);
1432  texpoly("",2x2y23z);
[917fb5]1433
[ae4196]1434
1435  ring rr= real,(x,y),dp;
1436
1437  ring r7= 7,(x,y,z),dp;
1438  poly f = 2x2y23z;
1439  texpoly("",f);
1440  ring rab =(0,a,b),(x,y,z),dp;
1441  poly f = (-2a2 +b3 -2)/a * x2y4z5 + (a2+1)*x + a+1;
1442  f;
1443  texpoly("",f);
[917fb5]1444}
[ae4196]1445
[651b46]1446static proc parsp(string cfmt, int b)
[ae4196]1447{ string mt, nom,denom;
1448  int fl1,fl2,sz1,sz2,msz;
1449
1450  if (!(b))
1451  { mt,fl1 = parst(cfmt,0); msz = size(cfmt)-2;
1452    if (fl1) { mt = "(" + mt + ")"; msz = msz +1; }
1453  }
1454  else
1455  { nom,fl1 = parst(cfmt[1,b-1],1);
1456    denom,fl2 = parst(cfmt[b+1,size(cfmt)-b],1);
1457    if (defined(TeXnofrac))
1458    { if(fl1) { nom = "(" + nom + ")"; sz1++;}
1459      if(fl2) {denom = "(" + denom + ")"; sz2++;}
1460      mt = nom+ "/"+ denom; msz = sz1+sz2 +1;
1461    }
1462    else
1463    { mt = "\\frac{" + nom + "}{" + denom + "}";
1464      if (sz1-sz2) { msz = 5*sz1;}
1465      else {msz = 5*sz2;}
1466    }
1467   }
1468  return(mt,msz);
1469}
1470example
1471{"EXAMPLE:"; echo =2;
1472  ring r=(0,a,b),x,dp;
1473  int i;
1474  poly f = (a2b12 + 23a2 -b13-1)/(a2+2b -1);
1475  f;
1476  string s;
1477  s= string(f);
1478  i = find(s,")/(");
1479  parsp(s,i);
1480}
1481
[651b46]1482static proc parst(string s,int sec)                // parse parameter
[ae4196]1483// sec parameter to see if in parsp a fraction follows
1484{ int i,j =1,-1;
[917fb5]1485  int b,k,jj,mz;                         // begin and end
[ae4196]1486  int saveshort=short;
1487            string t,c,vn,nom,denom,sg;
[6a7528]1488  if (s[1]=="(") { s = s[2,size(s)-2]; }
1489  s = s + "!";
[ae4196]1490
1491  if(defined(TeXreplace)){ short =0;}   // only then replacing works correctly
1492  if (short)
1493  { while(s[i]<>"!")
1494    { b=i; j++;
1495      while(s[i]>="0" and s[i]<="9" or (s[i]=="+" or s[i]=="-") and s[i]!="!")
[6a7528]1496      {i++;}     // scan the number
[ae4196]1497        t =s[b,i-b];
1498    //  if (t=="-1" and s[i]!="!" and s[i]!="-" and s[i]!="+"){t = "-";}
1499      if (t=="-1" and (s[i]<="0" or s[i]>="9") and s[i]!= "/" and s[i]!="!")
1500       {
[6a7528]1501     t = "-";}
1502      if (s[i]=="/")
[ae4196]1503      { i++;
1504        sg = "";
1505        if (t[1]=="+" or t[1]=="-")
1506        { nom = t[2,size(t)-1];
1507          sg = t[1];
1508        }
1509        else { nom = t;}
[6a7528]1510        b =i;
[ae4196]1511        while(s[i]>="0" and s[i]<="9") {i++;}
1512        denom = s[b,i-b];
1513        if (!(sec) and (!(defined(TeXaligned))))
1514        { t = sg + "\\frac{" + nom + "}{" + denom + "}";}
1515        else
1516        { t = sg + "(" + nom + "/" + denom + ")";
1517        }
[6a7528]1518      }
[ae4196]1519      c = c + t;
1520      if(s[i]!="!"){c = c + s[i]; i++;}      // the parameter
1521      b=i;
1522      while(s[i]>="0" and s[i]<="9")
1523      {i++;}  //the exponent
1524     if(i-b){ c = c + "^{" + s[b,i-b]+"}";}
1525     }
1526   }
1527   else                         // if not short ....
[6a7528]1528   { while (s[i] <> "!")
[ae4196]1529     { b=i; j++;
1530       while(s[i]=="-" or s[i]=="+" or (s[i]>="0" and s[i]<="9")){i++;}
1531       t = s[b,i-b];
1532       if (t=="-1" and s[i]=="*" ) {t="-";}
[6a7528]1533      if (s[i]=="/")
[ae4196]1534      { i++;
1535        sg = "";
1536        if (t[1]=="+" or t[1]=="-")
1537        { nom = t[2,size(t)-1];
1538          sg = t[1];
1539        }
1540        else { nom = t;}
[6a7528]1541        b =i;
[ae4196]1542        while(s[i]>="0" and s[i]<="9") {i++;}
1543        denom = s[b,i-b];
1544        if (!(sec) and (!(defined(TeXaligned))))
1545        { t = sg + "\\frac{" + nom + "}{" + denom + "}";}
1546        else
1547        { t = sg + "(" + nom + "/" + denom + ")";
1548        }
[6a7528]1549      }
1550       c = c+t; t="";
1551       if (s[i]=="*"){i++;}
[ae4196]1552       b=i;
1553       while(s[i]!="+" and s[i]!="-" and s[i]!="!")  //pass a monom
[6a7528]1554       { // start with letters
[ae4196]1555        // alternativ:
1556        while((s[i]>="a" and s[i]<="z") or (s[i]>="A" and s[i]<="Z")){i++;}
[6a7528]1557             k = i-b;
[ae4196]1558        vn = s[b,k];
1559        if (defined(TeXreplace))
[6a7528]1560        { for (jj=1; jj<= size(TeXreplace);jj++)
1561         { if (vn == TeXreplace[jj][1])
[ae4196]1562           {vn = TeXreplace[jj][2]; k=1;
[6a7528]1563             if (s[i]=="*") {vn = vn + " ";}
[ae4196]1564            break;} //suppose replacing by a single sign
1565         }
1566        }
1567        t = t + vn;
1568        mz = mz + 10*k;
1569        if (s[i]=="_"  or s[i]=="(") { i++;}    // the index is coming
1570        b = i;
1571        while(s[i]>="0" and s[i]<="9"){ i++;}
1572        k = i-b;
1573        if (k){ t = t + "_{" +s[b,k] + "}";}
1574        if(s[i]==")") {i++;}
1575            if (s[i]=="^")
1576        { i++; b = i;
1577          while(s[i]>="0" and s[i]<="9"){ i++;} // for neg. expon.
1578          if (b-i) { t = t + "^{" + s[b,i-b] + "}";}
1579        }
1580          if (i-b > k) { mz = mz + 5*(i-b);}
1581        else {mz = mz + 5*k;}
1582       if (s[i]=="*"){i++;}
1583       b=i;
1584        }
1585      c =c+t;
1586      }
1587   }
1588  short = saveshort;
1589  return(c,j);
1590}
1591example
1592{ "EXAMPLE:"; echo =2;
1593  ring r=(0,a,b),x,dp;
1594  poly f = (a2b12 + 23a2 -b13-1);
1595  f;
1596  parst(string(f));
[6a7528]1597
[ae4196]1598  f =(-a +4b2 -2);
1599  f;
1600  parst(string(f));
[6a7528]1601
[ae4196]1602  f = a23;
1603  f;
1604  parst(string(f));
1605  f = 2a12b3 -4ab15 +2a4b12 -2;
1606  short =0;
1607  f;
1608  parst(string(f));
1609   ring r2=(0,a1,b1),x,dp;
1610  poly f = 2*a1^12*b1^3 -4*a1*b1^15 +2*a1^4*b1^12 -2;
1611  f;
1612  parst(string(f));
1613}
1614
1615
[651b46]1616static proc parselong(string s)
[6a7528]1617{
[ae4196]1618  int i,j,k,b,mz;
1619  string t,vn;              // varname
[6a7528]1620
[ae4196]1621 // "s=" + s;
[6a7528]1622  i = 1;
1623  while (s[i] <> "!")
1624  { b=i;
1625
[ae4196]1626// -- scan now the letter ...
1627
1628  //  while(s[i]!="!" and )
1629
1630// alternativ:
1631 while((s[i]>="a" and s[i]<="z") or (s[i]>="A" and s[i]<="Z"))
1632 { i++;}
1633 // s[i]; i;
[6a7528]1634   k = i-b;
[ae4196]1635   vn = s[b,k];
1636
1637   if (defined(TeXreplace))
[6a7528]1638   { for (j=1; j<= size(TeXreplace);j++)
1639     { if (vn == TeXreplace[j][1])
[ae4196]1640       {vn = TeXreplace[j][2]; k=1;
[6a7528]1641        if (s[i]=="*") {vn = vn + " ";}
[ae4196]1642         break;} //suppose replacing by a single sign
1643     }
1644   }
1645   t = t + vn;
1646   mz = mz + 10*k;
1647   if (s[i]=="_"  or s[i]=="(") { i++;}    // the index is coming
1648   b = i;
1649   while(s[i]>="0" and s[i]<="9"){ i++;}
1650   j = i-b;
1651   if (j){ t = t + "_{" +s[b,j] + "}";}
1652   if(s[i]==")") {i++;}
1653   if (s[i]=="^")
1654   { i++; b = i;
1655     while(s[i]>="0" and s[i]<="9" or s[i]=="-")
1656     { i++;}  // for neg. expon.
1657     if (b-i) { t = t + "^{" + s[b,i-b] + "}";}
1658   }
1659   if (i-b > j) { mz = mz + 5*(i-b);}
1660   else {mz = mz + 5*j;}
1661   if (s[i]=="*"){i++;}
1662  }
1663  return(t,mz);
1664}
1665example
[6a7528]1666{ "EXAMPLE:"; echo =2;
[ae4196]1667  ring r =(49,a),x,dp;
1668  number f = a13;
1669  parsg(string(f));
1670  list TeXreplace; export TeXreplace;
1671  TeXreplace[1] = list("b","\\beta");
1672  TeXreplace[2] = list("a","\\alpha");
[6a7528]1673  TeXreplace[3] = list("c","\\gamma");
[ae4196]1674  parselong(string(f)+"!");
1675}
1676///////////////////////////////////////////////////////////////////////////////
1677
[afcf7d]1678
1679proc tktex (def d)
1680{
1681 // calls appropriate proc from latex lib
1682
1683 string typeofd =typeof(d);
1684 if (typeofd=="int" or typeofd=="string" or typeofd=="resolution" or typeofd=="map" or typeofd =="list"){ return(d);}
1685
1686 if (typeofd=="intvec" or typeofd == "intmat" or typeofd =="vector" or
1687     typeofd=="matrix" or typeofd == "module")   { return(texobj("",d));}
1688 if (typeofd=="ring" or typeofd=="qring") { return(texring("",d));}
1689 if (typeofd =="ideal") { return(texobj("",d));}
1690 if (typeofd=="number" or typeofd=="poly" or typeofd=="ideal")
1691                                                 { return(texpoly("",d));}
1692 if (typeofd=="link") {return(d);}
1693
1694}
[ae4196]1695/////////////////////////////  PART0 //////////////////////////////////////////
1696
[651b46]1697static proc part0(string fname)
[ae4196]1698{
1699 int texdemopart =0;
1700 export texdemopart;
1701
1702
1703// Singular script for generating tldemo.tex
1704
1705 // int TeXwidth =-1;
1706 // export TeXwidth;
1707 // if(defined(NoDollars)) {kill NoDollars;}
1708 //echo =2;
1709
[651b46]1710  proc randompoly(int n,int cm,int em)
[ae4196]1711   {
1712    int i,j,k;
1713    number nm,nom,denom;
1714    poly f,g;
1715    int nv,np=nvars(basering),npars(basering);
[6a7528]1716
[ae4196]1717    for (i=1; i<=n; i++)
[6a7528]1718    {
1719      if (np)
1720      {
[ae4196]1721         nm=random(-cm,cm);
1722         for (j=1;j<=np;j++)
1723         { nm=nm*par(j)^random(-em/ 2,em/ 2);}
1724         nom = nom + nm;
[651b46]1725
[ae4196]1726         nm=random(-cm,cm);
1727         for (j=1;j<=np;j++)
1728         { nm=nm*par(j)^random(-em/ 2,em/ 2);}
1729         denom = denom + nm;
1730       if (denom!=0) {g = nom*denom^-1;}
1731       else {g = 0;}
1732      }
1733      else
1734      { g = random(-cm,cm);
1735      }
1736      for (j=1; j<=nv; j++)
1737      { g=g*var(j)^random(0,em);}
1738      f = f + g;
1739     }
1740    return(f);
1741   }
1742
[d6cc54]1743  if(system("with","Namespaces")) { exportto(Current, randompoly); }
1744  else { export randompoly; }
[ae4196]1745
1746  proc randomintv(int n, int m)
1747  {
1748   int i;
[6a7528]1749
[ae4196]1750   for(i=1; i<=n; i++)
[6a7528]1751   {
[ae4196]1752    v[i];
1753   }
1754  }
1755
1756
1757  proc splt(string s)
1758  { int n,i= size(s),1;
1759    int p;
1760    string t;
[6a7528]1761
[ae4196]1762    while(n-i+1 >pagewidth)
1763    { p = find(s,newline,i);
1764      if (p and (p-i)<pagewidth)
1765      { t = t + s[i,p];
1766        i = i + p;
1767      }
1768      else
1769      {
1770       t = t+ s[i,pagewidth] + newline;
1771       i = i + pagewidth;
1772      }
1773    }
1774    if (n) { t= t + s[i,n-i+1];}
1775    return(t);
1776  }
1777
[c67136]1778 if(system("with","Namespaces")) { exportto(Current,splt); }
1779 else { export splt; }
[917fb5]1780
[ae4196]1781// string fname = "texlibdemo.tex";
1782 string nl = newline;
1783 string nl2 = newline + newline;
1784 string lb = "\\\\";
1785 string bv = "\\begin{verbatim}" + newline ;
1786 string ev = "\\end{verbatim}" ;
1787 export nl,nl2,lb,bv,ev;  //fname
1788
1789 "generating part0 of " + fname  + nl;
1790
1791 opentex(fname);
1792
1793
1794write(fname,"\\newcommand{\\Line}{\\rule{\\textwidth}{0.25mm}\\\\[5mm]}");
1795
1796   write(fname,"\\centerline{\\large \\bf Demo file for latex.lib 1.0.0}");
1797   write(fname,"\\centerline{\\bf Christian Gorzel}");
1798   write(fname,"\\vspace{1cm}");
1799
1800
1801//--
1802
1803 write(fname,"\\section{Introduction}");
[651b46]1804 write(fname,"The procedures in \\verb|latex.lib| translate the output of
1805 Singular in \\LaTeX \\ text.
1806 Most of the examples in this document are generated
[917fb5]1807 randomly by Singular itself and passed through the procs from
1808 \\verb|latex.lib|. Consequently,
[651b46]1809 every document does not show merely how the \\verb|latex.lib| works
[ae4196]1810 but looks differently in large parts.");
1811 write(fname,bv +
1812"
[651b46]1813LIBRARY: latex.lib    PROCEDURES FOR TYPESET OF SINGULAROBJECTS IN LATEX2E
[ae4196]1814
[651b46]1815
1816 closetex(fnm);       writes closing line for TeX-document
1817 opentex(fnm);        writes header for TeX-file fnm
1818 tex(fnm);            calls LaTeX2e for TeX-file fnm
1819 texdemo([n]);        produces a file explaining the features of this lib
1820 texfactorize(fnm,f); creates string in TeX-Symbolformat for factors of poly f
1821 texmap(fnm,m,r1,r2); creates string in TeX-Symbolformat for map m:r1->r2
1822 texname(fnm,s);      creates string in TeX-Symbolformat for identifier
[ae4196]1823 texobj(l);           creates string in TeX-Symbolformat for any (basic) type
1824 texpoly(f,n[,l]);    creates string in TeX-Symbolformat for poly
[651b46]1825 texproc(fnm,p);      creates string in TeX-Symbolformat of text from proc p
1826 texring(fnm,r[,l]);  creates string in TeX-Symbolformat for ring/qring
1827 rmx(s);              removes .aux and .log files of TeXfile s
1828 xdvi(s);             calls xdvi for dvi-file s
[ae4196]1829         (parameters in square brackets [] are optional)
[6a7528]1830
1831                      Global Variables:
[ae4196]1832  TeXwidth, TeXnofrac, TeXbrack, TeXproj, TeXaligned, TeXreplace, NoDollars
[6a7528]1833               are used to control the typesetting
[651b46]1834    Call example texdemo; to become familiar with the features of latex.lib
[ae4196]1835
1836" +
1837ev);
1838
[917fb5]1839write(fname,"A flag means in the following that a variable with the indicated
[ae4196]1840name has to be defined. Usually it is from type \\verb|int|.");
1841
1842
1843write(fname,
1844bv +
1845"
1846  TeXwidth      : int: -1,0,1..9, >9  controls the breaking of long polynomials
1847  TeXnofrac     : (int) flag,  write 1/2 instead of \\frac{1}{2}
1848  TeXbrack      : string: possible values {,(,<,|, \"\"
1849                          controls brackets around ideals
1850  TeXproj       : (int) flag, write : instead of , in intvecs
1851  TeXaligned    : (int) flag, write mappings (and ideals) aligned
1852  TeXreplace    : list, entries twoelemented list for replacing symbols
1853  NoDollars     : (int) flag, suppresses surrounding \\$ signs
[917fb5]1854
[ae4196]1855" +
1856ev);
1857
1858//% The procs and
1859//% the global variables
1860
1861//----------------------- opentex -----------------------------
1862   write(fname,"\\section{Opening a \\LaTeX\\ file}");
[6a7528]1863   write(fname,"All starts by defining a variable " + nl
[651b46]1864                + bv + "> string fname = \"" + fname + "\";" + nl +
[ae4196]1865                "> texopen(fname);" + ev + nl);
1866 write(fname,"This variable \\verb|fname| has to given as first argument to
[651b46]1867 all procedures in \\verb|latex.lib|");
[6a7528]1868
[ae4196]1869 //% opentex, defaulted to latex, possibly extension are ... and
[6a7528]1870 //% ``own''
[ae4196]1871
1872
1873pagewidth = 65;
[651b46]1874int TeXwidth = 100; export TeXwidth;
[ae4196]1875 "part 0 generated " + nl;
1876} //part0
1877
1878
1879/////////////////////////////  PART1 //////////////////////////////////////////
1880
1881
[651b46]1882static proc part1(string fname)
[ae4196]1883{ int st = defined(texdemopart);
1884
1885  if (not(st) or texdemopart>=1)
1886  { print(" Call part0 first");
1887    return();
1888  }
1889  else { texdemopart=1; }
[6a7528]1890
[ae4196]1891"Continuing part1 of " + fname + nl;
1892
1893write(fname,
1894"\\section{Rings and polynomials}"+nl2);
1895
1896// -1a------ a ring in char 0, short varnames and poly. ordering ----------
1897write(fname,
1898" A ring in characteristic 0 with short variablenames and polynomial ordering.
1899" +nl);
[d6cc54]1900 ring r0=0,(x,y,z),dp;
1901 if(system("with","Namespaces")) { exportto(Current, r0); }
1902 else { export r0; }
[6a7528]1903 poly g = -x2y +2y13z +1;           export g;
[ae4196]1904 poly f = randompoly(5,25,25); f;      export f;
1905write(fname,
1906bv +
1907"> ring r0=0,(x,y,z),dp;                       texring(fname,r0);
1908> poly g = -x2y +2y13z +1; g;                 texpoly(fname,g);" +nl +
[917fb5]1909 string(g) + nl +
[ae4196]1910"> poly f = randompoly(5,25,25); f;            texpoly(fname,f);" +nl +
[6a7528]1911 splt(string(f)) + nl2 +
1912ev
1913);
[ae4196]1914  texring(fname,r0);              write(fname,nl2);
[6a7528]1915  texpoly(fname,g);              write(fname,nl2);
[ae4196]1916  texpoly(fname,f);              write(fname,nl2);
1917// write(fname,"\\Line");
1918
1919// -1b------ stil in the same ring, the poly with rational coefs --------
1920write(fname,
1921" The polynomial with rational coefficients.
1922" +nl);
1923 f = f/280;
1924write(fname,
1925bv +
[917fb5]1926"> f = f/280;
[ae4196]1927> texpoly(fname,f);" +nl +
[917fb5]1928 splt(string(f)) + nl2 +
[ae4196]1929ev
[6a7528]1930);
[ae4196]1931  texpoly(fname,f);              write(fname,nl2);
1932write(fname,"\\Line");
1933// -2-------- a ring in char 7, indexed varnames and series ordering ----------
1934write(fname,
1935" A ring in characteristic 7 with indexed variablenames and local ordering.
1936" +nl);
[d6cc54]1937 ring r1=7,(x1,x2,x3,x4),Ds;
1938 if(system("with","Namespaces")) { exportto(Current, r1); }
1939 else { export r1; }
[917fb5]1940 poly g = -2*x1 +x4 -1;
[ae4196]1941 poly f = randompoly(5,25,25); f; export f;
1942write(fname,
1943bv +
1944"> ring r1=7,(x1,x2,x3,x4),Ds;                 texring(fname,r1);
1945> poly g =  -2*x1 +x4 -1; g;                  texpoly(fname,g);" +nl +
[917fb5]1946 string(g) + nl +
[ae4196]1947"> poly f = randompoly(5,25,25); f;            texpoly(fname,f);" +nl +
[917fb5]1948 splt(string(f)) + nl2 +
[ae4196]1949ev
[917fb5]1950);
[ae4196]1951  texring(fname,r1);             write(fname,lb);
[917fb5]1952  texpoly(fname,g);              write(fname,lb);
[ae4196]1953  texpoly(fname,f);              write(fname,lb);
1954write(fname,"\\Line");
1955
1956// -3-------- a ring in char 0, indexed varnames and mixed ordering ----------
1957write(fname,
1958" A ring in characteristic 0 with indexed variablenames and mixed ordering.
1959" +nl);
1960 ring r2=0,(x(1..5),y(1..2)),(ds(5),dp(2));
[917fb5]1961 poly g = -y(1)*x(5) +y(1)*x(2); g;
[ae4196]1962 poly f = randompoly(5,25,25); f;
1963write(fname,
1964bv +
1965"> ring r2=0,(x(1..5),y(1..2)),(ds(5),dp(2));  texring(fname,r2);
1966> poly g = -y(1)*x(5) +y(1)*x(2); g;          texpoly(fname,g);"  +nl +
[917fb5]1967 string(g) + nl +
[ae4196]1968"> poly f = randompoly(5,25,25); f;            texpoly(fname,f);" +nl +
[917fb5]1969 splt(string(f)) + nl2 +
1970ev
1971);
[ae4196]1972  texring(fname,r2);             write(fname,lb);
[917fb5]1973  texpoly(fname,g);              write(fname,lb);
[ae4196]1974  texpoly(fname,f);              write(fname,lb);
1975write(fname,"\\Line");
1976
1977// -4-------- a ring in char 0, indexed varnames and weighted ordering ------
1978write(fname,
1979" A ring in characteristic 0 with indexed variablenames and weighted  ordering.
1980" +nl);
[d6cc54]1981 ring r3=0,(x_1,x_2,x_3),wp(3,2,1);
1982 if(system("with","Namespaces")) { exportto(Current, r3); }
1983 else { export r3; }
[917fb5]1984 poly g = -x_1*x_2 + 2*x_2*x_3 + x_1*x_3; g;
[ae4196]1985 poly f = randompoly(5,25,25); f;            export f;
1986write(fname,
1987bv +
1988"> ring r3=0,(x_1,x_2,x_3),wp(3,2,1);          texring(fname,r3);
1989> poly g = -x_1*x_2 + 2*x_2*x_3 + x_1*x_3; g; texpoly(fname,g);"  +nl +
[917fb5]1990  string(g) + nl +
[ae4196]1991"> poly f = randompoly(5,25,25); f;            texpoly(fname,f);" +nl +
[917fb5]1992 splt(string(f)) + nl2 +
[ae4196]1993ev
[917fb5]1994);
[ae4196]1995  texring(fname,r3);             write(fname,lb);
[917fb5]1996  texpoly(fname,g);              write(fname,lb);
[ae4196]1997  texpoly(fname,f);              write(fname,lb);
1998write(fname,"\\Line");
1999
2000// -5-------- a ring with real coeff and matrix ordering -------------------
2001write(fname,
2002" A ring with real coefficients and matrix ordering.
2003" +nl);
[917fb5]2004 ring rr =real,(x,y),M(1,2,3,4);
2005 poly g = -1.2e-10*x + y +1;
[ae4196]2006 poly f = randompoly(5,25,25); f;
2007write(fname,
2008bv +
2009"> ring rr =real,(x,y),M(1,2,3,4);             texring(fname,rr);
2010> poly g = -1.2e-10*x + y +1; g;              texpoly(fname,g);" +nl +
[917fb5]2011 string(g) + nl +
[ae4196]2012"> poly f = randompoly(5,25,25); f;            texpoly(fname,f);" +nl +
[917fb5]2013 splt(string(f)) + nl2 +
[ae4196]2014ev
[917fb5]2015);
[ae4196]2016  texring(fname,rr);             write(fname,lb);
[917fb5]2017  texpoly(fname,g);              write(fname,lb);
[ae4196]2018  texpoly(fname,f);              write(fname,lb);
2019write(fname,"\\Line");
2020
2021// -6a-------- a ring in char 0, and indexed parameters --------- ----------
2022write(fname,
2023" A ring in characteristic 0 and indexed parameters.
2024" +nl);
[917fb5]2025 ring r0t=(0,s,t),(x,y),dp;
[d6cc54]2026 if(system("with","Namespaces")) { exportto(Current, r0t); }
2027 else { export r0t; }
[917fb5]2028 poly g = 8*(-s+2t)/(st+t3)*x + t2*x -1; g;
[ae4196]2029 poly f = randompoly(5,25,25); f;  export f;
2030write(fname,
2031bv +
2032"> ring r0t=(0,s,t),(x,y),dp;                  texring(fname,r0t);
2033> poly g = 8*(-s+2t)/(st+t3)*x + t2*x -1; g;  texpoly(fname,g);" +nl +
[917fb5]2034 string(g) + nl +
[ae4196]2035"> poly f = randompoly(5,25,25); f;            texpoly(fname,f);" +nl +
[917fb5]2036 splt(string(f)) + nl2 +
[ae4196]2037ev
[917fb5]2038);
[ae4196]2039  texring(fname,r0t);            write(fname,lb);
[917fb5]2040  texpoly(fname,g);              write(fname,lb);
[ae4196]2041  texpoly(fname,f);              write(fname,lb);
2042write(fname,"\\Line");
2043
2044
[651b46]2045// -6b------- a ring in char 11003, and indexed parameters --------- ----------
[ae4196]2046write(fname,
2047" A ring in characteristic 11 and indexed parameters.
2048" +nl);
[917fb5]2049 ring rt=(11003,t1,t2,t3),(X,Y),dp;
2050 poly g = 8*(-t1+t2)/(t1+t3)*X + t2*Y -1; g;
[ae4196]2051 poly f = randompoly(5,25,25); f;
2052write(fname,
2053bv +
[651b46]2054"> ring rt=(11003,t1,t2,t3),(X,Y),dp;             texring(fname,rt);
[ae4196]2055> poly g = 8*(-t1+t2)/(t1+t3)*X + t2*Y -1; g; texpoly(fname,g);" +nl +
[917fb5]2056 string(g) + nl +
[ae4196]2057"> poly f = randompoly(5,25,25); f;            texpoly(fname,f);" +nl +
[917fb5]2058 splt(string(f)) + nl2 +
[ae4196]2059ev
[917fb5]2060);
[ae4196]2061  texring(fname,rt);             write(fname,lb);
[917fb5]2062  texpoly(fname,g);              write(fname,lb);
[ae4196]2063  texpoly(fname,f);              write(fname,lb);
2064write(fname,"\\Line");
2065
2066// -7-------- a ring over an algebraic extension in char 7 ---------------
2067write(fname,
2068" A ring over an algebraic extension in char 7.
2069" +nl);
[917fb5]2070 ring ralg = (7,a),x,dp;
2071 minpoly = a2-a+3;
2072 poly g = -(2a13 +a)*x2 + a2*x -a +1; g;
[ae4196]2073 poly f = randompoly(5,25,25); f;
2074write(fname,
2075bv +
[917fb5]2076"> ring ralg = (7,a),x,dp;
[ae4196]2077> minpoly = a2-a+3;                           texring(fname,ralg);
2078> poly g = -(2a13 +a)*x2 + a2*x -a +1; g;    texpoly(fname,g);" +nl +
[917fb5]2079 string(g) + nl +
[ae4196]2080"> poly f = randompoly(5,25,25); f;            texpoly(fname,f);" +nl +
[917fb5]2081 splt(string(f)) + nl2 +
[ae4196]2082ev
[917fb5]2083);
[ae4196]2084  texring(fname,ralg);           write(fname,lb);
[917fb5]2085  texpoly(fname,g);              write(fname,lb);
[ae4196]2086  texpoly(fname,f);              write(fname,lb);
2087write(fname,"\\Line");
2088
2089// -8-------- the same ring a in 7 ralg, defined with gftables -- F_49 -------
2090write(fname,
[917fb5]2091" A ring defined with \\verb|gftables|, the same as \\verb|ralg| before, but
[ae4196]2092with primitive element in the Galoisfield $\\F_{49}$." +nl);
[d6cc54]2093 ring r49 =(49,a),x,dp;
2094 if(system("with","Namespaces")) { exportto(Current, r49); }
2095 else { export r49; }
[917fb5]2096 poly g = -(2a13 +a)*x2 + a2*x -a +1; g;  export g;
[ae4196]2097 poly f = randompoly(5,25,25); f;
2098write(fname,
2099bv +
2100"> ring r49 =(49,a),x,dp;                     texring(fname,r49);
2101> poly g = -(2a13 +a)*x2 + a2*x -a +1; g;    texpoly(fname,g);" +nl +
[917fb5]2102 string(g) + nl +
[ae4196]2103"> poly f = randompoly(5,25,25); f;           texpoly(fname,f);" +nl +
[917fb5]2104 splt(string(f)) + nl2 +
[ae4196]2105ev
[917fb5]2106);
[ae4196]2107  texring(fname,r49);            write(fname,lb);
[917fb5]2108  texpoly(fname,g);              write(fname,lb);
[ae4196]2109  texpoly(fname,f);              write(fname,lb);
2110write(fname,"\\Line");
2111
2112// -9-------- a ring over the Gaussian numbers  ----------
2113write(fname,
2114" A ring over the Gaussian numbers.
2115" +nl);
2116 ring ri=(0,i),(x,y,z),ls;
[917fb5]2117 minpoly = i2 +1;
2118 poly g = -(i+1)*x +2i2y2 +i +x; g;
[ae4196]2119 poly f = randompoly(5,25,25); f;
2120write(fname,
2121bv +
2122"> ring ri=(0,i),(x,y,z),ls;
2123> minpoly = i2 +1;                            texring(fname,ri);
2124> poly g = -(i+1)*x +2i2y2 +i +x; g;          texpoly(fname,g);" +nl +
[917fb5]2125 string(g) + nl +
[ae4196]2126"> poly f = randompoly(5,25,25); f;            texpoly(fname,f);" +nl +
[917fb5]2127 splt(string(f)) + nl2 +
[ae4196]2128ev
[917fb5]2129);
[ae4196]2130  texring(fname,ri);              write(fname,lb);
[917fb5]2131  texpoly(fname,g);              write(fname,lb);
[ae4196]2132  texpoly(fname,f);              write(fname,lb);
2133write(fname,"\\Line");
2134
2135// -10--------- a quotient ring performed from  ----------
2136write(fname,
[651b46]2137" A quotient ring performed from \\verb|r0|
[ae4196]2138" +nl);
2139 setring r0;
[917fb5]2140 ideal I = x2-y,y+z2, xy;
[ae4196]2141 I = std(I);
2142string sI = string(I);
2143 qring qr = I;
2144write(fname,
2145bv +
2146"> setring r0;
2147> ideal I = x2-y,y+z2, xy;
2148> I = std(I);
2149> string(I);" + nl +
2150splt(sI) + nl +
[917fb5]2151"> qring qr = I;                   texring(fname,qr);" +
[ae4196]2152ev
[917fb5]2153);
[ae4196]2154  texring(fname,qr);              write(fname,lb);
2155
2156write(fname,"\\Line");
2157
2158// ------------------------- Features for rings
2159
2160write(fname,"\\subsection{Features for rings}");
2161
2162write(fname,"The printed form of the ring may be modified in a great variety");
2163
2164// changing the brackets
2165
[917fb5]2166write(fname,"If the displayed  and defaulted brackets for the ring are not
[ae4196]2167the rigth one,
2168correct brackets my be passed over to \\verb|texring|",nl,
2169"Predefined and accepted brackets are \\verb|\"\\{\"|,\\verb|\"\\{\"|,
2170\\verb|\"\\{\\{\"|,\\verb|\"[\"|,\\verb|\"[[\"|,\\verb|\"<\"|,
2171\\verb|\"<<\"|.");
2172
2173
2174write(fname,
2175bv +
[917fb5]2176"> texring(fname,rr,\"{{\");" + nl +
[ae4196]2177ev
[917fb5]2178);
[ae4196]2179
2180texring(fname,rr,"{{");
2181
2182write(fname,
2183bv +
[917fb5]2184"> texring(fname,r2,\"[\");" + nl +
[ae4196]2185ev
[917fb5]2186);
[ae4196]2187
2188texring(fname,r2,"[");
2189
2190write(fname,nl2);
2191
[917fb5]2192write(fname,nl2,"The brackets around the ideal in a quotientring can be
2193changed  with the global variable \\verb|TeXbrack| (see the section
[ae4196]2194{\\tt ideal}).",nl);
2195
2196
2197write(fname,
2198bv +
2199"> string TeXbrack = \"<\";
[917fb5]2200> texring(fname,qr);
[ae4196]2201> kill TeXbrack;" + nl +
2202ev
[917fb5]2203);
[ae4196]2204
2205string TeXbrack = "<"; export TeXbrack;
2206texring(fname,qr);
2207kill TeXbrack;
2208
2209write(fname,nl2,"\\Line");
2210
2211// changing the coeffield
2212// -------------------------------------------------
2213write(fname,"If the coefficientfield in charcteristic 0 should be written as
2214$\\C$  instead of $\\Q$ use this as additonal argument.",nl);
2215
2216
2217write(fname,
2218bv +
[917fb5]2219"> texring(fname,r3,\"\\\\C\");" + nl +
[ae4196]2220ev
[917fb5]2221);
[ae4196]2222
2223texring(fname,r3,"\\C");
2224write(fname,nl2);
2225
2226write(fname,nl2, "naechster abschnitt stimmt nicht"+lb,nl2);
2227
[917fb5]2228write(fname,"Predefined and accepted values here are
[ae4196]2229\\verb|\"\\\\C\"|, \\verb|\"\\\\R\"|,
2230 \\verb|\"\\\\C\"|, \\verb|\"k\"|, \\verb|\"K\"|, \\verb|\"R\"|.");
[917fb5]2231write(fname,"The latter are useful to print a ring whose coefficientfield is
[ae4196]2232defined by an algebraic extension. Now the parameters will omitted completely.
2233");
[917fb5]2234write(fname,"The user may specify then the field in more detail."+lb,nl2);
[ae4196]2235
2236write(fname,"Any correct letter in \\LaTeX \\ notation may be used to describe
[917fb5]2237the coefficientfield. If the letter is k, K or R it  forces \\verb|texring|
[ae4196]2238not to print the parameters. This will be useful for a ring described by an
2239algebraic extension",nl2);
2240
2241write(fname,
2242bv +
[917fb5]2243"> texring(fname,ralg,\"k\");" + nl +
[ae4196]2244ev
[917fb5]2245);
[ae4196]2246
2247texring(fname, ralg,"k");
[917fb5]2248
[ae4196]2249// texobj(fname,"with k = ");
[651b46]2250
2251write(fname,nl2,
2252"The algebraic extension is diplayed with the optional paramater
2253\\verb|mipo|");
2254write(fname,
2255bv +
[917fb5]2256"> texring(fname,ralg,\"mipo\");" + nl +
[651b46]2257ev
[917fb5]2258);
[651b46]2259
2260texring(fname, ralg,"mipo");
2261
2262
[ae4196]2263write(fname,nl,"\\Line");
2264// displaying only certain vars
2265
2266write(fname,"By default all variables of a ring will be typed. It is possible
2267to print only certain variables filled up with $\\ldots$ between them. Define
2268therefore an \\verb|intvec| with the marked places.");
2269
2270write(fname,
2271bv +
2272"> intvec v = 5,6;
2273> texring(fname,r2,v);
[917fb5]2274> kill v;" + nl +
[ae4196]2275ev
[917fb5]2276);
[ae4196]2277
2278intvec v = 5,6;
2279texring(fname,r2,v);
2280kill v;
2281
2282write(fname,nl2,"The first and last variable
2283will be printed always, to print only these it is sufficient to give a 1 as
2284third argument.");
2285
2286write(fname,
2287bv +
[917fb5]2288"> texring(fname,r1,1);" + nl +
[ae4196]2289ev
[917fb5]2290);
[ae4196]2291texring(fname,r1,1);
2292
2293
2294write(fname,nl2,"\\Line",nl);
2295
2296// passing over additional information
2297
[651b46]2298write(fname,"If you want to mark a ring as the invariantring under a group,
2299additional informations starting with \\verb|^| may be added.",nl2);
[ae4196]2300
2301write(fname,
2302bv +
[917fb5]2303"> texring(fname,r0,\"^G\");" + nl +
[ae4196]2304ev
[917fb5]2305);
[ae4196]2306
2307texring(fname, r0,"^G");
[917fb5]2308
2309write(fname,nl2,"All these arguments may be passed over in any order as
2310optional arguments, but it may give a rather nonsense result if too much of
[651b46]2311them  are used at the same time",nl);
[ae4196]2312
2313write(fname,
2314bv +
[917fb5]2315"> texring(fname,r3,\"\\\\R\",1,\"{{\",\"^G\");" + nl +
[ae4196]2316ev
[917fb5]2317);
[ae4196]2318
2319texring(fname, r3,"\\R",1,"<<","^G");
2320
2321write(fname,nl2);
2322
[d6cc54]2323if(system("with","Namespaces")) { exportto(Current, r0, ralg); }
2324else { export r0,ralg; }
[ae4196]2325"end part 1" + nl;
2326}
2327
2328
2329/////////////////////////////  PART2 //////////////////////////////////////////
2330
2331
[651b46]2332static proc part2(string fname)
[ae4196]2333{ int st = defined(texdemopart);
2334
2335  if (not(st) or texdemopart>=2)
2336  { print(" Call part1 first");
2337    return();
2338  }
2339  else { texdemopart=2; }
[917fb5]2340
[ae4196]2341 "Continuing Part2 of " + fname + nl;
2342
2343//-------------------- texfactorize ------------------------------
2344write(fname,"\\subsection{Factorized polynomials}");
2345
2346write(fname,"The command \\verb|texfactorize| calls internally the Singular
2347command \\verb|factorize| and returns the product of the irreducible factors.
[917fb5]2348at the present it is not possible to pass the optional arguments of
[ae4196]2349\\verb|factorize| through \\verb|texfactorize|."+lb);
2350
2351setring r0;
2352poly h = (x+1+y)^2*x3y*(2x -2y)*y12*x2*z2;
2353//h;
2354write(fname,
2355bv +
2356"> setring r0;
2357> poly h = (x+1+y)^2*x3y*(2x -2y)*y12*z2;
2358> h;
2359> " + splt(string(h)) + nl +
2360"> texfactorize(fname,h);
2361" + nl +
2362ev);
2363
2364texfactorize(fname,h);
2365
2366setring ralg;
2367poly h = (a24x5 + x3)*a2x6*(x+1)^2;
2368//h;
2369write(fname,
2370bv +
2371"> setring ralg;
2372> poly h = (a24x5 + x3)*a2x6*(x+1)^2;
2373> h;
2374> " + splt(string(h)) + nl +
2375"> texfactorize(fname,h);
2376" + nl +
2377ev);
2378
2379texfactorize(fname,h);
2380
2381
[651b46]2382//write(fname,nl2, If \\verb|texfactorize| is called by the name of the
2383// polynom, the result is the following" + lb,nl);
[ae4196]2384
2385
[651b46]2386// write(fname,nl2, "Noch nicht implemtiert" + lb,nl2);
[ae4196]2387
2388
2389//write(fname,"\\subsection{Hilbertpolynomials}");
2390
2391//--------------------- features for polynomials -----------------
2392write(fname,"\\subsection{Features for polynomials}");
2393
2394
2395write(fname,"very long variables will be set correctly too. Furthermore,
2396but we cannot demonstrate it here,
2397the Laurentpolynomials with negative exponents will be translated."+ lb);
2398
2399
2400
2401// TeXreplace
2402// ---------------------------------------------
[917fb5]2403write(fname,"The global variable \\verb|TeXreplace| must be a list
[ae4196]2404whose entries are twoelemented lists again; wherby the first entry is the
[651b46]2405word which should be replaced and second is the replacing word."  +
[917fb5]2406"This is may be applied to replace variablenames, but holds  also for texname
[651b46]2407anmd texmap" + lb +
2408"It is most useful to write the greece letters correctly. Notice that it
2409is necesarry to write
[917fb5]2410a double backslash \\verb|\\\\\ | at the beginning of
[651b46]2411a \\TeX \\ symbol." + lb);
[ae4196]2412
2413
2414// Example
2415
2416write(fname,"Usually we write $\\xi$ for the primitive element:"+ lb);
2417list TeXreplace; export TeXreplace;
2418TeXreplace[1] = list("a","\\xi");
2419setring r49;
2420
2421write(fname,
2422bv +
2423"> list TeXreplace;
2424> TeXreplace[1] = list(\"a\",\"\\\\xi\");
2425> setring r49;
2426> texpoly(fname,g);
2427" + nl +
2428ev);
2429
2430texpoly(fname,g);
2431
2432write(fname,nl2,"Let us write $\\lambda$ and $\\mu$ for deforming parameters"
2433 +lb);
2434TeXreplace[2]= list("s","\\lambda");
2435TeXreplace[3]= list("t","\\mu");
2436setring(r0t);
2437
2438write(fname,
2439bv +
2440"> TeXreplace[2]= list(\"s\",\"\\\\lambda\");
2441> TeXreplace[3]= list(\"t\",\"\\\\mu\");
2442> setring(r0t);
2443> texpoly(fname,f);
2444" + nl +
2445ev);
2446
2447texpoly(fname,f);
2448
2449
2450write(fname,nl2,"let us write $\\tilde{y}$ for $x$" + lb);
2451
2452TeXreplace[4] = list("x","\\tilde{y}");
2453setring r1;
2454
2455
2456write(fname,
2457bv +
2458"> TeXreplace[4] = list(\"x\",\"\\\\tilde{y}\");
2459> setring r1;
2460> texpoly(fname,f);
2461> kill TeXreplace;
2462" + nl +
2463ev);
2464
2465texobj(fname,f);
2466kill TeXreplace;
2467
[651b46]2468write(fname,"If \\verb|TeXreplace| is defined, the translation into \\TeX  code
[917fb5]2469runs significantly slower, because every polynomial will be compiled in the
[ae4196]2470\\verb|non short| mode."+ lb );
2471
2472
2473write(fname,nl,"\\Line");
2474//linebreaking   TeXwdith
2475//-----------------------------------------------------------------------
[917fb5]2476write(fname,"The global variable \\verb|TeXwidth| controls the wrapping of
[ae4196]2477polynomials; possible values are:" + lb);
2478
2479write(fname,
2480"\\[ " + nl +
2481"TeXwidth = ",
2482"\\begin{cases} ",
2483" -1 & \\text{no linebreaking} \\\\ ",
2484"  0 & \\text{print the polynom as equation} f=0 \\\\ ",
[917fb5]2485" 1,\\ldots,5 & \\text{ the first n termes followed by the sign of the next
[ae4196]2486term} \\\\ ",
2487" > 5 & \\text{wrapping after n letters corresponding x} ",
2488"\\end{cases}",
2489"\\]",nl);
2490
[917fb5]2491write(fname,"Notice that two letters like x counts as three subscripts or
[ae4196]2492exponents",nl);
2493
2494
2495write(fname,nl,"\\Line",nl);
2496//----------------------------------------------------------
2497
[651b46]2498write(fname,"\\verb|TeXwidth| is the only global variable which will be defined
[917fb5]2499automatically from Singular. Its default value is -1
[651b46]2500i.e. wrapping is set off."+ lb);
[ae4196]2501
2502// Examples:
2503
2504write(fname,"\\begin{itemize}",nl);
2505write(fname,"\\item",nl);
2506
[651b46]2507write(fname,"Up to now the value is " + string(TeXwidth)+".");
[ae4196]2508
2509write(fname,
2510bv +
2511"> TeXwidth;
2512" + nl +
2513string(TeXwidth) +
2514ev);
2515
2516
2517write(fname,
2518bv +
2519"> setring r0;
2520> poly h = f^2;
2521> texpoly(fname,h);
2522" + nl +
2523ev);
2524
2525setring r0;
2526poly h = f^2;
2527texpoly(fname,h);
2528
2529write(fname,"\\item",nl);
2530
2531write(fname,
2532bv +
2533"> TeXwidth =0;
2534> texpoly(fname,g);
2535" + nl +
2536ev);
2537TeXwidth = 0;
2538texpoly(fname,g);
2539
2540write(fname,"\\item",nl);
2541
2542write(fname,
2543bv +
2544"> TeXwidth = 2;
2545> texpoly(fname,f);
2546" + nl +
2547ev);
2548TeXwidth = 2;
2549texpoly(fname,h);
2550write(fname,"\\item",nl);
2551
2552write(fname,
2553bv +
2554"> TeXwidth = 60;
2555> texobj(fname,h);
2556" + nl +
2557ev);
2558TeXwidth = 60;
2559texobj(fname,h);
2560
2561write(fname,"\\end{itemize}",nl);
2562
2563// overread for \[ and \] ???
2564
2565// offset for texpoly
2566
2567write(fname,nl2,"\\Line",nl);
2568
[651b46]2569//write(fname,nl2, " offset for poly " + lb, nl);
[ae4196]2570
[651b46]2571//write(fname,nl2,"\\Line",nl);
[ae4196]2572
[917fb5]2573write(fname,"As seen there are two possibilities to tex a polynomial. The
[ae4196]2574command \\verb|texpoly| is the most basic one and sets the polynomials in
2575textmode. Notice that it counts the length of the terms convenientely." + lb +
2576" The command \\verb|texobj| is the most general one, if a polynomial
2577will be texed with this command, it will be written in display mode and
[651b46]2578the length of the terms will be counted appropriately ." + lb,nl2,
[ae4196]2579"Let us compare the output for \\verb|texpoly| and \\verb|texobj|."+lb);
2580
2581write(fname,
2582bv +
2583"> setring r3;
[917fb5]2584> texpoly(fname,f/180);" + nl +
[ae4196]2585ev);
2586
2587
2588setring r3;
[917fb5]2589texpoly(fname,f/180);
[ae4196]2590
2591write(fname,nl2, "Now the same again with \\verb|texobj| "+ lb,nl);
2592
2593write(fname,
2594bv +
[651b46]2595"> texobj(fname,f/180);
[ae4196]2596" + nl +
2597ev);
2598
[651b46]2599texobj(fname,f/180);
[ae4196]2600
2601
2602write(fname,"Some explaination how it works: if \\verb|texobj| is called for
2603a polynomial, then it defines a global variable \\verb|TeXdisp| which forces
[917fb5]2604\\verb|texpoly| to count fraction with space corresponding
[ae4196]2605the displaymode."+lb,nl2);
2606
2607
2608
2609//---------------------texobj for ideal ---------------
2610write(fname,"\\section{ideal}");
2611write(fname,"Ideal will just be printed as they are");
2612
2613
[917fb5]2614ring r;
[ae4196]2615ideal I = 3xz5+x2y3-3z,7xz5+y3z+x-z,-xyz2+4yz+2x;
2616
2617
2618write(fname,
2619bv +
2620"> ring r;   // the default one
2621> ideal I = 3xz5+x2y3-3z,7xz5+y3z+x-z,-xyz2+4yz+2x;
2622> texobj(fname,I);" + nl +
2623ev + nl);
2624
2625texobj(fname,I);
2626
2627write(fname,"\\subsection{Features for ideals}");
2628//----------------------------------------------------------------------
2629write(fname," With setting of \\verb|TeXaligned| the ideal will be set in
2630line ");
2631
2632write(fname,
2633bv +
2634"> int TeXaligned;
2635> texobj(fname,I);" + nl +
2636ev);
2637
2638int TeXaligned; export TeXaligned;
2639texobj(fname,I);
2640
2641write(fname,"\\Line");
2642//----------------------------------------------------------------------
[651b46]2643write(fname,"If other brackets are prefered, just set them");
[ae4196]2644
2645write(fname,
2646bv +
2647"> string TeXbrack = \"<\";
2648> texobj(fname,I);
2649> kill TeXbrack, TeXaligned;" + nl +
2650ev);
2651
2652
2653string TeXbrack = "<";  export TeXbrack;
2654texobj(fname,I);
2655kill TeXbrack,TeXaligned;
2656write(fname,"\\Line");
2657//----------------------------------------------------------------------
2658write(fname,
2659" If \\verb|TeXwidth| is set 0, an ideal will be set as an equation system
2660" +nl);
2661
2662
2663// ------------- a linear equation system
2664
2665 ring r5 = 0,x(1..5),dp;
2666 ideal I = -x(1) + 2*x(3) + x(5),x(2) -x(4) +2*x(5) -1,8*x(1) +x(4) +2;
2667
[917fb5]2668 TeXwidth = 0;
[ae4196]2669write(fname,
2670bv +
[917fb5]2671"> ring r5 = 0,x(1..5),dp ;
[ae4196]2672> ideal I = -x(1) + 2*x(3) + x(5),x(2) -x(4) +2*x(5) -1,8*x(1) +x(4) +2;
2673> string(I);" + nl +
[917fb5]2674splt(string(I)) + nl2 +
2675"> TeXwidth = 0;
[ae4196]2676> texobj(fname,I);" +
2677//> TeXwidth = 0;" +
2678ev
[917fb5]2679);
[ae4196]2680
2681 texobj(fname,I);
2682// TeXwidth = -1;
[917fb5]2683
[ae4196]2684 setring r;
2685 ideal J;
2686 J[1] = randompoly(2,5,25);
2687 J[2] = randompoly(4,15,25);
2688 J[3] = randompoly(2,5,25);
2689 J[4] = randompoly(3,10,25);
2690 J[5] = randompoly(2,20,25);
2691
2692 string(J);
2693
2694write(fname,
2695bv +
2696"> setring r;
2697> J[1] = randompoly(2,5,25);
2698> J[2] = randompoly(4,15,25);
2699> J[3] = randompoly(2,5,25);
2700> J[4] = randompoly(3,10,25);
2701> J[5] = randompoly(2,20,25);
2702> string(J);
2703" + nl + string(J) +
2704ev
2705);
2706
2707
2708write(fname,
2709bv +
[917fb5]2710"> texobj(fname,J);" +
[ae4196]2711ev
[917fb5]2712);
2713
[ae4196]2714 texobj(fname,J);
2715//% TeXwidth = 0; TeXbrackets
2716
2717write(fname,"\\Line");
2718//-----------------------------------------------------------------------
2719write(fname,"Call the ideal by its name and it will be printed as follows");
2720write(fname,
2721bv +
2722"> setring r;
2723> ideal I = 3xz5+x2y3-3z,7xz5+y3z+x-z,-xyz2+4yz+2x;
2724> texobj(fname,\"I\");" + nl +
2725ev);
2726
[917fb5]2727setring r;
[ae4196]2728ideal I = 3xz5+x2y3-3z,7xz5+y3z+x-z,-xyz2+4yz+2x;
[d6cc54]2729if(system("with","Namespaces")) { exportto(Current, r, I); }
2730else {
2731  export r;
2732  export I;
2733}
[ae4196]2734listvar(r);
2735texobj(fname,"I");
2736
2737// kill r;
2738" end part 2 " + nl;
2739}
2740
2741/////////////////////////////  PART3 //////////////////////////////////////////
2742
2743
[651b46]2744static proc part3(string fname)
[ae4196]2745{ int st = defined(texdemopart);
2746
2747  if (not(st) or st>=3)
2748  { print(" Call part2 first");
2749    return();
2750  }
2751  else { texdemopart=3; }
2752
2753 " Continuing part 3 of " + fname +
2754 " : map,matrices,vectors,intvec,intmats,proc";
2755
2756//---------------------- texmap ------------------------------
2757write(fname,"\\section{maps}");
2758// TeXwidth;
2759// int TeXwidth =-1;
2760write(fname,bv +
[917fb5]2761"> ring r1=0,(x,y,z),dp;
[ae4196]2762> ring r2=0,(u,v),dp;
2763> map phi = r1,u2,uv -v,v2;
2764> texmap(fname,phi,r1,r2,\"\\\\C\");" + nl +
2765ev );
[d6cc54]2766 ring r1=0,(x,y,z),dp;
2767 if(system("with","Namespaces")) { exportto(Current, r1); }
2768 else { export r1; }
[ae4196]2769 ring r2=0,(u,v),dp;
2770 map phi =r1,u2,uv -v,v2;  export phi;
2771 texmap(fname,phi,r1,r2,"\\C");
2772
2773
2774write(fname,"\\subsection{Features for maps}");
2775//--------------------------------------------------------------------
2776
2777
2778write(fname,"\\begin{itemize}",nl);
2779
2780write(fname,"\\item",nl);
2781
[917fb5]2782write(fname,"If the map will be called by its name \\verb|texmap| can in
[ae4196]2783combination with \\verb|TeXreplace| print the name of the map." + lb ,nl);
2784
2785write(fname,bv +
2786"> list TeXreplace;
2787> TeXreplace[1] = list(\"phi\",\"\\\\phi\");
[917fb5]2788> texmap(fname,\"phi\",r1,r2);" + nl +
[ae4196]2789ev);
2790
2791  list TeXreplace;
2792  TeXreplace[1] = list("phi","\\phi");
2793  export TeXreplace;
2794  texmap(fname,"phi",r1,r2);
2795
2796write(fname,"\\item",nl);
2797
2798write(fname,"With \\verb|TeXaligned| the map will be printed in a line"+lb,nl);
2799
2800write(fname,bv +
2801"> int TeXaligned;
2802> texmap(fname,phi,r1,r2,\"\\\\C\");" + nl +
2803ev );
2804
2805  int TeXaligned; export TeXaligned;
2806  texmap(fname,phi,r1,r2,"\\C");
2807
2808write(fname,"\\item",nl);
2809
[917fb5]2810write(fname,nl2,"The addtional arguments for \\verb|rings| may be passed over
[ae4196]2811in \\verb|texmap|.",nl);
2812
[917fb5]2813write(fname,"In the following form the arguments are valid for both
[ae4196]2814\\verb|rings|.",nl);
2815
2816write(fname,bv +
2817">  texmap(fname,\"phi\",r1,r2,\"\\\\C\",\"{\",1); " + nl +
2818ev );
2819
2820 texmap(fname,"phi",r1,r2,"\\C","{",1);
2821
2822write(fname,"\\\\",nl2,"If they are enclosed in \\verb|list( )| the arguments
2823 may specialized in ",nl);
2824
2825
2826write(fname,bv +
2827"> intvec v = 2;",
2828"> texmap(fname,\"phi\",r1,r2,list(),list(v,\"{\"));",
2829"> kill r1,r2,TeXreplace,TeXaligned;" + nl +
2830ev );
2831
2832 intvec v = 2;
2833 texmap(fname,"phi",r1,r2,list(),list(v,"{"));
2834
2835 "map _Ende";
2836  kill r1,r2,TeXreplace,TeXaligned;
2837
2838write(fname,"\\end{itemize}",nl);
2839
2840//% the texobj part
2841write(fname,"\\section{basic, composed  data}");
2842//=======================================================================
2843
2844write(fname, "Now we present the most general procedure \\verb|texobj| to
2845translate composed Singularobjects into \\LaTeX \\ code"+lb,nl);
2846
2847write(fname,"\\section{matrices and vectors}");
2848//=======================================================================
2849
2850write(fname,bv +
2851"> ring r;",
2852"> poly h = 2xy3-x2z+x4z7 + y4z2;",
2853"> matrix H = jacob(jacob(h));",
2854"> texobj(fname,H);",
2855ev );
2856
2857ring r;
2858poly h = 2xy3-x2z+x4z7 + y4z2;
2859matrix H = jacob(jacob(h));
2860
2861texobj(fname,H);
2862
[917fb5]2863// probiere auch V = 0 bei texobj aus
[ae4196]2864matrix M = H;
2865
2866write(fname,"A \\verb|vector| will be set as one column:"+lb ,nl);
2867
2868// Das geht nicht ?
2869vector V = M[2];
2870
2871vector W= [x,y,0,z];
2872
2873write(fname,bv +
2874"> matrix M = H;",
2875"> vector V = M[2];",
2876"> vector W= [x,y,0,z];",
2877"> texobj(fname,V);",
2878ev );
2879
2880texobj(fname,V);
2881
2882write(fname,bv +
2883"> texobj(fname,W);",
2884ev );
2885
2886
2887texobj(fname,W);
2888
2889
2890write(fname,"To turn it just the cast \\verb|matrix| here"+ lb,nl);
2891write(fname,bv +
2892"> texobj(fname,matrix(V));",
2893ev );
2894
2895
2896texobj(fname,matrix(V));
2897
2898write(fname,"\\subsection{Features for matrices and vectors}");
2899//------------------------------------------------------------------------
2900
[917fb5]2901write(fname,"All the features for \\verb|poly| and the features for
[ae4196]2902\\verb|intmat| or \\verb|intvec| hold here, too.");
2903
2904write(fname,"Display only the jet of the Hessian");
2905
2906write(fname,bv +
2907"> TeXwidth = 1;",
[917fb5]2908"> texobj(fname,H);",
[ae4196]2909"> TeXwidth = -1;",
2910ev );
2911
2912TeXwidth = 1;
[917fb5]2913texobj(fname,H);
[ae4196]2914TeXwidth = -1;
2915
2916write(fname,nl,"\\Line");
2917//------------------------------------------------------------------------
2918write(fname,"Set rational numbers as you like"+lb,nl);
2919
2920write(fname,bv +
2921"> ring r0 = 0,x,dp;",
2922"> matrix M[2][3] = 1/2, 0, 1/2, 0, 1/3, 2/3;",
2923"> texobj(fname,M);",
2924ev);
2925
2926
2927ring r0 = 0,x,dp;
2928matrix M[2][3] = 1/2, 0, 1/2, 0, 1/3, 2/3;
2929texobj(fname,M);
2930
2931write(fname,bv +
[917fb5]2932"> int TeXnofrac;",
[ae4196]2933"> texobj(fname,M);",
2934"> kill TeXnofrac;",
2935ev );
2936
2937int TeXnofrac; export TeXnofrac;
2938texobj(fname,M);
2939kill TeXnofrac;
2940
2941write(fname,nl,"\\Line");
2942//------------------------------------------------------------------------
2943
2944write(fname,nl,"Print a vector with homogenous coordinates ");
2945write(fname,bv +
2946"> setring r;",
2947"> int TeXproj;",
2948"> texobj(fname,V);",
2949"> kill TeXproj;",
2950ev );
2951
2952setring r;
2953int TeXproj; export TeXproj;
2954texobj(fname,V);
2955kill TeXproj;
2956
2957write(fname,"\\section{modules}",nl2);
2958
2959write(fname,bv +
2960"> setring r;",
2961"> module md = module(H);",
2962"> texobj(fname,md);",
2963ev );
2964
2965setring r;
2966module md = module(H);
2967texobj(fname,md);
2968
2969write(fname,"\\subsection{Features for modules}");
2970
2971write(fname,"Set a module aligned",nl2);
2972
2973write(fname,bv +
2974"> int TeXaligned;",
2975"> texobj(fname,md);",
2976"> kill TeXaligned;",
2977ev );
2978
2979int TeXaligned; export TeXaligned;
2980texobj(fname,md);
2981kill TeXaligned;
2982
2983// write(fname,"\\section{Bettinumbers}");
2984
2985
2986//----------------------------------------------------------------
2987write(fname,"\\section{intvec and intmat}");
2988
2989write(fname,"Despite of the fact that a \\verb|intvec| is in Singular a column
2990vector, the \\verb|tex.lib| sets it as a row vector ust as Singular displays it
2991");
2992intvec v = 1..4;
2993write(fname,
2994bv +
2995"> intvec v = 1..4;
2996> v;" + nl +
2997string(v) + nl +
[917fb5]2998"> nrows(v);" + nl +
[ae4196]2999string(nrows(v)) + nl +
3000"texobj(fname,v);" + nl2 +
3001ev );
3002
3003texobj(fname,v);
3004
3005
3006intmat m[3][4] = -1,3,5,2,-2,8,6,0,2,5,8,7;
3007m;
3008
3009write(fname,
3010bv +
3011"> intmat m[3][4] = -1,3,5,2,-2,8,6,0,2,5,8,7;" + nl +
3012"> m;" + nl +
[917fb5]3013string(m) + nl +
[ae4196]3014"> texobj(fname,m);" + nl2 +
3015ev );
3016
3017texobj(fname,m);
3018
3019//-----------------------------------------------------------------
3020write(fname,"\\subsection{Features for intvec and intmat}");
3021
3022write(fname,"If the \\verb|intvec| should represent homogemous coordinates
3023set \\verb|TeXproc|.");
3024write(fname,
3025bv +
3026"> int TeXproj;" + nl +
3027"> texobj(fname,v);" + nl +
3028"> kill TeXproj;" + nl2 +
3029ev );
3030
3031int TeXproj; export TeXproj;
3032texobj(fname,v);
3033kill TeXproj;
3034
3035write(fname,nl2);
3036
3037//-----------------------------------------------
3038write(fname,"\\Line");
3039write(fname,"For writing an \\verb|intvec| as row vector as it is use the
3040cast \\verb|intmat|");
3041
3042write(fname,
3043bv +
3044"> texobj(fname,intmat(v));" + nl2 +
3045ev );
3046
3047texobj(fname,intmat(v));
3048
3049write(fname,
3050bv +
3051"> texobj(fname,intmat(m*v),\"=\",m,\"*\",intmat(v));" + nl2 +
3052ev );
3053
3054texobj(fname,intmat(m*v),"=",m,"*",intmat(v));
3055
3056//-----------------------------------------------------------------
3057write(fname,"\\Line");
3058
3059write(fname,"The brackets of a \\verb|intmat| can be set with \\verb|TeXproj|
3060as usual");
3061
3062write(fname,
3063bv +
3064"> intmat mat[3][3] = 1,2,3,4,5,6,7,8,9;" + nl +
3065"> string TeXbrack = \"|\";" + nl +
[917fb5]3066"> texobj(fname,mat,\"=\",det(mat)); " + nl2 +
[ae4196]3067ev );
3068
3069intmat mat[3][3] = 1,2,3,4,5,6,7,8,9;
3070string TeXbrack = "|"; export TeXbrack;
3071texobj(fname,mat,"=",det(mat));
3072kill TeXbrack;
3073
3074//----------------------------------texname-------------------
3075
[651b46]3076//write(fname,"\\section{Names of identifiers}");
[ae4196]3077
3078
[917fb5]3079//write(fname,"The proc \\verb|texname| is used to write indexed names in a
[651b46]3080//correct way"+lb,nl);
[ae4196]3081
3082
3083
3084// ------------------------------- texproc -------------------------------
3085write(fname,"\\section{procs}");
3086 write(fname,"Finally, here is the procedure we used to generate the random
3087polynomials.");
[651b46]3088 // write(fname,"\\newpage");
[ae4196]3089  texproc(fname,"randompoly");
3090
3091
3092// ------------------------------ closing the tex file -------------------
3093write(fname,"\\section{Closing the \\LaTeX\\ file}");
3094write(fname,"The file will be closed by \\verb|closetex(fname);|. It should
3095contain now purely correct \\LaTeX code and may be compiled with " +
3096"\\verb|tex(fname)| and displayed with \\verb|xdvi(fname)|");
3097
[651b46]3098// write(fname,"\\section{Remarks}");
[ae4196]3099closetex(fname);
3100
3101"end of part3" + nl;
[651b46]3102
3103pagewidth =80;
[ae4196]3104}
3105
3106
3107 proc cleantexdemo()
[917fb5]3108 {
[ae4196]3109  kill fname,nl,nl2,lb,bv,ev;
3110  return();
3111 }
[8942a5]3112///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.