Making Latex Images of Worksheets
This worksheet describes some perl5 scripts which I been developing to massage files exported from MapleV worksheets, before latexing them. In order to use them, you need to have perl5 installed on your machine. It is on the Chisel disk.
An overview
The idea here is to make the *.mws worksheet files the source files, so that any changes by hand are made in the actual worksheet rather than in the latex file exported from Maple. The script mknotes.pl takes a collection of exported worksheets, modify each one in the manner described below, and constructs a rootfile which contains the formatting commands and then 'includes' the files into the rootfile.
Usage:
1. perl -S mknotes -h to get a help message and exit.
2. perl -S mknotes rootname worksheetfile , where rootname is a name (such as calcnotes.tex) you have chosen for the rootfile, and worksheetfile is the name of a file containing the names of the worksheets you have exported to latex. One name per line in the order you want them to be in the document.
3. perl -S mknotes rootname worksheet.tex , where rootname is as above and worksheet.tex is the name of a worksheet exported to latex.
4. perl -S mknotes -t rootname worksheetfile infofile , where rootname and worksheetfile are as in 2. and infofile is the name of a file containing three pieces of information separated by blank lines. Use mknotes -h to get the format details.
5. The i option: Change mknotes to mknotes -i in 2. or 3. and mknotes -t to mknotes -it in 4. to suppress the input cells in the LaTeX output. This is helpful when preparing papers or exams where you might not want the input cells to appear.
6. The w option is used if you want to wrap text around selected diagrams (only in mknotes54.pl)
Effects : The rootfile is opened and some appropriate latex2e lines are written to it. If the -t option has been chosen, the info file is opened and the TITLE, AUTHOR, and FRONTPIECE information is extracted and written into the rootfile (if you don't supply an infofile, dummy stuff is written in). Then the worksheet file is opened and the files listed there are processed one by one.
Things that mknotes.pl does
Fixes a bug in the formatting of mapleinput lines.
The current edition of maple2e.sty does not respect embedded carriage returns in an input cell. When one is developing the definition of a maple word, it is natural to have long input cells with lots of embedded carriage returns. When this is exported to latex, the result is that input lines overflow badly. mknotes fixes this problem for the most part. (You can see the embedded carriage returns if you choose the "show invisible characters" option on the View Menu.)
>
tabular := proc (f ,obj, v )
local t, A, m,i, n, x,ob,c,Z, vars,zrow;
t := convert(map(lhs-rhs = 0,f),list);
if nargs = 2 then vars := sort(convert(indets(t,name),list))
else vars := v fi;
ob:=subs([seq(h=0,h=vars)],obj);
zrow := linalg[genmatrix]([obj=0],vars,'flag');
zrow[1,nops(vars)+1] := ob;
A := linalg['genmatrix'](t,vars,'flag');
m := linalg['rowdim'](A); n := linalg['coldim'](A);
A := linalg[stackmatrix](zrow,A);
A := linalg[stackmatrix]([op(vars),Z],A);
end:
TEST1.bmp 2 1.5 l
Enables inclusion of externally drawn graphics files.
If you have a bmp or eps file drawn with an external program pasted into your worksheet, and you want this to appear in the latex output, do the following: 1. Make sure a copy of the graphic file is in the current directory. 2. Underneath the pasted in picture in the worksheet, open a new paragraph and type in the name of the graphic file, including its suffix, followed by its dimensions, width first, in inches. Center this and change the paragraph style to diagram. (If you don't have such a style, you just create it from the Format Menu. Don't give it any properties, except possibly change the color to very light grey to reduce it's visibility.). When you export this, mknotes makes the substitutions needed, even if there is no eps file.
Handles user defined character style bookmark.
Create a character style called B ookmark, with green font say. Then when you make a bookmark in your worksheet from the View menu, also highlight a word or phrase in that paragraph and convert it to the character style bookmark , leaving 4 to 8 blanks after the highlighted word. Then mknotes inserts an index marker there so that you can place the word in the index. This can be done even when you don't have a bookmark in the worksheet. After you latex the rootfile, a file with the same name as the rootfile, but with an idx suffix is created. Run makeindex on that file and another file with the same name but with suffix ind is created. You can change the name of that file to something like index.tex and add the line include{index} to the bottom of your rootfile, and relatex it. Voila! An index.
Sample: See above
Gets rid of leading hyperlinks.
Hyperlinks which are in the worksheets and direct people to the menu page don't want to be in the latex output. If they are in a paragraph by themselves, mknotes takes them out.
Gets rid of QTR.
QTR appears whenever you have a hyper link or any user defined character style. Use is made of this in locating bookmarks and leading hyperlinks. After that I have no further use for it, so I just get rid of it.
Makes LaTeX substitutions.
Maple has several made several passive operations, for example, Int, Sum, and Diff are all operations which do not carry out the operation but generate the typesetting symbol for the operation. However, there is no passive union, intersection, or setminus in MapleVr4. Mknotes fixes this (sort of), and also adds some other latex substitutions (for ray, line, seg, angle, and triangle). Below are several examples, from which you can get the idea of what can be done. More work needs to be done on this portion of mknotes For example, you can add your own latex macros and modify mknotes to recognize these. (Note: In release 5, there is a character style, LaTeX, which can be used to pass raw LaTeX commands and macros.)
Here is an example of an inline substitution:
. the same thing won't work on displayed output.
> A union (B union C);
What one can do make an ampersand definition or a proc definition.
> `&union` := proc(A,B) options operator; cat(`(`,A,` Union `,B,`)`) end;
> A &union ( B &union C );
Or you can just make a plain ol proc.
> uni := proc(A,B) cat(`(`,A,` Union `,B,`)`) end;
> uni(A,uni(B,C));
One can set up some things using '*'.
> R*Intersect*uni(ray(C,D),ray(A,B));
Here is some inline geometry stuff:
and some more
also some more
Here is
> angle*RVD = (ray*VR)* Union(ray*VD);
>
Turns off input.
The input used to generate the formatted output is suppressed, so you don't have to erase those lines from the worksheet.
Puts in newpages and vfills.
Create two new paragraph styles newpage and vfill. Then where you want newpages or vfills, insert a blank paragraph in that style.
This script act just like mknotes, except it adds color commands to the latex source. So, you can make color postscript files. Even if, you don't have a color printer the color adds a lot when you are using ghostview as a reader.
Unlike the three scripts mknotes.pl, mkindex.pl, and mkcontents.pl, mkcolor.pl does not come with the chisel disk. It comes in the zipfile with this worksheet. After you unzip the file, move the script to the directory X:\chisel\bin, where X is the drive letter where you have installed chisel.
mknotes5.pl
The character styles are exported more cleanly to latex in release 5 than they were in release 4. In release 4, if you wanted to mark a bookmark with the character style Bookmark, you needed to leave 2 to 5 spaces after the bookmark, in order for the perl script mknotes.pl to know where the index item ended. In release 5, you needn't bother with this. Another feature that has been added to mknotes5.pl is that the modified tex files have been marked as modified and the date of modification noted.
Unlike the three scripts mknotes.pl, mkindex.pl, and mkcontents.pl, mkotes5.pl does not come with the chisel disk. It comes in the zipfile with this worksheet. After you unzip the file, move the script to the directory X:\chisel\bin, where X is the drive letter where you have installed chisel. As of 6/9/98, the latest version of mknotes5.pl is mknotes54.pl. To see a more complete description of the styles processed by mknotes54.pl, see the worksheet parag.mws.
clreps.pl
This script massages the eps plot files that are generated when a maple worksheet is exported to LaTeX. The eps plot files generated when a worksheet is exported to LaTeX are monochrome, the lines are too thin, and there is a black border around each picture. clreps.pl restores the standard 24 colors, thickens up the lines, and removes the border. If a greyscale number does not come from a standard color, then a linear interpolation is made between the two nearest colors.
Unlike the three scripts mknotes.pl, mkindex.pl, and mkcontents.pl, clreps.pl does not come with the chisel disk. It comes in the zipfile with this worksheet. After you unzip the file, move the script to the directory X:\chisel\bin, where X is the drive letter where you have installed chisel.
Usage:
perl -S clreps *.eps will modify all of the eps files in the current directory