Part VI
Appendices

A  Adding Additional Automatic Picture Converters
     A.1  Using Irfan-View instead of ImageMagick
     A.2  Removing an automatic conversion
B  Changing the HyperLink layout
     B.1  Changing the appearance
     B.2  Arbitrary markers
C  The Explicit-Package Approach to TeX4ht
     C.1  Using the explicit package approach
     C.2  Testing the explicit-package approach
     C.3  Providing options
     C.4  Configuration files
D  The TeXConverter
     D.1  Obtaining the TeXConverter
     D.2  Setting up the TeX Converter
     D.3  Converting a document to HTML
E  Adding a Directory to Your Path
     E.1  Windows NT
     E.2  Windows 95/ 98
F  Older versions of ImageMagick
G  Advanced Configuration of htrun
H  Advanced Configuration of swpinstall.exe
I  SWP Version 4+
     I.1  Some Version 4 issues
     I.2  A comparative test of HTML production
J  Legal Matters
     J.1  Disclaimer of liability
     J.2  Redistribution

Appendix A Adding Additional Automatic Picture Converters

First, of course, you will need to obtain the necessary software. The next step is usually to write a batch file which calls the new converter, with any necessary switches. This batch file will be called from within TeX4ht/SWP with either three or four arguments:

  1. Optional: The path to your picture, as it appears in SWP. Note that this will appear with Unix syntax (see below) and may be empty. Example: H:/mydir1/mydir2/
  2. The filename of your picture as it appears in SWP, eg: mygraf
  3. The picture’s extension, including the leading period (.), eg .abc
  4. The desired extension of the Web image including the leading period (.) as supplied by TeX4ht; unless you explicitly change this, the extension will be .gif

You cannot know in advance whether your batch file will be called with three or with four parameters (this depends on the way your Save Options are set up in SWP, and may change from document to document). You will need to check this in the batch file itself: this amounts to checking whether parameter 4 is empty: see tex4ht-im.bat for the basic idea. Thus in terms of the batch file, you will be converting either #1#2#3 to #2#4 (if you are called with 4 parameters) or #1#2 to #1#3 (if you are called with 3). You should test your batch file outside the TeX4ht context before going any further; be sure to test it with both 3 and with 4 parameters.

Next, you need to tell TeX4ht to run your batch file when it encounters your picture type. You will do this for both standard SWP and for Portable LaTeX documents.

It is important to understand how this will work. Your graphic’s path (if one is provided) will appear in Unix form, with separators / instead of the normal DOS \ characters. This is not usually acceptable to DOS. We use the TeX4ht filter htcmd -slash to change the separators around. But this means that you will not be able to use any program which uses the / character for its own purposes, because htcmd will change it, too. (That was a problem with the .wmf support via IrfanView, which needed /convert as a switch: that’s why I wrote xiview.exe to get round it).

Now to work. For purposes of illustration, suppose you are providing automatic conversion for a picture type abc which will use the batch file tex4ht-abc.bat to do the work. We begin with the standard SWP support. Open swpht\tcitex\tex\latex\tex4ht\swpframe.sty (where swpht is your top-level SWP directory) in a text editor.

Now we do the same for Portable LaTeX support. Open swpht\tcitex\tex\latex\tex4ht\portgraf.tex in a text editor. Note that each block of graphics-control statements contains two \Configure{graphics*} statements, one for uppercase and one for lowercase extension.

Now when TeX4ht/SWP finds a picture with extension .abc (or .ABC), it will use tex4ht-abc.bat to convert it to a web image.

A.1 Using Irfan-View instead of ImageMagick

As mentioned in the main text, TeX4ht/SWP is pre-configured to use ImageMagick to convert the following image types to gif: .pcx .bmp .png .jpg .wpg .tif . But Irfan-View can also do these, and may be faster, so you may want to consider switching converters. Irfan-View also claims to handle .eps graphics, but in my limited experience it has problems here, so I recommend handling these with GhostScript/ImageMagick.

