Document 146

How to use a LaTeX style not provided with SW

Version 2.5 - Scientific Word

You can use your favorite LaTeX style in version 2.5 of SW if you place it in the correct directory, then modify the .lat file associated with the type of document the style creates (for example, if the style is a report style, the .lat file is report.lat). Modifying the .lat file ensures that the name of the style you add appears as an option when you want to choose a style using the New command on the File menu.

About the .lat file

Each .lat file contains a section for each style with which the .lat file is associated. Each section has these entries:

[stylename]

DESCRIPTION=My Favorite Style

DOCSTYLE=entry

SHELLFILE=entry

CSTFILE=entry

DOCCLASS=entry

PACKAGES=entry

When you add a style, you must modify the associated .lat file by adding a section for the new style. However, you must change the .lat file very carefully, because this action has serious consequences:

  • The information you enter in the DOCCLASS, DOCSTYLE and PACKAGES statements for a given style is placed directly in any .tex document that you create with the style.

  • The .lat file entries determine the version of LaTeX with which you can use a given style.

    • To use a style with LaTeX 2.09, the DOCSTYLE item must have an entry and the entry must be correct. If the entry is wrong, documents created with the style won't compile. To prevent a style from being used with LaTeX 2.09, leave the DOCSTYLE entry blank.

    • To use a style with LaTeX 2e, the DOCCLASS item must have an entry and the entry must be correct. If the entry is wrong, documents created with the style won't compile. To prevent a style from being used with LaTeX 2e, leave the DOCCLASS entry blank.

    • Use the PACKAGES statement only for LaTeX 2e styles. LaTeX 2.09 ignores PACKAGES entry. Include only one package in the PACKAGES statement.

    • To use a style with both LaTeX 2.09 and LaTeX 2e, create an entry for all three items: DOCSTYLE, DOCCLASS and PACKAGES.

    • Some examples:

      The following entries support a style that can be used with LaTeX 2.09:

      [section name]

      DESCRIPTION=a description

      DOCSTYLE=[options]{basestyle}

      SHELLFILE=shellfile

      CSTFILE=cstfile

      DOCCLASS=

      PACKAGES=

      The following entries support a style that can be used with LaTeX 2e:

      [section name]

      DESCRIPTION=a description

      DOCSTYLE=

      SHELLFILE=shellfile

      CSTFILE=cstfile

      DOCCLASS=[options]{baseclass}

      PACKAGES=[options]{pkg}

      The following entries support a style that can be used with both LaTeX 2.09 and with LaTeX 2e.

      [section name]

      DESCRIPTION=a description

      DOCSTYLE=[options]{basestyle}

      SHELLFILE=shellfile

      CSTFILE=cstfile

      DOCCLASS=[options]{baseclass}

      PACKAGES=[options]{pkg}

Adding a style

To add another style:

Remember The information in .lat files is delicate and changing it incorrectly can cause serious difficulties. You may want to consult with a local LaTeX expert before undertaking this action.

  1. Place the LaTeX style file in the \sw25\tex\macros directory.

  2. Add a section to the .lat file:

    1. Using an ASCII editor, open the .lat file for the type of style you want to add.

      The file will be located in one of the subdirectories of the sw25\styles directory.

    2. Add these lines to the end of the file, substituting the name of your style file:

      [stylename]

      DESCRIPTION=My Favorite Style

      DOCSTYLE=

      SHELLFILE=entry

      CSTFILE=entry

      DOCCLASS=

      PACKAGES=

    3. Save the file.

  3. Modify the new section:

    Perhaps the easiest and best way to find correct content for the .lat file statements is to copy it from a .tex file that uses the style in question or, in the case of the SHELLFILE and CSTFILE statements, from other sections in the .lat file.

    • To create the SHELLFILE and CSTFILE statements:

      1. Using an ASCII editor, open the .lat file.

      2. Search the .lat file for the section pertaining to a style similar to the one being added.

      3. Find the SHELLFILE statement and copy the entry to the SHELLFILE field in the new section.

      4. Find the CSTFILE statement and copy the entry to the CSTFILE field in the new section.

      5. Save the .lat file.

    • To copy the DOCSTYLE statement from an existing .tex file:

      1. Using an ASCII editor, open a .tex file that uses the style in question.

      2. Find the LaTeX \documentstyle statement, which looks something like this:

        \documentstyle[opt1,opt2,...]{basestyle}

      3. Copy the [opt1,opt2,...]{basestyle}part of the statement.

      4. Paste the copied information into the DOCSTYLE field in the new section of the .lat file, so that the statement reads

        DOCSTYLE=[opt1,opt2,...]{basestyle}

      5. Save the .lat file.

    • To copy the DOCCLASS statement from an existing .tex file:

      1. Return to the .tex file that uses the style in question.

      2. Find the LaTeX \documentclass statement, which has this form:

        \documentclass[opt1,opt2,...]{basestyle}

      3. Copy the [opt1,opt2,...]{basestyle}part of the statement.

      4. Paste the copied information into the DOCCLASS field in the new section of the .lat file, so that the statement reads

        DOCCLASS=[opt1,opt2,...]{basestyle}

      5. Save the .lat file.

    • To copy the PACKAGES statement from an existing .tex file:

      1. Return to the .tex file that uses the style in question.

      2. Find the LaTeX \usepackage statement, which has this form:

        \usepackage[option]{pkgname}

      3. Copy the [option]{pkgname}part of the statement.

      4. Paste the copied information into the PACKAGES statement in the new section of the .lat file, so that the statement reads

        PACKAGES=[option]{pkgname}

      5. Note that it isn't possible to have the .lat file generate more than one \usepackage statement.

      6. Save the .lat file.

  4. Check that the file has been installed correctly:

    1. Start SW.

    2. From the File menu, choose New.

    3. Make sure your style is listed among the available styles.

Last revised 02/27/06

This document was created with Scientific WorkPlace.