< Previous Chapter | Next Chapter >

449 Chapter 15. Working with Long Documents

In this chapter, you’ll learn…

If the only kinds of documents you use Nisus Writer for are letters, memos, E-mail, and other short documents, you will probably never encounter the kinds of problems this chapter addresses. Long documents like books, annual reports, academic papers, and so on pose special challenges to a word processor. Besides simply being long, these kinds of documents tend to make heavy use of footnotes, graphics, autonumbers, and other special features—and in the light of such complexity, certain limitations of Nisus Writer are revealed. In this chapter, we’ll talk about those limitations and how to overcome them, plus see how the tedious work of producing a long document can be simplified in several ways.

450 Dealing with Memory

The number one problem in working with long documents is running out of memory for one reason or another. As you know, your entire document must always be held in RAM. This means that the larger your document, the more memory you must assign to Nisus Writer (see Chapter 9). And of course, when your documents get longer, you tend to cut and paste larger portions of text, use more graphics and autonumbers, and perform more activities that must be remembered on the Undo list, meaning that memory usage may increase on a sharp curve as your document size increases. On top of all that, when Nisus Writer gets squeezed for memory, its performance tends to deteriorate noticeably—things like moving graphics, scrolling, or even just typing can become painfully slow in low-memory situations.

The first thing you should know is what makes large documents so large. Text—even with lots of fonts or styles—takes up relatively little space. But graphics (of any kind—including tables and equations) can make your document size balloon very quickly. Even very tiny character graphics take up a significant amount of disk space. So if document size is becoming a problem, consider limiting the number and size of graphics in your document. And particularly if you’re working with bitmap graphics, try reducing the number of colors they use. For example, a 24-bit TIFF image can occupy four times as much space as an 8-bit version of the same image. If the output medium you’ll be using doesn’t require exacting color distinctions, you can save a lot of space just by using graphics with a smaller bit depth. And if you can actually leave the graphics out altogether until you’re done with the other parts of your document, the rest of your editing will be all the more pleasant.

The other thing you should know, though, is what takes up RAM. It is possible for you to have two documents, each 100K in size, such that one takes up only 100K of RAM, while the other takes up 300K. How could this be? In addition to the space needed to load the file itself into RAM, Nisus Writer allots roughly an additional 5K for each graphic 451 (over and above the size of the graphic itself). Autonumbers also occupy a large chunk of RAM, and the pieces all add up very quickly when your document contains large numbers of these items. So if memory is tight, consider using styled (macro-based) autonumbers (see below) rather than the built-in variables. And if graphics are your Achilles’ heel, try choosing Graphics as X from the Display Attributes pop-up menu. This doesn’t affect your printout in any way, but it tells Nisus Writer not to draw each graphic on the screen, saving considerable memory and processing power. Graphics as X is great for squeezing out a little extra scrolling speed when memory is tight.

If you’re short on memory, Nisus Writer is smart enough not to load in all your graphics at once, but only the ones that are being displayed on the screen at any given moment. However, as you scroll, any graphics you pass will be loaded in. To keep graphics from loading while you scroll, hold down the Command key.

Linking Documents

But let’s say you’ve done all of that, but due to the sheer amount of text in your document, you’re finding it too large to work with. The obvious solution is to split your document into several pieces. But there are a few problems in doing this. For one thing, you’ll need to make sure, when it comes time to print, that the page-numbering sequence flows from one document to the next so that it looks like a single file. The same is true of any numbering sequences (figures, footnotes, etc.) in your document. And if your document has an index or table of contents, you need to have that refer to the document as a whole, not just the individual pieces. Finally, you’ll want to make sure that any styles, rulers, or document-formatting attributes used in one document are identical in the others.

One reason you might consider linking documents would be to get a bibliography to appear at the very end of a document that uses endnotes. Here’s an easier way: copy the entire bibliography and paste it into your last endnote. If you then make the endnote reference number invisible, it will appear that you simply have additional material after your endnotes.

Unfortunately, most of the above has to be done manually. Nisus Writer doesn’t have anything like a “book list” feature to link documents together automatically. But with some clever macro writing and a little forethought, you can automate much of the process and at least make it a bit less awkward.