For the graphics types above, here’s how you switch converters. We begin with standard-SWP support.

Now we do the same thing for Portable LaTeX. Note that each block contains two \Configure{graphics*} statements — one for uppercase and one for lowercase extensions — and you need to make two changes.

TeX4ht/SWP should now use Irfan-View instead of ImageMagick to do these conversions.

Note that you cannot completely replace ImageMagick by Irfan-View, since Irfan-View cannot do the crop-as-much-as-possible operation needed to produce equation- and glyph-gifs. ImageMagick is still needed here.

A.2 Removing an automatic conversion

If you should need to disable a particular type of automatic conversion, the simplest way is to “comment it out”. This is easy, since each set of conversion instructions forms a group of statements, as noted above. Just put the LaTeX comment character % in front of every line. Remember that you need to do this in both swpframe.sty and portgraf.tex.

Appendix B Changing the HyperLink layout

This Appendix deals with two points concerning the SWP-specific HyperLink dialog: how to customize the way these links are rendered in your HTML, and how to obtain a link to an arbitrary Marker in your document.

B.1 Changing the appearance

The default behavior of the HTML generated by SWP’s HyperLink dialog is to make the “Screen Text” a live link, and when the user clicks on it, the action described by the “Target” is taken. Here’s how to alter this behavior, if you need to.

