WhizzyTeX1
An Emacs minor-mode
for incremental viewing of
LATEX documents

Didier Rémy

Version 1.1.3, October 27, 2004

Abstract: WhizzyTeX is an Emacs minor mode for incrementally viewing LATEX documents that you are editing. It works under Unix with gv and xdvi viewers, but the Active-DVI viewer will provide much better visual effects and offer more functionalities.

Table of Contents



1  Installation

WhizzyTeX is designed for Unix plateforms2.

To use WhizzyTeX, you need Emacs or XEmacs, latex2e, and bash installed, and at least one DVI or Postscript previewer, such as advi, xdvi, or dvips combined with gv.

WhizzyTeX has been developed under Linux Redhat 7.2 but has not been extensively tested on other platforms. However, LATEX and Emacs are quite portable and possible compatibility problem with the bash shell-script should be minor and easily fixable.

Get the source whizzytex-1.1.3.tgz from the distribution, uncompress and untar it in some working directory, as follows:
gunzip whizzytex-1.1.3.tgz
tar -xvf whizztex-1.1.3.tar
cd whizzytex-1.1.3
Then, the installation can be automatic (default or customized), or manual.

Warning!
Many Linux installations make xdvi a shell-script that erroneously end with the line xdvi.bin "$@" instead of exec xdvi.bin "$@". The later is needed to preserve the process id, so that signals sent to xdvi are correctly received and handled by xdvi.bin.

Since correct signal handling is crucial for WhizzyTeX, and this problem is so common we provide a script to check your configuration with the command
./checkconfig
By default, this check is performed by automatic installation below.

1.1  Automatic installation

By default, shell-script whizzytex will be installed in /usr/local/bin/ and all files will be installed a subdirectory of /usr/local/share/whizzytex/ but the documentation, which will be installed in /usr/local/share/doc/whizzytex/. Moreover, Emacs-lisp code will not be byte-compiled.

For default installation, just type:
make all
This will create a Makefile.config file (only if nonexistent) by taking a copy of the template Makefile.config.in. This will also check the Makefile.config (whether it is the default or a modified version) against the software installed on your machine. If you wish to change the default configuration, or if your configuration is rejected, see ``Customizing the installation'' below. This will also prepared configured versions of the files for installation.

Finally, to install files, become superuser (unless you are making an installation for yourself) and do:
umask 022 make install
The first line ensures that you give read and execute permission to all.

See Using WhizzyTeX (Section 2) to test your installation.

1.2  Customizing the installation

To customize the installation, you can edit Makefile.config, manually. You may also use either the command
./configure
This command may be passed arguments to customize your installation. Call it with the option -help to see a list of all options. By default, the configuration is not interactive. However, you may call it with option -helpme to have the script do more guessing for you and prompt for choices if needed.

Note that by default, the Emacs-lisp code whizzytex.el is not byte-compiled. You need to pass the option -elc to configure in order to byte-compiled it.

Checking Makefile.config
A misconfiguration of your installation, or ---much more subttle--- a misconfiguration of other commands (it appears that some installations wrap scripts around standard commands that are sometimes incorrect and break their normal advertized interface) may lead to systematic errors when launching WhizzyTeX. To prevent delaying such obvious errors, some sanity checks are done after Makefile.config has been produced and before building other files. These include checking for mandatory bindings (useful for manual configuration) and for the conformance of initex, latex, and viewers commands to their expected interface.

Checking viewers interface implies simulating a small WhizzyTeX session: a small test file is created for which a specializled version of latex format is built and used to run LATEX on the test file; finally, required viewers are tested on the DVI output, which opens windows, temporarily.

If the sanity check fails, at least part of your configuration is suspicious. If some windows remain opened, your confirguration is likely to be erronesous (and so, even if not detected by the script).

However, if you really know what you are doing, you may bypass the check by typing make config.force, which will stamp your Makefile.config as correct without checking it. Checking compliance to viewers interface is also bypassed if you you do not have a connection to X. Conversely, you may force checking manually by typing ./checkconfig.