Sequencing Page Numbers

For example, let’s look at the page-number problem. You can, of course, manually set the starting page number of a 452 document to anything you want using the Page Setup… command. But how could we make this happen automatically? Try this. Select the last page number of your first document and publish it. Place your insertion point at the very beginning of the second document and subscribe to the page number edition file. Now make the subscriber invisible. Finally, run a macro that: finds this subscriber; adds 1 to the number; pastes the result into the Starting Page Number box of the Page Setup dialog box. Ta-da—linked documents. In fact, this macro can even be made to run automatically when you open a new document, so you won’t have to worry about forgetting. Just name it InitOpen and you’re all set. A similar tactic can be used to keep footnote numbers and autonumbers in sequence.

Of course I’ve already written such a macro for you, and included it on the enclosed CD, along with some sample “linked” documents.

Maintaining Consistency

Along the lines of the last suggestion, you will probably want your series of documents to have exactly the same header, footer, and perhaps other “boilerplate” information. The easiest way to do this is to set up your documents in advance to share template features using either page graphics or Publish & Subscribe, as we saw in Chapter 14 (“Keeping Your Documents Consistent”). If you already have a document that is pretty long and you’ve decided to split it into pieces, remember that the headers, footers, and so on won’t automatically appear in the “offspring” files. Ordinarily, you’d have to copy and paste the paragraph returns to which the headers or footers are attached if you want to duplicate them precisely without recreating them from scratch. But you still may want to consider making one of the files the “primary” document and using Publish & Subscribe or Page as Graphic to link the information to the other files. Then, if a change is needed, make it to the primary document and the rest will update automatically.

Even after doing all this, defined styles and named rulers won’t automatically remain the same across documents. But if you use macros to apply your styles (see “Dynamically Linked Styles” below), you can get around this problem. Have a document (your “style sheet”) that only contains the 453 styles for your documents, and keep this open in the background all the time (perhaps add a command to your InitInit macro to do this). Make a Define Styles macro that always brings that document to the front before opening the Define Styles dialog box. Then make sure your style-applying macros reference the styles in your Style Sheet document (e.g., Style Sheet:Header). The effect is that all styles will be applied and changed from a single document, thus assuring consistency in all your files. See the CD-ROM for examples.

Indexing Linked Documents

The biggest problem you’ll encounter when your document is split into pieces is indexing. You can only index one document at a time; there’s no way to index across documents automatically. So you have two options. First, you could recombine the documents at the very end, just before indexing—if you can afford the memory. Second, you could make individual indexes and merge them. To merge multiple index files, copy the contents of each one and paste them into a master index file. Then select the whole document and choose Sort Paragraphs from the Edit menu to arrange all the entries in a single alphabetical sequence. Then you’ll need to find any duplicated entries and combine them into a single line.

Nisus Software has provided a Merge Indexes macro with Nisus Writer. You’ll find it, along with about 100 other macros, in the Prepared Macros folder inside your Nisus Writer folder.

Using Defined Styles

In long documents, it is virtually mandatory to use defined styles and named rulers, as described in Chapter 10. This will save you tons of effort in formatting your document and keeping it internally consistent. Because these formatting shortcuts are so important, let’s continue our earlier discussion and look at their use in more detail.

Nisus Writer now has a feature called Style Libraries. A style library is essentially a special document that contains defined styles. Other documents can refer to the styles in the style library, so that if you make a modification to the style library, all the documents that use that style are automatically updated. This is a great way to keep your documents consistent, and while it doesn’t amount to dynamic inheritance, it does at least allow you to separate the style from the document.

First, let’s look at the way multiple styles interact with each other. You can, in principle, have any number of different defined styles applying to a given piece of text, just as you can use any number of individual character styles. There 454 are just a couple of limitations. First, if you have the attribute Remove Existing Defined Styles set for a given style, it will wipe out all previously applied styles when you use it. If two defined styles both have that attribute checked, they are mutually exclusive. If only one of the styles has that attribute checked, you can apply it first, then the other style, for an overlapping effect. Second, if styles have competing settings for one or more attributes (e.g., which font is used or whether bold is on or off), then the most recently applied style will override earlier style definitions. And, of course, manually selected character formatting is wiped out if the style you apply has Remove Existing Menu Styles checked. To remove a defined style from the selected text without deleting the style definition itself, you can simply choose the style again from the Style menu.

