Return to PAV Home Page     Email to PAV    

A Scratch-Work Environment for SWP

Philip A. Viton

August 29, 2006

1 Introduction

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).

2 Instructions

There is a tiny zip file which includes a “starter” setup available here . The zip file also includes an HTML copy of this note.

  1. version.sty is typically included in your SWP distribution, in /latex/contrib/misc (for SWP5; earlier versions put it in /latex/contrib/other/misc); but if it’s not there — you should check on this before proceeding — you can obtain it from any CTAN node. Place it in your SWP LaTeX tree under tcitex/latex: a reasonable place is under contrib/misc.
  2. Next, you need to change both the shell (.shl) files and style (.cst) files for any documents for which you want to create a Scratch Work facility. In SWP, open a document of the appropriate type. Then do File -> Document Info. The name and location of the shell (.shl) file is at the bottom of the General tab; make a note of it. Then do File -> Style. The name and location of the style (.cst) file is at the bottom of the window; record it, too.

    1. Begin by opening the shell (.shl)file in a text editor. Add the lines


      before the \newtheorem statements. (If there are no \newtheorem statements, insert them somewhere before \begin{document}). Save the shell file.

    2. Now copy scratch.txt from my zip file to the clipboard. Open the style (.cst) file in a text editor, and paste in the contents of scratch.txt at the end of the file. Note that in this fragment, the text in brackets at the beginning ([scratchwork]) must exactly match (in spelling and capitalization) the argument of the \excludeversion command you put into the shell file. The next line, beginning ALIAS= controls what will appear on the tag list in SWP, and can be altered in any way you like.
    3. Finally, go to the beginning of the .cst file. You will find a section beginning [FILTER] and ending \TCIEnd. Between these, add the line


      Once again, the spelling and capitalization must exactly match what you said in the \excludeversion command in the shell file. Save and close the .cst file.

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.