At the end of customization, proceed as described in ``Automatic installation'' (Section 1.1)

Customization notes
By default, WhizzyTeX assumes the standard convention that latex is the command name used to call LATEX, initex, the command name used to build a new format, and that the latex predefined format is latex.

If your implementation of LATEX uses other names, you may redefine the variables INITEX, LATEX, and FORMAT accordingly in the file Makefile.config. For instance, platex could be use the default configuration
INITEX = iniptex
LATEX = platex
FORMAT = platex
BIBTEX = jbibtex
This would be produced directly with the configuration line:
./configure -initex iniptex -latex platex -format latex -bibtex jbibtex
If you wish to run WhizzyTeX with several configurations, you must still choose a default configuration, but you will still be able to call WhizzyTeX with another configuration from Emacs (see Section 3.1.2 below).

It is possible to customize the set up on a per-user basis by creating a file ~/.whizzytexrc containing, for example, the following lines:
INITEX = iniptex
LATEX = platex
FORMAT = platex
BIBTEX = jbibtex
During the configuration, you must at least choose one default previewer type among advi, xdvi, and ps, and at most one default previewer for each previewer type you chose. You will still be able to call WhizzyTeX with other previewers from Emacs, via Emacs configuration (see Section 3.1.1).

1.3  Manual installation

Since WhizzyTeX only need three files to run, installation can also be done manually:

1.4  Automatic upgrading

For convenience, the distribution also offers a facility to download and upgrade new versions of WhizzyTeX (this requires wget to be installed). If automatic upgrading does not work, just do it manually.

All operations should be performed in the WhizzyTeX top directory, i.e. where you untar whizzytex for the first time, that is right above the directory from were you made the installation. We assume that have created a link to the current version subdirectory:
ln -s whizzytex-1.1.3 whizzytex
(the manager will then update this link when version changes). Alternatively, you can also use the full name whizzytex-1.1.3 in place of whizzytex below. The main commands are:
make -f whizzytex/Manager upgrade
make -f whizzytex/Manager install
The command upgrade will successively download the newest version, unpack it, copy the configuration of the current version to the newest version, and bring the newest version up-to-date. The command install will install files of the newest version.

The following command will (re-)install an old version:
make VERSION=<version> download downgrade install

2  Using WhizzyTeX

2.1  Loading whizzytex.el

Maybe, whizzytex is already installed on your (X)Emacs system, which you may check by typing:
ESC x whizzytex-mode RET
If the command is understood, skip this section. Otherwise, you should first load the library whizzytex.el or, better, declare it autoload. To do this permanently, include the following declaration in your Emacs startup file (which probably is ~/.emacs if you are using Emacs):
(autoload 'whizzytex-mode
"whizzytex"
"WhizzyTeX, a minor-mode WYSIWIG environment for LaTeX" t)
This asumes that whizzytex.el has been installed in your (X)Emacs load-path. Otherwise, you may either adjust the load-path appropriately, or replace whizzytex by the full path to the file whizzytex.el, which depends on your installation and can be obtained by typing make where in the installation root directory. For instance, if you are using Emacs, the default location for whizzytex.el is /usr/local/share/whizzytex/lisp/whizzytex.el (but it will be different if you are using XEmacs or a customized installation).

2.2  Quick start