When do you want to use these attributes, and when do you want to avoid them? While this will depend on your particular goals, we can look at some examples that will help to make the choices clearer. Let’s take a simple document like the one shown in Figure 15.1. We have four defined styles in this document, to illustrate the four combinations of the “Remove…” attributes. First is the Heading style. This will be used for section or chapter headings, and it has both attributes checked. Why? Because we want all headings to have exactly the same style, no matter what. If some of the text was a different color, or a different font, we want to override that. We also want to override any other defined styles (like New Term) that may have been used for the text. We’ve made Heading a paragraph style (since it will always apply to an entire paragraph), attaching a named ruler to it for good measure. And since we know that “body” text will always be the next thing we want to type after a heading, we’ve set Style of Next ¶ to Body.

Figure 15.1. A document with four defined styles.

The Body style is used for the bulk of the text. This gives our document its overall look, but it also needs to be the most flexible. We may decide, for example, to apply the style Body to a paragraph we’ve already written, in which some words may have been made, say, italic or bold for emphasis. We don’t want those styles to be changed. And the paragraph may also have text in a defined style like New Term—again, we 455 want to leave that alone. So Body has both “Remove…” attributes unchecked. It is, however, a paragraph style (since we want it to apply to a whole paragraph at once), again using a named ruler.

There are some terms we want to call attention to, and we’ve marked them using the New Term style. This is not a paragraph style, because we want it to apply to individual words without affecting the rest of the paragraph. We’ve unchecked Remove Existing Menu Styles, because we realize that we might have a new term that also needs to be in a special style or color. But we want to make sure that any other defined styles are removed (for instance, a character style that specifies tracking or hyphenation). So we check Remove Existing Defined Styles.

Finally, we used a style named Quote for quotations. We’ve made this a paragraph style, but not given it any particular ruler, since we may want to use quotes in various contexts—bulleted lists, regular paragraphs, indented sections, and so on—and we want the quote to take on the characteristics of the previous paragraph. In this style, we have checked Remove Existing Menu Styles because we want to make sure the quotes are in just the font and size we specify. But, we also want to be able to apply the Quote style without removing any New Term marks that may have been in the quote. So Remove Existing Defined Styles is unchecked.

456 Dynamically Linked Styles

Back in Chapter 10, we observed that Nisus Writer’s styles do not have dynamic inheritance—you can’t have one style based on another in such a way that when the original changes, the subordinate style updates itself to match. But we also said there was a way to simulate this effect, which can be incredibly useful when working with a large number of defined styles in a long document. Here’s how it works. As an example, we’ll define a “parent” style and a “child” style based on it. Then we’ll check to see that changes made to the parent style affect the child style. First, choose Define Styles and set the attributes you want your parent style to have (including a ruler, if you wish). Name this style “Parent,” and set the attributes Courier, Red, 24, and Underline as shown in Figure 15.2. We’ll leave the Make Paragraph Style box unchecked for now, though you can add a ruler later if you wish. Also, you’ll probably want to make sure that Remove Existing Menu Styles and Remove Existing Defined Styles are unchecked for now.

Figure 15.2.The Define Style dialog box showing the Parent style.

Next, create a one-line macro, called ParentStyle. This macro will simply contain the command Parent—that is, it will apply the Parent style. (You can create this macro quickly by choosing Record from the Macros submenu, choosing the Parent style, then choosing Stop Recording from the Macros 457 submenu.) Any time you run the ParentStyle macro, it will apply all of those attributes to the selected text, exactly as though you had made it a defined style. So the selected text will now be Courier 24, underlined, and red. Why go to the bother of making this macro if it does the same thing as the Parent menu choice? Two reasons. First, you can add additional steps to the macro later if you wish, like adding text whenever the style is applied. But more importantly, since all the other styles you create this way will be based on macros, it will be less confusing if they’re all in one place.

