- Timestamp:
- Feb 7, 2001, 2:47:50 PM (23 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
- Children:
- a23181f4691407c0dda201f7522421b947e214b2
- Parents:
- 9e58366eade0dde081d5a55b0d3f5eaaa799acbf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/latex.lib
r9e5836 r1c1d96b 1 1 e/////////////////////////////////////////////////////////////////////////////// 2 version="$Id: latex.lib,v 1.1 5 2001-02-07 09:29:32 lossenExp $";2 version="$Id: latex.lib,v 1.16 2001-02-07 13:47:50 Singular Exp $"; 3 3 //category="Visualization"; 4 4 info=" … … 25 25 TeXwidth, TeXnofrac, TeXbrack, TeXproj, TeXaligned, TeXreplace, NoDollars 26 26 are used to control the typesetting. 27 Call @code{example texdemo;} to become familiar with the features of 27 Call @code{example texdemo;} to become familiar with the features of 28 28 @code{latex.lib}. 29 29 @format 30 30 @code{TeXwidth} (int) -1, 0, 1..9, >9: controls breaking of long polynomials 31 31 @code{TeXnofrac} (int) flag: write 1/2 instead of \\frac@{1@}@{2@} 32 @code{TeXbrack} (string) \"@{\", \"(\", \"<\", \"|\", empty string: 32 @code{TeXbrack} (string) \"@{\", \"(\", \"<\", \"|\", empty string: 33 33 controls brackets around ideals and matrices 34 34 @code{TeXproj} (int) flag: write \":\" instead of \",\" in vectors … … 131 131 texobj("exp001","An ideal ",I); 132 132 closetex("exp001"); 133 tex("exp001"); 133 tex("exp001"); 134 134 echo=0; 135 135 pause("the created files will be deleted after pressing <RETURN>"); … … 284 284 proc texfactorize(string fname, poly f, list #) 285 285 "USAGE: texfactorize(fname,f); fname string, f poly 286 RETURN: if @code{fname=\"\"}: string, f as a product of its irreducible 286 RETURN: if @code{fname=\"\"}: string, f as a product of its irreducible 287 287 factors@* 288 otherwise: append this string to the file @code{<fname>}, and 288 otherwise: append this string to the file @code{<fname>}, and 289 289 return nothing. 290 290 NOTE: preceeding \">>\" are deleted and suffix \".tex\" (if not given) … … 369 369 proc texmap(string fname, def m, def @r1, def @r2, list #) 370 370 "USAGE: texmap(fname,m,@r1,@r2); fname string, m string/map, @r1,@r2 rings 371 RETURN: if @code{fname=\"\"}: string, the map m from @r1 to @r2 (preceeded 371 RETURN: if @code{fname=\"\"}: string, the map m from @r1 to @r2 (preceeded 372 372 by its name if m = string) in TeX-typesetting;@* 373 otherwise: append this string to the file @code{<fname>}, and 373 otherwise: append this string to the file @code{<fname>}, and 374 374 return nothing. 375 NOTE: preceeding \">>\" are deleted in @code{fname}, and suffix \".tex\" 375 NOTE: preceeding \">>\" are deleted in @code{fname}, and suffix \".tex\" 376 376 (if not given) is added to @code{fname}. 377 377 If m is a string then it has to be the name of an existing map … … 561 561 n = n+5*(i-anf); 562 562 anf =i; // the next text in ( , ) as exponent 563 if (op) 564 { 563 if (op) 564 { 565 565 if (s[i]== ","){anf = anf+1;} 566 566 while(s[i] !=")"){ i++;} … … 580 580 "USAGE: texname(fname,s); fname,s strings 581 581 RETURN: if @code{fname=\"\"}: string, the transformed string s, where the 582 following rules apply: 583 @example 582 following rules apply: 583 @example 584 584 s' + \"~\" --> \"\\tilde@{\"+ s' +\"@}\" 585 \"_\" + int --> \"_@{\" + int +\"@}\" 585 \"_\" + int --> \"_@{\" + int +\"@}\" 586 586 \"[\" + s' + \"]\" --> \"_@{\" + s' + \"@}\" 587 \"A..Z\" + int --> \"A..Z\" + \"^@{\" + int + \"@}\" 587 \"A..Z\" + int --> \"A..Z\" + \"^@{\" + int + \"@}\" 588 588 \"a..z\" + int --> \"a..z\" + \"_@{\" + int + \"@}\" 589 589 \"(\" + int + \",\" + s' + \")\" --> \"_@{\"+ int +\"@}\" + \"^@{\" + s'+\"@}\" 590 590 @end example 591 591 Anyhow, strings which begin with a @code{\"@{\"} are only changed 592 by deleting the first and last character (intended to remove the 592 by deleting the first and last character (intended to remove the 593 593 surrounding curly brackets). 594 594 595 if @code{fname!=\"\"}: append the transformed string s to the file 595 if @code{fname!=\"\"}: append the transformed string s to the file 596 596 @code{<fname>}, and return nothing. 597 NOTE: preceeding \">>\" are deleted in @code{fname}, and suffix \".tex\" 597 NOTE: preceeding \">>\" are deleted in @code{fname}, and suffix \".tex\" 598 598 (if not given) is added to @code{fname}. 599 599 EXAMPLE: example texname; shows an example … … 603 603 st=manipul(s); 604 604 if (size(fname)) 605 { 605 { 606 606 int i=1; 607 607 while (fname[i]==">"){i++;} 608 608 fname = fname[i,size(fname)-i+1]; 609 609 if (size(fname)>=4) // check if filename is ending with ".tex" 610 { 610 { 611 611 if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } 612 612 } … … 634 634 635 635 static proc absterm(poly f) 636 { 636 { 637 637 int k; 638 638 for (k=1; k<=nvars(basering); k++) … … 645 645 "USAGE: texobj(fname,l); fname string, l list 646 646 RETURN: if @code{fname=\"\"}: string, the objects in LaTeX-typesetting;@* 647 otherwise: append this string to the file @code{<fname>}, and 647 otherwise: append this string to the file @code{<fname>}, and 648 648 return nothing. 649 NOTE: preceeding \">>\" are deleted in @code{fname}, and suffix \".tex\" 649 NOTE: preceeding \">>\" are deleted in @code{fname}, and suffix \".tex\" 650 650 (if not given) is added to @code{fname}. 651 651 EXAMPLE: example texobj; shows an example … … 687 687 { if (defined(`obj`)) 688 688 { if (typeof(`obj`)=="ideal") 689 { 689 { 690 690 Iname = obj; def e = `obj`; //convert to correct type ideal 691 691 kill obj; def obj = e; kill e; … … 900 900 } 901 901 example 902 { 902 { 903 903 echo=0; 904 904 // -------- prepare for example --------- … … 942 942 "USAGE: texproc(fname,pname); fname,pname strings 943 943 ASSUME: @code{`pname`} is a procedure. 944 RETURN: if @code{fname=\"\"}: string, the proc @code{`pname`} in a verbatim 944 RETURN: if @code{fname=\"\"}: string, the proc @code{`pname`} in a verbatim 945 945 environment in LaTeX-typesetting;@* 946 otherwise: append this string to the file @code{<fname>}, and 946 otherwise: append this string to the file @code{<fname>}, and 947 947 return nothing. 948 NOTE: preceeding \">>\" are deleted in @code{fname}, and suffix \".tex\" 948 NOTE: preceeding \">>\" are deleted in @code{fname}, and suffix \".tex\" 949 949 (if not given) is added to @code{fname}.@* 950 950 @code{texproc} cannot be applied to itself correctly. … … 1044 1044 "USAGE: texring(fname, r[,L]); fname string, r ring, L list 1045 1045 RETURN: if @code{fname=\"\"}: string, the ring in TeX-typesetting;@* 1046 otherwise: append this string to the file @code{<fname>} and 1046 otherwise: append this string to the file @code{<fname>} and 1047 1047 return nothing. 1048 1048 NOTE: preceeding \">>\" are deleted and suffix \".tex\" (if not given) … … 1177 1177 texring("",ralg,"mipo"); 1178 1178 // 1179 ring r49=(49,a),x,dp; // Galois field 1179 ring r49=(49,a),x,dp; // Galois field 1180 1180 texring("",r49); 1181 1181 // … … 1200 1200 proc rmx(string fname) 1201 1201 "USAGE: rmx(fname); fname string 1202 RETURN: nothing; removes the @code{.log} and @code{.aux} files associated to 1202 RETURN: nothing; removes the @code{.log} and @code{.aux} files associated to 1203 1203 the LaTeX file <fname>.@* 1204 NOTE: If @code{fname} ends by @code{\".dvi\"} or @code{\".tex\"}, the 1204 NOTE: If @code{fname} ends by @code{\".dvi\"} or @code{\".tex\"}, the 1205 1205 @code{.dvi} or @code{.tex} file will be deleted, too. 1206 1206 EXAMPLE: example rmx; shows an example … … 1286 1286 { "EXAMPLE:"; echo = 2; 1287 1287 intmat m[3][4] = 9,2,4,5,2,5,-2,4,-6,10,-1,2,7; 1288 opentex("exp001"); 1288 opentex("exp001"); 1289 1289 texobj("exp001","An intmat: ",m); 1290 1290 closetex("exp001"); … … 1300 1300 1301 1301 static proc parsr(string s) // parse real 1302 { 1302 { 1303 1303 string t; 1304 1304 if (s==" Inf") { return("\\infty",3);} … … 1312 1312 else {return(s[1,5]+"*10^"+t,23);} 1313 1313 } 1314 else 1314 else 1315 1315 { 1316 1316 return(s[1,5],12); … … 1319 1319 1320 1320 static proc parsg(string s) // parse Galoisfield 1321 { 1321 { 1322 1322 int i,j = 1,1; 1323 1323 string t; 1324 1324 if (short) 1325 { 1325 { 1326 1326 t =s[1]; 1327 1327 if(size(s)>1) {return(t+"^{" + s[2,size(s)-1] + "}",3+2*(size(s)-1));} … … 1329 1329 } 1330 1330 else 1331 { 1331 { 1332 1332 return(parselong(s+"!")); 1333 1333 } … … 1338 1338 "USAGE: texpoly(fname,p); fname string, p poly 1339 1339 RETURN: if @code{fname=\"\"}: string, the poly p in LaTeX-typesetting;@* 1340 otherwise: append this string to the file @code{<fname>}, and 1340 otherwise: append this string to the file @code{<fname>}, and 1341 1341 return nothing. 1342 NOTE: preceeding \">>\" are deleted in @code{fname}, and suffix \".tex\" 1342 NOTE: preceeding \">>\" are deleted in @code{fname}, and suffix \".tex\" 1343 1343 (if not given) is added to @code{fname}. 1344 1344 EXAMPLE: example texpoly; shows an example … … 1851 1851 but looks differently in large parts."+"\\\\" + nl); 1852 1852 write(fname,"\\begin{tabular}{ll}" + nl + 1853 "LIBRARY: {\\tt latex.lib} & PROCEDURES FOR TYPESETTING SINGULAR" + 1853 "LIBRARY: {\\tt latex.lib} & PROCEDURES FOR TYPESETTING SINGULAR" + 1854 1854 "\\\\" + nl + 1855 1855 " & OBJECTS IN LATEX2E"+ … … 1863 1863 "{\\tt texdemo([n]);} & produces a file explaining the features of this lib"+ 1864 1864 "\\\\" + nl + 1865 "{\\tt texfactorize(fnm,f);} & creates string in \\LaTeX-format for 1865 "{\\tt texfactorize(fnm,f);} & creates string in \\LaTeX-format for 1866 1866 factors of poly f"+ "\\\\" + nl + 1867 1867 "{\\tt texmap(fnm,m,r1,r2);} & creates string in \\LaTeX-format for 1868 1868 map m:r1$\\rightarrow$r2"+ "\\\\" + nl + 1869 "{\\tt texname(fnm,s);} & creates string in \\LaTeX-format for 1869 "{\\tt texname(fnm,s);} & creates string in \\LaTeX-format for 1870 1870 identifier"+ "\\\\" + nl + 1871 1871 "{\\tt texobj(l);} & creates string in \\LaTeX-format for … … 1875 1875 "{\\tt texproc(fnm,p);} & creates string in \\LaTeX-format of 1876 1876 text from proc p"+ "\\\\" + nl + 1877 "{\\tt texring(fnm,r[,l]);} & creates string in \\LaTeX-lformat for 1877 "{\\tt texring(fnm,r[,l]);} & creates string in \\LaTeX-lformat for 1878 1878 ring/qring"+ "\\\\" + nl + 1879 1879 "{\\tt rmx(s);} & removes .aux and .log files of \\LaTeX-files"+ … … 1885 1885 "\\\\" + nl2 + "\\vspace{0.2cm}" + nl2 + 1886 1886 "The global variables {\\tt TeXwidth}, {\\tt TeXnofrac}, {\\tt 1887 TeXbrack}, {\\tt TeXproj}, {\\tt TeXaligned}, {\\tt TeXreplace}, {\\tt 1887 TeXbrack}, {\\tt TeXproj}, {\\tt TeXaligned}, {\\tt TeXreplace}, {\\tt 1888 1888 NoDollars} are used to control the typesetting: " 1889 1889 ); … … 1931 1931 1932 1932 static proc part1(string fname) 1933 { 1933 { 1934 1934 1935 1935 int st = defined(texdemopart); … … 1962 1962 "> texring(fname,r0);" + 1963 1963 ev); 1964 texring(fname,r0); 1964 texring(fname,r0); 1965 1965 write(fname,nl2); 1966 1966 write(fname, … … 1969 1969 "> texpoly(fname,g);" +nl + 1970 1970 ev); 1971 texpoly(fname,g); 1971 texpoly(fname,g); 1972 1972 write(fname,"\\\\"+nl2); 1973 1973 … … 1983 1983 ev 1984 1984 ); 1985 texpoly(fname,g/280); 1985 texpoly(fname,g/280); 1986 1986 kill r0; 1987 1987 1988 1988 write(fname,"\\\\"+nl2); 1989 1989 write(fname,"\\Line"); 1990 1990 // -2-------- a ring in char 7, indexed varnames and series ordering ---------- 1991 1991 write(fname, 1992 " A ring in characteristic 7 with indexed names of variables and local 1992 " A ring in characteristic 7 with indexed names of variables and local 1993 1993 ordering." +nl); 1994 1994 ring r1=7,(x1,x2,x3,x4),Ds; 1995 poly g=-2*x1+x4-1; 1996 write(fname, 1997 bv + 1998 "> ring r1=7,(x1,x2,x3,x4),Ds;" +nl + 1995 poly g=-2*x1+x4-1; 1996 write(fname, 1997 bv + 1998 "> ring r1=7,(x1,x2,x3,x4),Ds;" +nl + 1999 1999 "> texring(fname,r1);" +nl + 2000 2000 ev); 2001 texring(fname,r1); 2001 texring(fname,r1); 2002 2002 write(fname,lb); 2003 2003 2004 2004 write(fname, bv + 2005 "> poly g=-2*x1+x4-1; g;" +nl + 2005 "> poly g=-2*x1+x4-1; g;" +nl + 2006 2006 "> texpoly(fname,g);" +nl + 2007 2007 ev); 2008 2008 2009 2009 texpoly(fname,g); 2010 2010 2011 2011 write(fname,lb); 2012 2012 write(fname,"\\Line"); … … 2014 2014 // -3-------- a ring in char 0, indexed varnames and local ordering ---------- 2015 2015 write(fname, 2016 " A ring in characteristic 0 with indexed names of variables and local 2016 " A ring in characteristic 0 with indexed names of variables and local 2017 2017 ordering. 2018 2018 " +nl); … … 2028 2028 texring(fname,r2); write(fname,lb); 2029 2029 texpoly(fname,g); write(fname,lb); 2030 2030 2031 2031 write(fname,"\\Line"); 2032 2032 … … 2046 2046 texring(fname,r3); write(fname,lb); 2047 2047 texpoly(fname,g); write(fname,lb); 2048 2048 2049 2049 write(fname,"\\Line"); 2050 2050 … … 2255 2255 \\verb|\"\\\\C\"|, \\verb|\"k\"|, \\verb|\"K\"|, \\verb|\"R\"|."); 2256 2256 write(fname,"The latter are useful to print a ring whose field of 2257 coefficients is defined by an algebraic extension. Now the parameters 2257 coefficients is defined by an algebraic extension. Now the parameters 2258 2258 will be omitted completely. 2259 2259 "); … … 2261 2261 2262 2262 write(fname,"Any correct letter in \\LaTeX \\ notation may be used to describe 2263 the field of coefficients. If the letter is k, K or R it forces 2264 \\verb|texring| not to print the parameters. This will be useful for a 2263 the field of coefficients. If the letter is k, K or R it forces 2264 \\verb|texring| not to print the parameters. This will be useful for a 2265 2265 ring described by an algebraic extension",nl2); 2266 2266 … … 2353 2353 2354 2354 static proc part2(string fname) 2355 { 2355 { 2356 2356 2357 2357 int st = defined(texdemopart); … … 2474 2474 2475 2475 TeXreplace[4] = list("x","\\tilde{y}"); 2476 2476 2477 2477 // setring r1; 2478 2478 ring r1=7,(x1,x2,x3,x4),Ds; 2479 poly g=-2*x1+x4-1; 2479 poly g=-2*x1+x4-1; 2480 2480 2481 2481 write(fname, … … 2543 2543 ev); 2544 2544 2545 setring r0; 2545 setring r0; 2546 2546 poly g=-x2y+2y13z+1; 2547 2547 poly f = g^2; … … 2741 2741 2742 2742 static proc part3(string fname) 2743 { 2743 { 2744 2744 int st = defined(texdemopart); 2745 2745 string nl = newline; … … 2750 2750 2751 2751 if (not(st) or st>=3) 2752 { 2752 { 2753 2753 print(" Call part2 first"); 2754 2754 return(); … … 2767 2767 > texmap(fname,phi,r4,r5,\"\\\\C\");" + nl + 2768 2768 ev ); 2769 2769 2770 2770 ring @r4_h=0,(x,y,z),dp; 2771 2771 if(system("with","Namespaces")) { exportto(Current, @r4_h); } … … 2835 2835 intvec v = 2; 2836 2836 texmap(fname,"@phi_h",@r4_h,r5,list(),list(v,"{")); 2837 2837 2838 2838 kill v,@phi_h,@r4_h,r5,TeXreplace,TeXaligned; 2839 2839 … … 2949 2949 ev ); 2950 2950 2951 setring r; 2951 setring r; 2952 2952 ideal I = 3xz5+x2y3-3z,7xz5+y3z+x-z,-xyz2+4yz+2x; 2953 2953 int TeXproj; export TeXproj; 2954 2954 2955 2955 texobj(fname,V); 2956 2956 kill TeXproj; … … 3089 3089 "// not an isolated singularity"; 3090 3090 } 3091 return(m_nr); 3091 return(m_nr); 3092 3092 } 3093 3093 export(milnor_number); 3094 3094 3095 3095 3096 3096 write(fname,"\\section{procs}"); 3097 write(fname,"Finally, here is a way to typeset procedures in \\LaTeX :"); 3098 3097 write(fname,"Finally, here is a way to typeset procedures in \\LaTeX :"); 3098 3099 3099 texproc(fname,"milnor_number"); 3100 3100 3101 3101 kill(milnor_number); 3102 3102 3103 3103 // ------------------------------ closing the tex file ------------------- 3104 3104 write(fname,"\\section{Closing the \\LaTeX\\ file}");
Note: See TracChangeset
for help on using the changeset viewer.