We will be changing the following lines of the definition (only the lines containing \Link will be changed):

       \Link{\filename@base}{}#1\EndLink  
   \else  
      \edef\PAVnext{\def\noexpand\PAVLcExt{\filename@ext}}  
      \lowercase\expandafter{\PAVnext}  
      \if\SubStringConditional{\PAVLcExt}{tex}  
        \Link[\filename@base.\PAVTeXExt]{}{}#1\EndLink  
      \else  
        \Link[#4]{}{}#1\EndLink  
       \fi  
   \fi  
\else  
  \Link[#4]{}{}#1\EndLink

Case 1: : You want the text of the “Target” to be the live text in your document. Change the lines to (replace #1 by #4):

      \Link{\filename@base}{}#4\EndLink  
   \else  
      \edef\PAVnext{\def\noexpand\PAVLcExt{\filename@ext}}  
      \lowercase\expandafter{\PAVnext}  
      \if\SubStringConditional{\PAVLcExt}{tex}  
        \Link[\filename@base.\PAVTeXExt]{}{}#4\EndLink  
      \else  
        \Link[#4]{}{}#4\EndLink  
       \fi  
   \fi  
\else  
  \Link[#4]{}{}#4\EndLink

Case 2: You want the text of the “Target” to be live, but you want it surrounded by the “Left” and “Right” Printed text. Change the lines to (this adds #2 before \Link and #3 after \EndLink):

     #2 \Link{\filename@base}{}#4\EndLink #3  
   \else  
      \edef\PAVnext{\def\noexpand\PAVLcExt{\filename@ext}}  
      \lowercase\expandafter{\PAVnext}  
      \if\SubStringConditional{\PAVLcExt}{tex}  
        #2 \Link[\filename@base.\PAVTeXExt]{}{}#4\EndLink #3  
      \else  
        #2 \Link[#4]{}{}#4\EndLink #3  
       \fi  
   \fi  
\else  
  #2 \Link[#4]{}{}#4\EndLink #3

Case 3: You want the “Screen Text” to be live, but you want it surrounded by the “Left” and “Right”” Printed Text (why, I don’t know). Change the lines to:

      #2 \Link{\filename@base}{}#1\EndLink #3  
   \else  
      \edef\PAVnext{\def\noexpand\PAVLcExt{\filename@ext}}  
      \lowercase\expandafter{\PAVnext}  
      \if\SubStringConditional{\PAVLcExt}{tex}  
        #2 \Link[\filename@base.\PAVTeXExt]{}{}#1\EndLink #3  
      \else  
        #2 \Link[#4]{}{}#1\EndLink #3  
       \fi  
   \fi  
\else  
  #2 \Link[#4]{}{}#1\EndLink #3

B.2 Arbitrary markers

As mentioned in section 15, SWP’s Marker mechanism is more general than LaTeX’s: you can put a Marker anywhere in your document, and jump to that location via the HyperLink dialog. In LaTeX this works only if the Marker marks something which is referenced by a LaTeX counter, like a section, subsection, or number in a numbered list.

It is possible get links to arbitrary Markers in your HTML, but the mechanism is a bit clumsy (not to mention visually unattractive). Essentially, we define a new LaTeX macro (\MARKER, in caps), and give it different definitions for typesetting and HTML generation. Here are the details.

Then whenever you need one of these free-standing markers, just insert Fragment and revise the field. The downside of this is a certain visual clutter: you have two fields with these references. You can avoid this by turning off the display of SWP’s Markers, but I personally find that I like to see them in my document.

Appendix C The Explicit-Package Approach to TeX4ht

This appendix discusses the details of the explicit-package approach to using TeX4ht. This was the only approach available in Version 1 of the support, and may still be useful for legacy documents. However, for most new users, the no-package approach described in section 12.1 is preferable.

C.1 Using the explicit package approach

To include an explicit reference to the TeX4ht/SWP package in your source, you include either of the following statements in the Preamble of your document:

\usepackage[no,other options]{swpht}

or

\RequirePackage[no,other options]{swpht}

Either will work: however, I find it somewhat easier to make changes with the \RequirePackage form, since this statement is accessible from SWP from the Typeset -> Preamble dialog. This sets up your document for standard typesetting: with this statement in your source, you should not notice any difference in typeset output.

To produce HTML output all you need to do is change the no to yes, and run the changed document through the TeX4ht batch file htswps.bat (or let htrun do it for you). You can make the change either in SWP itself, or you can use a text editor outside SWP. So to convert myfile.tex to HTML, assuming that the source contains the package reference:

C.2 Testing the explicit-package approach

Here is how to test that the explicit package approach is working correctly. We do two tests: one in which we call the batch file directly, and a second where we use the cover-program htrun.exe.

to start generating HTML. The TrueTeX window should pop up once, and then you should see some screen messages from the TeX4ht system.

— this cleans up most of the files produced by the system, so you can be sure that the next test runs correctly.

Next we test htrun.exe, which generates HTML without your having to tell the system whether or not your source (.tex) file contains the TeX4ht package.

C.3 Providing options

When your source document includes an explicit reference to the swpht package, you specify package options by including options in the brackets ([]) before the name of the package. You can include as many options as you like, and in any order, with two exceptions.

Here are some examples of providing package options (we show the form with \usepackage: the \RequirePackage form is the same).

C.4 Configuration files

When you use the explicit-package approach, you must explicitly request a configuration file as a package option. It is never automatic. Note that the same configuration file can be used for both standard SWP documents and for Portable-LaTeX and non-SWP-LaTeX documents, because of conditional code in the file.

Standard SWP LaTeX
Use of configuration files is optional. However, if you wish to use document-specific configuration files, you must explicitly refer to myconfig.cfg as the second option (after yes or no) in the list of package options for the swpht package. See section 13.2

Portable LaTeX
A configuration file is required in order to correctly process pictures in Portable LaTeX documents. This means that you must explicitly refer to myconfig.cfg as the second option (after yes or no) in the list of package options for the swpht package.See section 13.2

Non-SWP LaTeX
A configuration file is needed only if you wish to make use of automatic picture handling, as described in section 14.3, or document-specific configuration files. If you wish to make use of these facilities, you must explicitly refer to myconfig.cfg as the first option in the list of package options for the tex4ht package. See section 13.2

Plain-TeX, TeXinfo
Default configuration files are not supported. If needed, they may be included as command-line package options.

Appendix D The TeXConverter

Steve Mayer’s TeXConverter provides a point-and-select interface for TeX4ht/SWP, which some users will prefer to the command-line usage described in the main text. The TeXConverter supports all conversion options discussed here. This Appendix describes how to obtain, set up and use the TeXConverter.

D.1 Obtaining the TeXConverter

D.2 Setting up the TeX Converter

If you have not previously used the TeXConverter: the TeX4ht/SWP distribution provides a version of the Converter’s TeX Converter.ini file configured to match your installation choices in the rest of the system. This was left in c:\tex4ht\temp: you should move it to your TeXConverter directory, where it will over-write the one provided by Steve Mayer’s distribution. As of May 2004, the same thing applies to the configuration files tcconfig*.cfg: Carmen Fierro has supplied replacements for these, and if you want to use them you must move them to the TeXCoverter folder by yourseslf.

If you have already used the TeXConverter: you probably do not want to use the new version of TeX Converter.ini because it will not save any choices you have already made. You will need to tell the TeXConverter where you have installed TeX4ht, and possibly the locations of ImageMagick and GhostScript. To do this:

All users: with the TeXConverter running, and the Help tab displayed:

D.3 Converting a document to HTML

In this section, we’ll repeat one of the TeX4ht/SWP tests using the TeXConverter, and convert swphttestA.tex to HTML.

D.3.1 Basic setup

Start the TeXConverter, select the TeX4ht tab. Begin in the left-hand panel:

Now switch attention to the right-hand panel:

D.3.2 Locating the output

By default, the TeXConverter’s output is placed in a subdirectory of the main document directory; and any images are placed in a subdirectory \images of that directory. You can change this behavior by clicking on Change Directory (bottom-right panel) for the location of the HTML. If you uncheck Put Image in subdirectory immediately to the right of that, the document and its images will be stored in the same place. Alternatively, you can choose a different subdirectory (of the HTML directory) for images by entering something in the text box.

D.3.3 Configuring the HTML

Immediately below the choice-of-passes selector is a grayed out box which shows which command will be run. Package options are shown following the number of LaTeX passes, in quotes. If nothing is shown, you will be producing HTML-4 output, and your files will have extension .html. To change this, or to configure the HTML, click the Advanced button. In the new screen, choose your options. However, note that if your document explicitly refers to the swpht package, then any options you specify here will be ignored. (That is, the options you explicitly specify in the document are assumed to take precedence, which is usually what you want.)

D.3.4 Running the TeXConverter

When you have made all your selections, click Convert.

TrueTeX will run, and if you asked the TeXConverter to display the output you should see the same file you obtained when you originally tested TeX4ht/SWP.

Appendix E Adding a Directory to Your Path

If you needed to create a new directory for the TeX4ht/SWP batch files, here’s how to add this to your path. We’ll assume, for purposes of illustration, that you want to add c:\utility to your path.

E.1 Windows NT

You can now start a DOS session and type path : the response should show that the new element is indeed part of your path.

E.2 Windows 95/ 98

When your system re-starts, you can start a DOS session and type path. The response should show that the new element is indeed part of your path.

Appendix F Older versions of ImageMagick

Some time after ImageMagick 5.2.3, the convert switch to obtain a transparent background was changed from -transparency to -transparent. (Don’t ask me why). The distribution assumes that you have the latest version of ImageMagick, and consequently uses -tranparent. If you have an older version, you need to see which switch is applicable. To do this:

Appendix G Advanced Configuration of htrun

htrun opens your document and looks for one of a set of strings which identify the document type. It then calls the appropriate batch file. Both the strings and the batch files are user-configurable, though in most cases there will be no need to do this. All data used by the program is contained in htrun.ini, located (with htrun.exe) somewhere in your path. You can remind yourself where by starting a DOS session and running htrun with no arguments. The program then displays a screen of information.

The htrun logic is shown in the following table:

Notes:
(*): Not user-changeable     (**): Braces required
(***): As part of an input statement    (****): Must be entered exactly as written
If we find (=default): We decide that the source is And call file named by



\begin{document} (*) and      
     T4PACK={tex4ht} (**) LaTeX w/ explicit TeX4ht package LatexPackName
     SWPPACK={swpht} (**) SWP w/ explicit package SWPackName
     SWPINPUT=tcilatex (***) SWP w/o explicit package SWPName
     (none of the above) LaTeX w/o explicit TeX4ht package LatexName
TEXIINPUT=texinfo (***) TeXInfo TexiName
CSNAME=tex4ht\endcsname (****) plain-TeX, suitable for processing PlainName
(End of file, none of the above) plain-TeX (report an error)

There is one important thing to bear in mind when attempting to set up your own batch files. htrun does not actually run the batch file named in the .ini file: instead it appends a Translation Prefix to the name, and runs that batch file. The default Translation Prefix is ht. Thus, if a batch file entry says swps.bat then htrun will actually try to run the batch file htswps.bat. The reason for this is to facilitate alternative output format like XML: see section 18 for more on this. Before running the selected batch file, htrun looks for it in your path, and will refuse to run if the file isn’t found.

The following options are supported in the [integers] section (any omitted statement in this series is taken to be “off”, equivalent to =0):

Finally, note that the document-recognition strategy isn’t foolproof. Consider a plain-TeX file containing \input texinfo in a verbatim-like environment. (You’re illustrating the use of this command). This will be — mistakenly — recognized as a TeX4ht-processable TeXInfo file, instead of a plain-TeX file requiring some additional code (the string in CSNAME) before being processed by TeX4ht. Short of building a mini TeX parser, I don’t see how I can cope with this. Of course, LaTeX, with its well-defined notion of a preamble, is much less susceptible to this sort of thing.

Appendix H Advanced Configuration of swpinstall.exe

Almost everything in swpinstall.exe is user configurable, via an entry in swpinstall.ini.

Appendix I SWP Version 4+

With version 4.0 or later, the SWP family of products — including Scientific Notebook — allows you to create HTML directly from your on-screen files. As with TeX4ht, graphic images are used for mathematics, but because the internal Copy-As-Picture procedure is used to create them, the process is not only transparent to you, it is much faster than TeX4ht’s DVIPS+GhostScript+ImageMagick solution. For SN users who have previously used Hevea to create HTML, the new facility gives you a the ability to create HTML showing all your math without relying on glyphs being present in the Symbol font; and this is a major improvement. However, for SW and SWP users, who have access to LaTeX, there are a few limitations of the new facility that you need to be aware of.

I.1 Some Version 4 issues

No LaTeX The easiest way to understand the new HTML feature in SWP is to realize that it is creating hypertext from what is available on your SWP screen. In particular LaTeX is never used. This has a number of consequences, including:

Browser sensitivity The HTML produced by Version 4’s Export feature appears to be unusually sensitive to the browser. This applies particularly to inline math viewed in Netscape 4.7 (or presumably any of the 4.x series), which has severe alignment problems. However, alignment as viewed in Internet Explorer 5.0+ or Netscape 6.2 (possibly also 6.0+) is excellent. See below for a test.

Some appearance issues As noted above, the layout of the HTML is based on the screen appearance of your document (with several modifications, such as not using red for mathematics). If you’ve become used to not worrying much about the screen appearance on the grounds that LaTeX will take care of all the formatting for you, you may need to reconsider. TeX4ht, on the other hand, is independent of the screen appearance. (Conversely, if you want control over the appearance of your HTML, SWP 4’s .cst files provide a particularly easy way to get it, without worrying about LaTeX packages or TeX4ht configuration files). There are a couple of other issues you need to be aware of, some of which are fixable.

If these features are important to you, then you may wish to stick with a converter like TeX4ht, which handles them all correctly, albeit with a time cost.

I.2 A comparative test of HTML production

I have created a small test to show how the various HTML translation systems compare on the same source document. You can view it starting from here , and my advice is to do so in as many different browsers as you can, before you decide on your HTML strategy.

Appendix J Legal Matters

TeX4ht/SWP (‘The SWP Support for TeX4ht’) described here provides a means of integrating a number of free, shareware and commercial products: among these are TeX4ht, Aladdin GhostScript, ImageMagick, Irfan-View, TrueTeX, Microsoft Windows, the TeXConverter and the Mackichan Software family of products: Scientific Word, Scientific WorkPlace and, to a limited extent, Scientific Notebook. I am not the author of any of these products, nor am I employed by the developers of any of them.

J.1 Disclaimer of liability

(The following text is taken from LaTeX Project Public License, modified to refer specifically to the SWP support).

There is no warranty for The SWP Support for TeX4ht. Except when otherwise stated in writing, I provide The SWP Support for TeX4ht ‘as is’, without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of The SWP Support for TeX4ht with you. Should The SWP Support for TeX4ht prove defective, you assume the cost of all necessary servicing, repair, or correction.

In no event unless agreed to in writing will I, or any author named in the files of The SWP Support for TeX4ht, or any other party who may distribute and/or modify The SWP Support for TeX4ht as permitted below, be liable to you for damages, including any general, special, incidental or consequential damages arising out of any use of The SWP Support for TeX4ht or out of inability to use The SWP Support for TeX4ht (including, but not limited to, loss of data, data being rendered inaccurate, or losses sustained by anyone as a result of any failure of The SWP Support for TeX4ht to operate with any other programs), even if I or said other party has been advised of the possibility of such damages.

J.2 Redistribution

(The following text is taken from LaTeX Project Public License, modified to refer specifically to the SWP support, to remove conditions specific to LaTeX).

You may distribute a complete, unmodified copy of The SWP Support for TeX4ht. Distribution of only part of The SWP Support for TeX4ht is not allowed. You may not modify in any way a file of The SWP Support for TeX4ht that bears a legal notice forbidding modification of that file. You may distribute a modified file of The SWP Support for TeX4ht if, and only if, the following six conditions are met:

  1. You must not distribute the modified file with the filename of the original file.
  2. In the modified file, you must acknowledge the authorship and name of the original file, and the name (if any) of the program which contains it.
  3. You must change any identification string in the file to indicate clearly that the modified file is not part of The SWP Support for TeX4ht.
  4. You must change any addresses in the modified file for the reporting of errors in the file or in The SWP Support for TeX4ht generally to ensure that reports for files no longer maintained by the original maintainers will be directed to the maintainers of the modified files.
  5. You must distribute the modified file under a license that forbids distribution both of the modified file and of any files derived from the modified file with the filename of the original file.
  6. You must do either (a) or (b):

    1. distribute a copy of TheSWP Support for TeX4ht (that is, a complete, unmodified copy of The SWP Support for TeX4ht) together with the modified file; if your distribution of the modified file is made by offering access to copy the modified file from a designated place, then offering equivalent access to copy The SWP Support for TeX4ht from the same place meets this condition, even though third parties are not compelled to copy The SWP Support for TeX4ht along with the modified file;
    2. provide to those who receive the modified file information that is sufficient for them to obtain a copy of The SWP Support for TeX4ht; for example, you may provide a Uniform Resource Locator (URL) for a site that you expect will provide them with a copy of The SWP Support for TeX4ht free of charge (either the version from which your modification is derived, or perhaps a later version).

Note that in the above, ‘distribution’ of a file means making the file available to others by any means. This includes, for instance, installing the file on any machine in such a way that the file is accessible by users other than yourself. ‘Modification’ of a file means any procedure that produces a derivative file under any applicable law – that is, a file containing the original file or a significant portion of it, either verbatim or with modifications and/or translated into another language.

Changing the name of a file (other than as necessitated by the file conventions of the target file systems) is considered to be a modification of the file.

The distribution conditions in this license do not have to be applied to files that have been modified in accordance with the above conditions. Note, however, that Condition 5 does apply to any such modified file.

The conditions above are not intended to prohibit, and hence do not apply to, the updating, by any method, of a file so that it becomes identical to the latest version of that file of The SWP Support for TeX4ht.