You can save yourself some mousing by pressing Option while clicking the title bar of your document window to display the Macros menu.

Now make a second style (the “child” style), which we’ll call Child. Uncheck everything except Bold and Size, and enter a point size of 36 (see Figure 15.3). Now, make a second macro, which we’ll call ChildStyle. This one will have two lines:


In other words, this macro first runs the ParentStyle macro which applies the Parent style, then applies the Child style. After running this macro, the selected text will be Courier 36, bold, red, and underlined. It’s still underlined even though we unchecked Underline in the Child style, because leaving something unchecked means the style doesn’t affect that attribute one way or another (unless you have Remove Existing Menu Styles checked—see below). So far so good?

Figure 15.3.The Child style.

458 To force a style to turn some attribute (like underlining) off if it happens to be used in the selected text, add a command to your macro like Underline "off", where "on" or "off" is an argument of the menu command. See Chapter 12 for a more detailed explanation.

Now let’s look at how we get changes to percolate from the Parent style to the Child style. Open the Define Styles dialog box again, and choose the Parent style. Now make a change—for example, change the font from Courier to Geneva. Click Set, and then Done. Presto! All of the text that you styled using the ParentStyle macro and all of the text you styled using the ChildStyle macro have now become Geneva! This is pretty slick, if I do say so myself. To recap: define your original style as usual, but also write a macro that just applies that style. For “based on” styles, be sure to check only those attributes that differ from the original. Again, make a macro that applies both the parent and the child style. And always apply your styles using the Macro submenu rather than the Style menu. That’s all there is to it! Dynamic inheritance is yours.

While this basic system works quite well, there are many possible variations to it. Without going into a great deal of detail, I’ll give you the basic ideas, and let you figure it out from there.

Un-naming a Ruler

There may be times when you’d like to make changes to a paragraph that’s governed by a named ruler, without changing all the paragraphs in your document that use that ruler. However, you also don’t want to delete the ruler icon, because that may mess up the formatting of your paragraph. If only you could turn that one icon from a named ruler into an unnamed ruler! As a matter of fact, you can. All you need to do is select the ruler icon, highlight its name in the Ruler Name box, press Delete, then press Enter or Return. Your ruler icon will lose its name, but your paragraph formatting will remain unchanged (and, of course, the ruler name will still be available in the menu for future use). If you later want to rename the ruler and have the named ruler apply to all the paragraphs that share identical formatting with the current one, just press Command while typing Enter or Return after typing in a new ruler name. This is a very powerful technique when you need to change a large number of paragraphs at once.


When you’re working with a document that contains multiple chapters, figures, or other repeating parts, you’ll be glad to have Nisus Writer’s autonumbering capabilities handy, as we saw in Chapter 10. If you use them consistently, they’ll 460 save you an enormous amount of effort in keeping numbering sequences, and references to numbered items, in order. But indispensable as autonumbers are, there are a couple of glitches. One problem is that autonumbers are not converted to “real text” numbers when you export a file in another format. This can be very serious—imagine creating the manuscript for an entire book using autonumbers and sending it to your publisher in Word format, only to discover that all the numbers have disappeared!

One workaround is to publish your document, subscribe to it in a new document, and then export the subscribing document. This works because publishing—unlike exporting—does resolve autonumbers. But another, very different approach to solving this problem is to avoid using autonumbers at all, and instead number items in your text using Nisus Writer’s UpdateVariables() macro command.


Here’s the idea. The UpdateVariables() command simply says, “Take all the things in some particular style, and turn them into a sequence of numbers in some particular format.” So you need to start by defining a style—let’s call it NumStyle—that will serve as a marker for variables. This style doesn’t need to have any attributes at all, just a name. (If you want multiple numbering sequences, define more than one style.) Every time you want to insert a number, simply type any character and apply the NumStyle style to it. (Make sure the only things that have this style applied are the portions of your text you want to be turned into numbers—if you apply the style to a whole paragraph, the whole thing will be replaced with a number!) Next, we’ll need to have two very short macros. The first defines the format of the number. In this example, we’ll make a figure number, so we’ll add the word “Figure” before the number and a period after. Name this macro NumberOne:

