|Return to PAV Home Page Email to PAV|
A Scratch-Work Environment for SWP
August 29, 2006
If you’re writing something which uses the results of computer-algebra calculations, it’s useful to have an area where you can do scratch computation, to obtain and perhaps tidy up the results before they are incorporated into the paper itself. One possibility is to open a second SWP document, do the calculations there, and then cut-and-paste as necessary. But I find it more convenient to set up a work area within the document itself: naturally, I don’t want the work area to appear when the document is typeset — at least, most of the time I don’t. In this note I explain how to set up such a facility, which I’ll call a Scratch Work area. (The same thing can be used, of course, even if you’re not doing computations: for example, to write yourself some notes on things to include or revise in the paper. This would be useful to SW users as well).
The basic idea is to use the version package: this makes it possible to define any number of non-printing environments within your document. One advantage of this approach is that it is easy change your mind and print the material if you need to: all you do is change the \excludeversion command, which you’re going to insert in the preamble of your documents, into \includeversion. (I use this idea to produce problem sets, and then problem+answer sets for my courses). Setting up the facility is straightforward, though you will need to make a few modifications to your SWP style (.cst) and shell (.shl) files. The rest of this note explains how.
One downside occurs if you are using SWP’s built-in HTML generation facility: in this case the material in scratch work area will appear in the HTML: the reason is that HTML production does not involve LaTeX, so the fact that you’ve instructed LaTeX to ignore the environment isn’t known. In this case you can use an external HTML generator like TeX4ht, or go back to the two-document solution. (For the same reason, the environment will also appear in non-typeset printing. This means that the Scratch Work area will not be useful wth SNB, unless you want to distinguish the scratch work area visually from the main text).
There is a tiny zip file which includes a “starter” setup available here . The zip file also includes an HTML copy of this note.
You are now ready to try it out.
Open a document (one which uses the shell you’ve just modified, of course) in SWP. Type a few words. Now, start a new line, and tag it Scratch Work: the tag should be available on the Item Tag popup. Type a few lines, and maybe some math. Start a new line, and remove the item tag, or else just tag the new line as Body Text. Type a few lines. Now typeset-preview the document. There should no LaTeX errors, and whatever you put into the Scratch Work section should not appear.
At this point, you may want to customize the appearance of the Scratch Work area. As distributed, it writes to a light-light gray background and sets math expressions a bit larger than “normal” math (I find that easier to read and manipulate, especially for multiple superscript levels). Non-math text appears just as it does outside the environment. It’s simple to change this, and to experiment with other settings: just do Tag -> Appearance within SWP.
You will eventually need to repeat this on the .shl and .cst files for any other document types where you want a Scratch Work area available. I’d suggest not doing this until you’re happy with the way the environment looks in your first document: that way you can cut-and-paste the [scratchwork] section from that .cst file (rather than version from scratch.txt), and you won’t have to revise the settings in every other document.