Document 342

Adding new text tags

Version: 3.5, 3.51, & 4.x - Scientific WorkPlace & Scientific Word

Tagged runs are text tags that are applied to selections of text. Examples of tagged runs are bold and emphasized. Two components are needed to add tagged runs, a screen component that determines appearance in the program's edit window and the typeset component that determines the appearance of the typeset document. The screen appearance is controlled by the screen style or .cst file. New tagged runs can be added to the .cst file when using Version 4.0, but the .cst file must be edited with a text editor when using earlier versions. The typeset appearance is determined by appropriate LaTeX macros usually added to the document preamble or made available via a package file.

Two examples illustrate how to add new tagged runs. These procedures were tested with Versions 3.5 and 4.x.

Example 1. Adding a BoldItalics text tag

Screen display

The screen display is determined by the .cst file. To find out what .cst file is used by your document, choose File/Style. The name of the .cst file is located at the bottom of the dialog.

  • In Version 3.x:

  1. Make a note of the name.

  2. Use an ASCII editor to open the .cst file and add a section containing these lines:

    [QQQBoldItalics]

    TAG_TYPE=TEXT

    ALIAS=Bold Italics

    NEXT_TAG=QQQBoldItalics

    FONT_WEIGHT=700

    FONT_SLANT=1

    TAGLEVEL=0

    TAGBAR_DELETE=0

  3. Save and close the .cst file.

  • In Version 4.x:

  1. From the Tag menu, choose Appearance.

  2. Select the tag Bold and choose Clone Tag.

  3. Name the new tag BoldItalics.

  4. From the Tag Properties list, select Font and choose Modify.

  5. Change the Style to Bold Italics and choose OK to close the dialog.

  6. Either choose Save to save changes in the current .cst file or choose Save As to create a new .cst, and then choose OK.

Typeset display using the SW filter

  • In Version 3.x: If the document is open, close and reopen it so the changes to the .cst file will take effect.

  1. From the Typeset menu, choose Preamble.

  2. Click in the entry area and add this line:

    \def\QQQBoldItalics#1{\bfseries\itshape #1}

Typeset display using the Portable LaTeX filter

  1. Use an ASCII editor to open the file latex2.dat, located in the program directory.

  2. Search the file to find the section that starts:
    Here are the tagged run translations

  3. Add a new line to this section that contains:

    \QTR{QQQBoldItalics}#1 modeless "\textbf{\textit{#1}}", "\mathbf{\mathit{#1}}"

  4. Save the file latex2.dat with these changes.

  5. Test the change:

    1. Select some text, apply the BoldItalics tagged run.

    2. From the Typeset menu, choose Preview or Print to see bold italic text.

Note You can nest certain text tags, so the above effect can also be achieved by highlighting a word or words of text plus the spaces around the word(s), selecting the Bold tag, then highlighting only the word(s) and selecting the Italics tag.

Example 2. Adding a bold, 11-point, typewriter text tag

Screen display

The screen display is determined by the .cst file. From the File menu, choose Style and look at the bottom of the dialog to determine the .cst file used by your document.

  • In Version 3.x:

  1. Make a note of the name of the .cst file.

  2. Use an ASCII editor to open the .cst file and add a section containing these lines:

    [QQQTypewriterBoldxipt]

    TAG_TYPE=TEXT

    ALIAS=TypewriterBoldxipt

    NEXT_TAG=QQQTypewriterBoldxipt

    FONT_FACE=Courier New

    FONT_size=11

    FONT_WEIGHT=700

    FONT_SLANT=0

    TAGBAR_DELETE=0

  3. Save and close the file.

  • In Version 4.x:

  1. From the Tag menu, choose Appearance.

  2. Select the tag Typewriter and choose Clone Tag.

  3. Name the new tag TypewriterBoldxipt.

  4. From the Tag Properties list, select Font and choose Modify.

  5. In the Font Properties Specified list, select Face, Size, and Style (depending on the .cst file you are starting with, some of these selections will already be set).

  6. Change the Face to Courier New.

  7. Change the Size to 11.

  8. Change the Style to Bold.

  9. Choose OK to close the dialog.

  10. Either choose Save to save changes in the current .cst file or choose Save As to create a new .cst, and then choose OK.

Typeset display using the SW filter

LaTeX uses two methods to select attributes, a switch method and a macro method. The example above uses the switch method where the LaTeX source looks similar to {\switchTagged text.}. Unfortunately, the macro definition for \QTR in tcilatex.tex used only the switch method. This example uses the macro method, so tcilatex.tex must be modified. The modification given below will then work with both the switch and macro methods. This modification is already included with Version 4.1, so the following steps are needed only when using Version 3.x or 4.0.

  1. Open tcilatex.tex and locate the line

    \def\QTR#1#2{{\csname#1\endcsname #2}}%(gp) Is this the best?

  2. Modify this line so that it appears as follows:

    \def\QTR#1#2{{\csname#1\endcsname {#2}}}%

  3. Immediately after the modified line, add a new line so that your modification can be detected in the .log file that LaTeX produces when it compiles a document:

    \typeout{QTR modified for tagged run macros}

  4. Save the file tcilatex.tex file with these changes.

  • In Version 3.x: If the document is open, close and reopen it so the changes to the .cst file will take effect. Version 4.x automatically reopens the document after you make changes to the .cst file.

  1. From the Typeset menu, choose Preamble.

  2. Click in the entry area and add these lines:

    \DeclareTextFontCommand{\textttxi}{\fontsize{11}{13}\ttfamily}

    \def\QQQTypewriterBoldxipt#1{\textttxi{#1}}

Typeset display using the Portable LaTeX filter

  • In Version 3.x: If your document is currently open, close and reopen it so the changes to the .cst file will take effect.

  1. From the Typeset menu, choose Preamble.

  2. Click in the entry area and add the following line:

    \DeclareTextFontCommand{\textttxi}{\fontsize{11}{13}\ttfamily}

  3. Use an ASCII editor to open the file latex2.dat located in the program directory.

  4. Search the file to find the section that starts:
    Segment of latex2.dat file

  5. Add a new line to this section that contains

    \QTR{QQQTypewriterBoldxipt}#1 modeless tcimacro "\textttxi{#1}"

  6. Save the file latex2.dat with these changes.

  7. Test the changes:

    1. Select some text and apply the TypewriterBoldxipt tagged run.

    2. From the Typeset menu, choose Preview or Print to see a bold typewriter 11pt font.

Additional notes

If you share your document with other SWP or SW users, they will have to make similar changes to tcilatex.tex (if you use the macro method for defining the tagged run) and their local cst files. If you save your .cst file in the same directory as your document (from the Tag menu, choose Appearance, make changes, and then choose Save As) and then use the SW Document Manager to wrap your document, the cst file will be included with the document. If you run the Document Manager directly (in Version 3.x, from the File menu, choose Document Manager; in Version 4.x, from the Tools menu, choose Document Manager), you can also include your version of tcilatex.tex when wrapping your document.

If you are using the Portable LaTeX filter, notice that Example 1 and Example 2 use different forms of expanding the \QTR macro. In Example 1, the SW input filter recognizes the expansion. In Example 2, the SW input filter doesn't recognize the expansion. Therefore, in order to see appropriately tagged text instead of a TeX field, you must include "tcimacro" in the addition to latex2.dat and save the extra comments with the document.

Added 12/12/01; revised 07/03/02

This document was created with Scientific WorkPlace.