result = "Figure " + n[1] + "."

Follow this format exactly: it must start with result = and contain n[x], where x is the “level” of numbering (e.g., an 461 outline could have several levels, and you want lower-level numbers to restart whenever an instance of the next-higher level is encountered). You can add text strings before or after the number definition, and you can also modify it using a function like LowerRoman(n[2]) or NumToChar(64 + n[3]), depending on the effect you want. Create a new macro for each level of numbering you need, each with a different name but following the same format.

Next, we’ll write another macro that actually performs the renumbering. It, too, is very short:

Select All

This macro first selects the entire document (an important step, because UpdateVariables() only works when a range of text containing all the styled characters is selected). Next, it creates a stack named s, and pushes (from the “bottom”) the NumStyle style followed by the name of the macro that describes its number format. Again, you’ll need to repeat these two lines for each number-defining macro you have used. The last line of the macro performs the magical UpdateVariables() command in the frontmost window. When you run this macro, each character in the NumStyle style will be replaced with “Figure X.” where X is the next number in a sequence.

In addition to giving you exportable autonumbers, this approach gives you the maximum flexibility to design your own number format. But it is not without its limitations. For one thing, you must manually run the macro whenever you want the numbers to update. For another, it’s a little more awkward to refer to the current value of a given variable—instead of using commands like Current Figure #, you need to mark the variable and insert a cross reference (or, for multi-file documents, use Publish & Subscribe). However, if you can live with those limitations (and perhaps create a macro to automate entering a single character in one of these special styles), this technique can save you a lot of bother.

462 Variables in Editions

The other problem with using Nisus Writer’s built-in autonumbers surfaces when you publish a range of text containing an autonumber. The problem is that publishers containing variables or autonumbers don’t update their edition files if the value of the variable is the only thing that changes. This means that if you try one of the tricks above that involve publishing a page number or figure number, you may not get reliable results if the original changes. The solution is to make a change to each of the publishers, but to make the change “invisible.” One way to do this is to define a style with no attributes, and apply this style to each publisher. While this has no visible effect, it does count as a change, and it forces the publishers to update their edition files.

The CD-ROM contains a set of “Touch Publisher” macros that will automatically apply a “dummy” style to each publisher in your document, specifically to force all the edition files to update in cases where variables may have changed.


In a long document, cross-referencing (discussed in Chapter 10) is a real blessing. It allows you to refer to one part of your document in another part, without worrying about finding all those references to update them if the location or content of the original material changes. Here we want to look at two specific problems with cross-referencing and how to avoid them.

The first problem is that you can’t cross-reference into headers, footers, or footnotes. One reason you might want to do this is if you have a footnote that refers to an illustration, e.g., “See Figure 12 on page 18,” but you’ve used variables for the figure and page numbers. Ordinarily, you could just mark the numbers and insert a cross-reference to make sure the numbers automatically update as needed, but unfortunately, cross-referencing isn’t available in the header/footer or footnote/endnote windows. However, Publish & Subscribe is. In your text, publish each variable individually, then subscribe to them in your note. While this does involve a bit of extra effort, it achieves exactly the same effect as cross-referencing.

Remember, if the only thing that changes in a publisher is the value of a variable, it won’t update the edition file automatically. See above under “Autonumbering” for the workaround to this.

463 The second problem—to which you can easily guess the solution—is that when you have split a long document into parts, you can’t cross-reference text from one of the parts in another. You know what’s coming: Publish & Subscribe to the rescue again. Instead of marking text, publish it…and instead of inserting a cross-reference, subscribe to the edition file you created. Piece of cake.

Indexes and Contents Revisited

In Chapter 10 we looked at the basics of creating an index or table of contents. In long documents, though, this task can be much more involved. For one thing, there’s simply a lot more material to work with, so any shortcuts you can find will save you a lot of time. For another thing, as the length of your document grows, you may discover you need multiple indexes or tables of contents. And if you’re doing a lot of rearranging of the material in your document, it sure would be nice to have a dynamic table of contents that doesn’t need to be recreated every time you make a change. In this section, we’ll look more closely at all these issues.

