FLASHMODE

CLAUS GERHARDT

Date: May 13, 2012.

Contents

Contents
 1.  Introduction
 2.  Flashmode’s structure
 3.  Installation
 4.  Running Flashmode
 5.  Root files
 6.  Calling scripts via menus
 7.  Test files
 8.  System requirements
 9.  A Note on TeXShop-64
 10.  Links

1. Introduction

Flashmode enables simultaneous typesetting if TeXShop is used as editor for TEX or LATEX or any other common TEX variant. When Flashmode, or more precisely one of its applets, is started, it looks for the front most document in TeXShop, gets its path and after that it is hooked forever to this document as long as it stays open, i.e., a few split seconds after Flashmode has started the front most document in the TeXShop could be anything without doing any harm.

Then Flashmode checks in regular intervals (default is 0.000001 sec), the length of which is user definable—0.000001 sec are recommended for a fast Mac—, if its tex document has been modified, and if so, it initiates a save, a pdflatex run, and asks TeXShop to refresh the corresponding pdf file. Flashmode can be invoked even if a document isn’t typeset yet, but beware that its first action will be a typesetting command.

An important feature is that tex syntax errors don’t cause any error messages or disruptions of any kind, i.e., the pdf gets never corrupted, at least the pdf viewer is never aware of it, and the last refreshment is always visible; the pdf viewer will never complain.

Thus, the user never gets any error messages; the presence of errors can only be deduced from the pdf window which then doesn’t change any more; of course the errors will be reported in the log file and can be looked up.

When the tex document is unmodified, Flashmode stays put in the background with very little CPU load, i.e., Flashmode can stay open as long as one wishes without any bad side effects.

While Flashmode is active, the source document can be typeset independently by TeXShop or by other scripts or commands, especially other tex tools like bibtex can be run without any interference by Flashmode.

2. Flashmode’s structure

Flashmode uses small applications, referred to as applets, for its work. There are two sets of applets, where the members of each set use a specific shell script for typesetting. The applets in the first and largest set are called Flashmode-ts-i, 1 ≤ i ≤ 10  , and the corresponding shell script is flashmode-ts-1 which calls pdflatex (this is its default definition). The members of the second set are called Flashmode-ts-alt-i, 1 ≤ i ≤ 3  , with corresponding shell script flashmode-ts-alt-1, which is calling simpdftex (its default definition).

The applets are started by pressing the corresponding buttons in the window „Flashmode Scripts“ of the application Flashmode, namely, run Flashmode for starting any of the ten applets of Flashmode-ts, run Flashmode-alt for the three applets of the set Flashmode-ts-alt, and finally quit Flashmode to quit any of the applets.

Notice that each applet controls exactly one document and the applet that controls the document filename.tex will be quit by pressing the button quit Flashmode while filename.tex is the front most document in TeXShop.

The buttons in the window „Flashmode Scripts“ are grouped into five sets and their meaning should be self-explanatory. The maintenance scripts are used to clear Flashmode’s bookkeeping files when necessary: Whenever an applet is started it will report that it is in use by placing a corresponding notice in the Activity folder and the document that will be controlled will be marked as such by creating a so-called protocol file filename.flashmode. When an applet is orderly quit by pressing the corresponding button, these files will be deleted. However, in case of a snafu the files might be still present with the effect that either an applet is falsely reported to be active or that a document is falsely supposed to be already controlled by Flashmode, i.e., its .flashmode file still exists. In this case no Flashmode applet can be started to control it and a beep will be heard when trying it. The maintenance scripts will take care of these irregularities.

3. Installation

Copy Flashmode in the Applications folder

/Applications

4. Running Flashmode

Install the icon of Flashmode into the dock. When Flashmode is started one window will appear, Flashmode Scripts, which is used to control the applets. It is recommended to place it in the lower right corner of the screen such that it is slightly visible when working in TeXShop. You can fix the window’s position through a command in Flashmode’s Preferences.

Then adjust TeXShop for using it with Flashmode. Open an already typeset document so that both the preview window as well as the source window are present. Your screen should be large enough that both windows can be placed side by side. If you are pleased with the arrangement, open TeXShop’s preferences and check under Document the button „All windows start at fixed position“ and then press „Set with current position“ , same under Preview, uncheck the „Automatic Preview Update“ , set „Default Page Style“ to „Multi-Page“ .