WhizzyTeX runs as a minor mode of Emacs to be launched on a LATEX Emacs buffer. The extension of the buffer should be .tex. WhizzyTeX also understands .ltx extensions, but gives priority to the former when it has to guess the extension. Other extensions are possible but not recommended.
The file attached to the buffer must exists and either be a well-formed LATEX source file, or be mastered, i.e. loaded by another LATEX source file. Thus, whenever the buffer does not contain a \begin{document} command), WhizzyTeX will search for its master file, asking the user if need be, so as to first launch itself on a buffer visiting the master file. In particular, an empty buffer will be considered as beeing mastered, which may not be what you intend.
To start WhizzyTeX on either kind of buffer, type:
ESC x whizzytex-mode RET
By default, this should add new bindings so that you can later turn mode on and off with key strokes C-c C-w. This will also add a new menu Whizzy in the menu bar call ``the'' menu below. (If you are using the auctex, your may use other configuration key strokes to avoid clashes (see online emacs-help).

When whizzytex-mode is started for the first time on a new buffer, it attempts to configure buffer local variables automatically by examining the content of file, and using default values of global bindings.

You may customize default settings globally by running appropriate hooks or locally by inserting appropriate comments in the source file ---see the manual below.

You may also change the settings interactively using the menu, or tell whizzytex-mode to prompt the user for confirmation of file configuration by passing prefix argument 4 (using, for instance, key sequence C-u C-c C-w).

2.3  Editing

Once whizzytex-mode is on, just type in as usual. WhizzyTeX should work transparently, refreshing the presentation as you type or move into your LATEX buffer.

Additionally, a gray overlay is put outside of the current slice (the slice is the region of your buffer under focus, which is automatically determined by WhizzyTeX). When a LATEX error occurs and it can be localized in the source buffer, a yellow overlay also is put on the region around the error, and removed when the error is fixed.

Furthermore, when an error is persistent for several slices or some amount of time, the interaction-buffer will pop up with the error log (this option can be toggled on and off with the Auto interaction menu entry).

The mode line also contrains a brief summary of the status of WhizzyTeX. When whizzytex-mode is on, the line contain Whizzy.N when N is a numeric indication of the load in number of buffer changes between two slices, so the higher, the slower. However, WhizzyTeX is changed to Whizzy-ERROR when ERROR is either FORMAT, LATEX, or SLICE, which indicate an error in the format, the full document, or the slice, in this order. That is, if there is both an error in the format and the slice, only the FORMAT error will be shown.

2.4  Error recovery

WhizzyTeX makes a good attempt at doing everything automatically. However, there remains situations where the user need to understand WhizzyTeX ---when WhizzyTeX does not seem to understand the user anymore.

For that purpose, WhizzyTeX report processing and error messages in its interaction window. Thus the first help for debugging is always to look at interaction window (buffer *filename.tex* (where filename stands for the name of the file associated with the main buffer in case several files are composing your document).

This window will pop up and down automatically when an error persists or disappear. For debugging, you may unset Auto interaction so as to see the interaction buffer permanently. You may also unset Auto Shrink output to keep all log.

The View Log... menu entry can be used to view log files of last actions performed by whizzytex.

2.5  Error during initialization

The most delicate part of WhizzyTeX is when starting whizzytex-mode, and usually for the first time in a new buffer, since at that time all kinds of initialization errors may occur (in addition to LATEX errors.

WhizzyTeX will attempt to identify the error and report appropriate messages in the interaction buffer. (In case an error occurs ---or nothing happens--- always have a look at the interaction buffer, even if it did not prompted automatically.)

Most frequent initialiazation errors are described below, in chronological order.

Emacs fails during setup
This is all under Emacs, so easily under control. Normally, Emacs should report error messages. See the documentation for explanations.

In case, of uncaught fatal errors, you may ESC X toggle-debug-on-error to get help from Emacs, and try to fix the problem.

Emacs cannot find whizzytex
This should typically be an installation problem, where the variable whizzytex-command-name is erroneous (maybe you need to give the full path). Try to evaluate (shell-command whizzy-command-name) in the minibuffer, which of course should fail, but only after the command has been reached.

WhizzyTeX cannot build a format
Then WhizzyTeX will refuse to start.

The problem could result from an abnormal interaction between your macros and WhizzyTeX macros, but this situation seems rather unfrequent. So there is most probably an error in your macros. Try to compile LATEX your file.

By default the interaction window will pop-up with an section of the format log. If this is not enough, you may need to view log files. However, log files are normally removed when WhizzyTeX exits. To keep log files on, you must retart WhizzyTeX in debug mode (select the debug mode in the menu and restart WhizzyTeX). Then, you can check the format log and if necessary the command with which WhizzyTeX has been launched. (Once the bug is fixed, you should switch off the debug mode, which may slow down WhizzyTeX.)

WhizzyTeX cannot launch the previewer
Usually, this is because whizzytex received wrong previewer parameter. See the command echoed in the interaction buffer or try to evaluate (whizzy-get whizzytex-view-mode).

Other errors
There are two remaining problems that could happen at launch time, but that are not particular to launch time: WhizzyTeX could not recompiled the whole document or the current slice. However, these should not be fatal. In the former case, whizzytex will proceed, ignoring the whole document (or using the slice instead if you are in duplex mode). In the later case, whizzytex will replace the slice by an empty slice ---and print a welcoming document, as if you launch WhizzyTeX outside of any slice.

2.6  Errors during normal edition

After initialization time, WhizzyTeX will keep recompiles slices as you type or move, but also recompiles the format and the whole document when you save a file. Each of this step may failed, but this should not be fatal, and Emacs should report the error, possible pop up the interaction window, and continue.

Whizzytex fails on the current slice
This should not be considered as an error, it must happen during edition. In particular, WhizzyTeX is not much aware of LATEX and could very well slice in the middle of the typesetting of an environment or a macro command. This should not matter, since the erroneous slice will be ignore temporarily until the slice is correct again.

Whizzytex keeps failing on the current slice
The slice can also be erroneous because the Emacs did not correctly inferred where to insert the cursor, which may slice erroneous, although what you typed is correct. Hopefully, this will not occur too often, and disappear as you move the point. It should also disappear if you switch off both Point visible and Page to Point options, which is actually a good thing to do when you suspect some misbehavior. This will make WhizzyTeX more robust, but less powerful and more boring.

Whizzytex does not seem to slice at all
The interaction window does not produce any output. Try to move in the slice, or to another slice.

If nothing happens, check the interaction window, to see if it did attempt to recompile the slice. If nothing happens in the interaction window, check for Emacs messages (in the *Messages* buffer). You may also check for the presence (and content) of the slice by visiting _whizzy_filename.tex or
_whizzy_filename/input/_whizzy_name.new
If neither file exists, it means that Emacs did not succeed to slice, which you may force by evaluating (whizzy-observe-changes t). This can be run in even if whizzytex-mode is suspended, which may avoid automatic processing of slices, and their erasure.

If the slice is present, you may try to compile it by hand (outside of Emacs) with
latex '&_whizzy_filename' _whizzy_filename.tex
and see if it succeeds.

Reformatting failed
Formatting errors are fatal during initialization, but accepted once initialized. In case of an error during reformatting, WhizzyTeX will ignore the error and continue with the old format. This means that new macros may be ignored leading to further slicing errors. When rebuilding the format failed, the mode-line string will display the suffix FMT until the error is fixed. See the interaction buffer or select format from the log... menu entry).

You may also force reformatting by typing the reformat command in the interaction buffer.

Whizzytex cannot process the whole document
This is very likely a problem with you document, so try to LATEX it first. There is a small possibility of strange interaction between your macros and WhizzyTeX package. Try to turn options Page to Point and Point visible off and retry. This will make WhizzyTeX more robust (but also less powerful and more boring).

2.7  Debugging

If you are completely lost, and none of the above helped, you may need some debugging. If this is your first attempt at WhizzyTeX, you should suspect your configuration. You should them try with the examples of the distribution. Otherwise, you may rollback to a file and configuration that used to work, and make incremental changes.

You can turn emacs debug mode on and off with
ESC x toggle-debug-on-error RET
You can also turn whizzytex debug mode on and off by typing either line in the interaction window:
trace on
trace off
If whizzytex fails at lauch time, you may also use the option -trace of file configuration (see Section 3.1.2).

3  Manual

This section describes how to use and parameterize WhizzyTeX. So as to avoid redundancy, most of the documentation is only available online in Emacs, from the Help entry of the menu by following hyperlinks. Alternatively, you can type
ESC x describe-function RET whizzytex-mode RET
(In XEmacs, you may need to use
ESC x hyper-describe-function RET whizzytex-mode RET
instead of describe-function to see hyper-links.)

Section 3.1, 3.2 and 3.3 are also available as online help.

3.1  Configuration

3.1.1  Emacs global configuration

See Emacs help for whizzy-default-bindings and whizzytex-mode-hook for list of bindings.

The Emacs on-line help for whizzytex-mode lists all user-configurable variables, which may be given default values in your Emacs startup file to be used instead of WhizzyTeX own default values.

3.1.2  File-based configuration

A configuration line is one that starts with regexp prefix ``^%; +'' followed by a configuration keyword. If two configuration lines have the same keyword, only the first one is considered. The argument of a configuration line is the rest of the line stripped of its white space.

The keywords are:
whizzy-master
<master>
This only makes sense for a file loaded by a master file. <master> is the relative or full name of the master file. Optional surrounding quotes (character ") stripped off, so that "foo.tex" and foo.tex are equivalent.

whizzy-macros
<master>
This is equivalent to whizzy-master <master>, but for a file containing macros. The file is not sliced while editing, but saving it reformats the master.

whizzy
[ <slicing> ] [ <viewer> [ <command> ] ]
[ -mkslice <command> ] [ -mkfile <command> ]
[ -tex <suffix> ] [ -initex <initex> ] [ -latex <latex> ] [ -fmt <format> ]
[ -bibtex <bibtex> ] [ -dvicopy <command> ] [ -watch ] [ -duplex ] [ -trace ]
All arguments are optional, but if present they must appear in order and on a single line:
<slicing>

determines the way the document is sliced (see section 3.2).

<viewer>

is the type of viewer and can only be one of -advi, -xdvi, or -ps (see section 3.3)

-display <display>

specifies which X display to show the DVI previewer in, such as :0.1 for multidisplay set-ups.

<command>

is optional and is the command used to call the viewer (of course, it should agree with <viewer>).

-mkslice <command>

tells WhizzyTeX to use <command> to preprocess the slice. The command <make> will receive one argument _whizzy_basename.new and should produce _whizzy_basename.tex (or _whizzy_basename.ltx if the extension of the master file is .ltx). By default, mv is simply used.

The Unix make can itself be used as a preprocessor (with an appropriate Makefile). However, one may have to work around make's notion of time (using FORCE), which is usually too rough. This is safe, since WhizzyTeX tests itself for needed recompilations.

-mkfile <command>

executes ``<command> <filename>'' before recompiling every time a buffer is saved. The argument ``<filename>'' is the buffer-file-name path relative to the path of the master file directory.

-makeindex <command>

uses ``<command> <filename.idx>'' for rebuilding the index instead the default ``<makeindex> <filename.idx>''. If ``<command>'' is false, then do not attempt to rebuild the index.

-bibtex <bibtex>


uses <bibtex> for the bibtex command instead of the value assign to BIBTEX in Makefile.config (or whizzytex)

-initex <initex>


uses <initex> for the initex command instead of the value assign to INITEX in Makefile.config (or whizzytex)

-latex <latex>


uses <latex> for the latex command instead of the value assign to LATEX in Makefile.config (or whizzytex)

-fmt <format>


uses <format> for the latex format instead of the default value, usually fmt (see configuration).

This can either be used in combination with -latex and -initex, or alone. For instance, hugelatex could be used (depending on your LATEX configuration) to build a larger format to process huge files.

-dvicopy <command>


uses <command> instead of the default (mv) to copy DVI files (from FILE.dvi to FILE.wdvi). This can be used with command dvicopy so as to expand virtual font, which advi does not understand yet)

-watch

watches other files than just the slice (see Section 3.4).

-duplex

launches another window with the whole document (which is recompiled every time the source buffer is saved).

With -advi previewers, both views communicate with Emacs and can be used to navigate through source buffers and positions.

-trace

traces all script commands (for debugging purposes only.)

For instance, a typical configuration line will be:
   %; whizzy subsection -dvi "xdvi -s 3"
It tells whizzytex to run in subsection slicing mode and use a dvi style viewer called with the command xdvi -s 3. This is also equivalent to
   %; whizzy subsection -dvi xdvi -s 3
since Emacs removes outer double-quotes in option arguments.

A more evolved configuration line is:
   %; whizzy -mkslice make -initex iniptex -latex platex -fmt platex
It tells WhizzyTeX to use iniptex and platex comands instead of initex and latex and to use the format file platex.fmt instead of latex.fmt. Moreover, it should use make to preprocess the slice.

whizzy-paragraph
regexp
This sets the Emacs variable whizzy-paragraph to regexp.

3.2  Modes

WhizzyTeX recognizes three modes slide, section, and document. The mode determines the slice of the document being displayed and indirectly the frequently of slicing.

Note that in any mode but none slices are always included in the file beeing editing and files that it may include. Thus, when slice delimitors are not found, the slice default to the whole file. The slice may also be empty if the cursor is located before \begin{document} or after \end{document}.
slide


The mode slide is mainly used for documents of the class seminar. In slide mode, the slide is the text between two \begin {slide} comments (thus, the text between two slides is displayed after the preceding slide).

In slice modes, overlays are ignored i.e. all overlays all displayed in the same slide, unless a command \overlay {n} occurs on the left of the point, on the same line (if several commands are on the same line, the right-most one is taken), in which case only layers p <= n are displayed.

section
In section mode, the slice of text is the current chapter, section.

subsection
As section but also slice at subsections.

paragraph
The paragraph mode is a variation on section mode where, the separator whizzy-paragraph is defined by the user (set to two empty lines by default) instead of using \section and \subsection commands. subsection.

document
The document take the region between \begin{document} and \end{document} as the slice. Hence it defaults to the file when the file is a slave, which does not contain \begin{document}.

none
In none slicing mode, there is no sectioning unit at all and the whole document is recompiled altogether. Currently, pages are not turned to point and the cursor is not shown in document mode, because full documents are not sliced. (A slicing document mode could be obtained by working in paragraph mode, with an appropriate regexp.)

3.3  Viewer types

See help for whizzy-viewers.

The previewer types can have three possible values: -ps, -dvi, or -advi.

The previewer type should agree with the previewer command in several ways: Then, the previewer command is the command to call the previewer. This string will be passed as such to the WhizzyTeX shell-script. Note that the name of the dvi or postscript file will be appended to the previewer command.

3.4  Watching other files

WhizzyTeX is designed to watch other files and not just the slice saved by Emacs. In fact, it watches any file dropped in the pool directory. For instance, if your source file uses images, you can just change the image and drop the new version in the pool. Then WhizzyTeX will pick the new version, move it to the working directory and recompile a new slice. Be aware of name clashes: if you drop a file in the pool, it will automatically be move to the working directory with the same name, overriding any file of the same name sitting there.

However, activity is entirely controlled by Emacs, since after every iteration WhizzyTeX waits for Emacs to send a new command (usually the empty command that means iterate again). Hence, other files will only be taken into account at the next iteration. If you really wish these files to be watched you need to instrument emacs to send and empty line input to the interaction buffer regularly, even when idle.

3.5  Frequency of recompilation

To obtain maximum WhizzyTeX effect, a new slice should be save after any edition changed or any displacement that outside of the current slice. However, to avoid overloading the machine with useless and annoying refreshments, some compromise is made, depending on Emacs several parameters: edition v.s. move Emacs last commands, successful v.s. erroneous last slice, and the duration of last slice recompilation. This usually works well. However, different behavior may wish to be obtained in different situations. For instance, when editing on a lab-top, one may wish to save batteries by keeping the load rather low, hence not using the full power of the processor. Conversely, one may wish WhizzyTeX to be as responsive as possible. There is an function whizzy-load-factor that control a variable of the same name, which can be used to adjust the responsiveness (by increasing or decreasing the load-factor). This simply adds extra delays between slicing.

The format is automatically recompiled at the beginning of each session, and whenever the buffer containing the file is saved. That is, to load new packages or define new global macros (before the \begin{document}), it suffices to save the current file.

3.6  WhizzyTeX-ing macro files

Macro files can be WhizzyTeX-ed as well. The effect is them only to automatically call reformat when the file is saved. Files can also be declared as macro-files with whizzy-macro file configuration keyword (see Section 3.1.2), which argument should then indicate the master file. Files with .sty extension are by default considered as macro files and their master file is guessed if possible.

3.7  Cross-references, page and section numbers

The slice is always recompiled with the .aux file of the whole document. In paragraph mode, cross references and section numbers are recompiled whenever the buffer itself is saved (manually). The recompilation of the whole document is off in slide mode.

4  Viewers

4.1  Viewing with Active-DVI

Active-DVI is a DVI previewer with several additional features. In particular, it recognizes extra specials, some of which are particular useful for whizzytex that allows a two way communication between the source Emacs buffer and the previewer:

4.2  Defining your own previewer

To use your own command as a previewer, you must choose either type -dvi or -ps . In particular, your previewer should accept SIGUSR1 (for -dvi) signal or SIGHUP (for -ps) signal and respond by reloading the file.

4.3  Viewing with acroread

This does not work because they is no simple way to tell acroread to reload its file in batch.

5  Customizing the document under WhizzyTeX

WhizzyTeXattempts to make the slice appears as much as possible as in the full document, so that all typesetting adjustments, including overfull boxes, etc. can be fixed under WhizzyTeX. (Some tricks, such as showing the cursor, may disturb the presentation, but locally.)

Still, one may wish to permanently or temporarily give the document another appearance when under WhizzyTeX. For instance, you may wish to witch to draft mode under WhizzyTeX(maybe using a few Active-DVI tricks to include annotations) and use a normal mode under regular processing.

This can be achieved by defining macros in a file whizzy.sty in the LATEX path that will be automatically loaded by WhizzyTeX at the end format building. This file can be be placed in your macro directory and be used for all documents (you may thus customize WhizzyTeXitself), or in the current directory and be used for only some documents.

You may also use the Emacs variable whizzy-customize (that can be set interactively from the menu) to define a few LATEX commands that will be inserted at the beginning of each slides. This alone or in combination with whizzy.sty allows for a per-session rather than per-document customization. Moreover, the customization may be easily changed in the middle of a session. For instance, I frequently set this variable to \large to temporarily enlarge the text.

6  WhizzyEditing

Requires a recent version of Active-DVI (later that the CVS version of 01/11/2003)
When used together with Active-DVI, WhizzyTeX can be made much mode powerful. In particular, it is not difficult to lift WhizzyTeX from an incremental viewer to an assistant editor.

Active-DVI provides a notion of active boxes (specified with advi \special annotations. When Active-DVI is put in edition mode, active boxes are drawn on screen and can be move or resized with the mouse. When the mouse is released, the new size or position is printed on standard output together with the action to be taken and received by emacs watching the output. Emacs has then enough information to adjust some dimensional parameters in the source buffer. Just after this edition, the new slice is processed and the new position is displayed. Thanks to the short incremental loop, this almost appears as if actions where executed by Active-DVI itself. This dream has now become real...

Active-DVI provides one general editing command used by WhizzyTeXTeX for all mouse editing. The syntax of this command is
\adviedit[tag]{< options>}{< body>}
where < options> is a comma separated list of bindings. according to the keyval package. Each binding is either of the form < field>=< float> where < field> ranges either other letters x, y, h, w, d in lowercase or uppercase, or other unit=< dimension>.

The latter specifies the unit, which default to 1em.. The former defines values for the corresponding fields. Lowercase letters mean that fields are whizzy-editable, while uppercase letters are not. Then body, is then placed in an \hbox at coordinates (x, y) relatively to the current position. Moreover, a virtual box of width w, height h, and depth d is draw at that position when editing is made active. The box can this float around the current point and has no dimension. However, a box with no coordinates specified is fixed and has the dimensions of w, h, and d. When not specified, these fields takes the value of the box in which body is typeset. All dimensions x, y, w, h, and d are bound to advix, advix, adviy, adviw, advih, and advid macros during the evaluation of < body>.

See the example example/edit/main.tex in the distribution and the Active-DVI manual, which provides examples of whizzy-editable glue, boxes, minipages, etc..

Whizzy-editable objects can be nested. All parameters are reset to default values, within the new object. Sometimes, emacs may be confused and take an object for another. In these rare cases, the two objects can use the < tag> argument to be distinguished. This argument does nothing but being passed to Active-DVI and sent back to Emacs to identified the object exactly.

7  An overview of the implementation

In short, WhizzyTeX is selecting a small slice of the document that you are editing around the cursor (according to the selected mode) and redisplay the slice incrementally as it changes through edition. The rest of this section briefly describe these three parts3, and their interactions.

7.1  Emacs code

The main trick is to use post-command-hook to make Emacs watch changes. It uses buffer-modified-tick to tell if any editing has actually occurred, and compare the point position with the (remembered) position of the region being displayed to see if saving should occur. It uses sit-for to delay slicing until at least the time of slice computation has ellapsed since last saving, a significant number of editing changes has occurred, or iddleness.

WhizzyTeX can also display the cursor position, in which case slices are also recomputed when the cursor moves, but with lower priority.

7.2  LATEX code

The main TeX trick is to build a format specialized to the current document so as to avoid reloading the whole macros at each compilation. This is (almost4) entirely transparent, that is, the source file does not have to understand this trick.

This is implemented by redefining \documentclass which in turn redefines \document to execute \dump (after redefining \document to its old value and \documentclass so that it skips everything till \document). This is robust ---and seems to work with rather complex macros.

The specialized format can be used in two modes: by default it expects a full document: it them dumps counters at sectioning commands (chapters, sections, and subsections). This is useful to correctly numberred sections and pages on slices.

There are also a a few other used to get more advanced behavior, especially to dump source line numbers and file names so that the previewer can transform clicks into source file positions.

When building the format, WhizzyTeX also look for a local file of name whizzy.sty, which if existing is loaded at the end of the macros. This may be used to add other macros in whizzy mode, e.g. some TeX environments may be redefined to changed they type setting, according to whether the current line is inside or outside the environment. (We have written such an extension for an exercise package that sends the answers at the end in an appendix, unless the cursor is inside the answer, in which case the answer is in-lined.)

7.3  Bash code

There is no real trick there. This is a shell-script watching the pool (a directory where slices and other new version of files must be dropped). It them recompiles a slice and wait for input (in stdin). It recognizes a few one-line commands as input reformat, dupplex, and by default just watch for the presence of a new slice. It recompiles the format file (and the page and section number, but in batch mode) whenever the source file (its Unix date) has changed and recompiles the slice whenever it is present (since WhizzyTeX renames ---hence removes--- the slice before processing it).

If the file has been recompiled successfully, it triggers the previewer (ghostscript or xdvi) so that it rereads the dvi or ps file. Otherwise, it processes the TeX log file and tries to locate the error. It then sends part of the log file with annotations to the *TeX-shell* buffer from which Emacs has been WhizzyTeX, so that Emacs can report the error.

7.4  Interaction between the components

The control is normally done by Emacs, which launches and kills the Unix daemon. Quitting the previewer should be noticed by the daemon, which tells Emacs to turn mode off before exiting.

Muliple WhizzyTeX running on the same file would certainly raise racing conditions between files and would not make sense. For that purpose, the daemon pid is saved in a file and WhizzyTeX will kill any old WhizzyTeX process on startup.


1
WhizzyTeX is free software, Copyright ©2001, 2002 INRIA and distributed under the GNU General Public License (See the COPYING file enclosed with the distribution).
2
It has been reported to successfully work on Windows under Cygwin---See the FAQ.
3
This section is not quite up-to-date, hence it puts emphasis on the original design, but several aspects have changed significantly since the first version. Implementation of more recent features is thus omitted.
4
\begin{document} should be typed as such without any white white space

This document was translated from LATEX by HEVEA.