Using Styles for the Index and Contents

Depending on the type of document you’re creating, you may be able to save yourself a great deal of indexing effort by judicious use of defined styles. As you’ll recall from Chapter 10, the Define Styles dialog box includes a Format pop-up menu which allows you to give your styles a variety of formatting attributes. And it so happens that this menu contains both Index and Contents commands. These commands enable you to mark text for inclusion in the table of contents or index automatically when you apply a style. For example, if all the headings of a certain style in your document will be included in the table of contents, you can avoid marking any contents entries manually at all simply by choosing Contents in the style defini-464tion! When your document is complete, all you’ll need to do to create your table of contents is choose Create Contents… from the Contents submenu of the Tools menu.

While all “heading” items could reasonably be included in a table of contents, it’s not as obvious how you’d use a style for indexing. After all, you will generally mark only one or two words at a time to be used as index entries—not an entire sentence or paragraph. But since Nisus Writer does have character-based styles, you may find that there are certain kinds of words that do in fact appear in a special style and also need to be indexed, like all the menu command names in this book (you didn’t think I built this index manually, did you?), or technical terms, foreign words, or names. You probably won’t be able to index every word in your document using styles, but this can at least give you a good head start.

Multiple Indexes and Tables of Contents

Using defined styles to mark index and contents items also makes it possible to create multiple indexes or tables of contents within a single document. For instance, you may want to have a “main” index and also an index of names. To achieve this effect, first make sure all the names you want to index are marked in a particular defined style (you could call the style Name). This style does not need to have any font, size, or other attributes selected; it can just be a “dummy” style. Next, create your main index as usual. Now, to create the supplementary index, you must first unmark the items that are already marked for the index. (Don’t worry, you can undo this later.) The best way to do this is to use the PowerFind method in the Find/Replace dialog box (see the next chapter for details). Choose Any Character from the Wild Card menu followed by 1+ from the Repeat # menu. Select your entire Find expression and choose Mark for Index from the Index submenu. Now press the Option key and click Find All. All the terms in your document that have been marked for the index will be selected noncontiguously. Click once in your document window to make it active, and choose Unmark Index to take away the index marks. Now go to the Define Styles dialog box, and add the Index attribute 465 to your Name style. Choose Create Index… again, and this will make a new index containing only the names in your document. (If you want to restore the index marks to your document, just don’t save the file after you’ve made these changes.) You can follow similar steps with the Table of Contents style attribute to create multiple tables of contents.

Dynamic Tables of Contents

Tables of contents, like indexes, are static documents—they don’t change if the text in your main document changes. However, there is a way to create a dynamic table of contents that will continually update itself to show you the current text and page number of each contents item. The key is to use cross-referencing (discussed in Chapter 10). For the sake of discussion, let’s assume that you want all of the headings in your document to be in the contents. First, select each heading and mark it using the Mark… command. (Give your markers any name you like.) Now jump to the beginning of your document and insert a cross-reference to your first marker. Choose Marked Text or Graphic as the cross-reference type—in other words, this will put an exact copy of your header at the beginning of your document. Now type the Tab key and insert another cross-reference to the same marker, only this time using the Page # option. This way, you’ll have both the header name and its page number at the beginning of your document. Repeat this process for each of your headings. Be sure to enter the cross-references in the order they appear in your document. (Fortunately, it’s easy to tell if they’re out of order and rearrange them.) When you’re done, you’ll have a super-cool, dynamically updating table of contents!

It is even possible to have dynamic tables of contents for multi-file documents using Publish & Subscribe instead of cross-references.


Long documents can pose quite a challenge to you as a writer, to say nothing of testing the limits of your word processor. But as we’ve seen, with a little creativity we can make some of the most tedious tasks quite tractable. While 466 books and academic papers are usually intended for publication in print, there are other types of documents that spend their lives in electronic form—things like E-mail and HTML documents for the World Wide Web. In Chapter 16 we’ll look at the uses of Nisus Writer in cyberspace.

Copyright © 1995, 1996, 1999 by Joe Kissell

< Previous Chapter | Next Chapter >