Under Typesetting define the „Sync Method“ you would want to use. You should select „SyncTeX“ . Synchronization is then excellent in both directions.

Flashmode can only be used when the document has already been saved once, i.e., it should have a name. When the tex document is opened and front most in TeXShop and you would like it to be controlled by Flashmode, e.g., by any member of the first set of applets, press the button „run Flashmode“. An applet, most likely Flashmode-ts-1, will start and take control of the front document, i.e., it will check periodically, default is 0.000001 seconds, if the document has been modified, and if so it will issue a typesetting command.

TFhlaussh,m tohdee dowcounme’tn dtetsehcotu alndy nemvoedrifibcea staiovnesd! manually, since then

On an 8-core Mac Pro the typed text will be instantaneously shown in the preview window in case of a 50 pages document, if the time interval is set to 0.000001 seconds. Even for a 300 pages book the delay will be only 2-3 seconds.

Since Flashmode will never complain or show an error message, your only way of spotting a problem is by watching the preview window which won’t change anymore when the source file has been modified.

Then you can open the log, or even better, press the button „pdflatexc“ , then the cause of the error will be shown in your source file. Anyway, the error shouldn’t be too far from the present position of the cursor.

Notice that up to ten documents can be simultaneously controlled by Flashmode and three additionally by the applets from „Flashmode-alt“.

When a document should be released from Flashmode’s control, make it front most in TeXShop and press the button „quit Flashmode“, then the corresponding applet will quit.

The provided shell scripts require first line parsing for documents
using pdflatex, pdftex, context, xelatex or xetex i.e., the first line
of the corresponding source files should look like

%&pdflatex  
%&cont-en  
%&pdftex  
%&xelatex  
%&xetex

if you want the document to be typeset in pdflatex, context, plain tex, xelatex or xetex.

Only if you want to use the routine „dvi ->  ps ->  pdf“ , i.e., typesetting with simpdftex, then no special first line is required, in fact it is not allowed, except when using the Applescript „simpdftex complete“ which ignores the first line.

5. Root files

When writing a book in LATEX one usually has a root file and the chapters are loaded through the „include“ command. In this situation the chapters are the target files for Flashmode though the typesetting’s target has to be the root file. A smooth interaction can be accomplished by inserting

%SourceDoc rootName.tex

in one of the first three lines of you chapter file, where „rootname“ is the name of your root file, and in the present situation it is assumed that the chapter file and the root file are in the same directory. If this is not the case, then the relative path to the root file has to be given like e.g.,

%SourceDoc ./rootName.tex

TcaenXSehiothperusbees u aseddiffceorenncturrpehnrtalyseotroyoinudiccaatnettelhle T reoXoSthofiple wtohiucshe
its old settings by issuing the command in the terminal
defaults write TeXShop UseOldHeadingCommands YES

6. Calling scripts via menus

Additional scripts can be triggered from the menus „Bibdesk, Makeindex, Metapost, Htlatex, Xelatex, Scripts and Templates“ . Most of these Applescripts are stored as subroutines in

~/Library/Application Support/Flashmode/Applescripts-modular

Some scripts can be triggered by a keystroke when Flashmode is the front application.

The scripts „mathmacros.sty“ resp. „mathmacrosB.sty“ in the „Templates“ menu open personal .sty files which have to located in

~/Documents

If you want to use these commands for your personal files, you have to create these files first. Similar arguments apply to the scripts „PaperTemplate“, „LetterTemplate“, „LetterTemplate Private“ and „LetterTemplate Special“ which refer to tex files with corresponding names located in the above folder.

If you don’t know what a script does, open the script in Script Editor and read the short explanation.

7. Test files

In the folder

~/Library/Apple Support/Flashmode/Test-files

are minimal test files for articles or books that should run with Flashmode and a useful template for using metapost via the package mfpic. If they aren’t typeset by Flashmode then there is probably something wrong with your set up.

8. System requirements

Flashmode requires OS 10.6 or better; a large screen is recommended.

9. A Note on TeXShop-64

There is a 64-bit version of TeXShop to be used in Lion called TexShop-64. Please, rename the application to TeXShop, then Flashmode will work just fine with it.

10. Links

Flashmode

Home page, TEXHelpers, TEX Switcher, pdfselect, TEX Scripts, Books, Preprints, Former Students, Veranstaltungen, Lecture Notes