Word, Styles and Structure

In a couple of posts, I’ve talked about thinking in terms of document
structure vs. thinking in terms of document formatting when using Word’s
styles. It occurs to me that it may not be clear what I mean by document
structure, so I thought I’d drill into this subject just a bit.

Before I get into structure, however, some of you may be wondering why I
didn’t include any screen shots in my discussion of the new styles UI. Well,
blogs.msdn.com (and the affiliated weblogs.asp.net) currently doesn’t provide a
way to host images locally. The folks who provide this service for Microsoft
employees are working on a solution for this. Until the solution arrives,
however, my only option is to go through the hassle of setting up some other
web-hosting service, uploading graphics there, and including external links in
my posts—an option I’d prefer not to exercise at this time. In the mean
time, Kirk McPike has a nice post on Office 2004, with
a screen shot
that shows the new Styles pane on the formatting palette. He also has a
shot of the revamped New/Modify Style dialog box.

Also, I’d forgotten to mention that we reworked the functionality of
Cmd-Shift-S for Word 2004. For those of you who don’t know, Cmd-Shift-S is a
short-cut key that’s supposed to move keyboard focus to the “Style” popup-edit
control—the left-most control on the formatting toolbar
(View/Toolbars/Formatting). Once keyboard focus is in that control, you can
type the name of the style you want to apply and hit <return> to apply
that style. For touch-typists, this is a nice feature. By the way, if you
type Cmd-Shift-S and change your mind, pressing <esc> takes the keyboard
focus back to your document.

Unfortunately, in Word X, this only works if the formatting toolbar is
visible. In Word 2004, however, we did two things. First, when you type
Cmd-Shift-S, Word now looks to see if that control is on a toolbar that’s
already visible. If so, it simply moves focus to the control. If the control
isn’t on a toolbar that’s visible, it makes the formatting toolbar visible, and
then transfers keyboard focus. I’ve simply added the Style control to my
standard toolbar, and use Cmd-Shift-S on a regular basis.

OK. Enough of the preliminaries. On to structure. What do I mean when I
talk about document structure? Well, depending on the kind of document you’re
writing, the text in that document will perform different functions. For
example, if you’re writing a memo, it will have a subject, a list of
recipients, possibility a priority level, and some body text that contains the
substance of the memo. For a letter, on the other hand, you’ll have
letterhead, recipient address, salutation, body text and closing. A long
document might have a title, a sub-title, and several levels of headings. It
might also have footnotes, with footnote reference characters in the main text,
or figures and tables that have captions below them. Other structural elements
include a table of contents, an index, or a bibliography.

For all of the structural elements I’ve listed above, Word has built-in
styles. In total, Word has more than 150 built-in styles. You can see them by
selecting Styles from the Format menu, and selecting “All styles” in the “List”
dropdown. In Word 2004, you can simply select “All styles” in the “List” dropdown
in the Styles pane of the formatting palette (which will not only give you a
list of styles, but will also attempt to show them in a WYSIWYG fashion). In
that list, there are a few web-centric styles (most starting with “HTML” in the
name). Since I’m typing this post in Word, perhaps an example will make this
clear.

I’m a developer, so I quite often want to include snippets of code in my
posts. The code is different from the body text in that I want it to have a
mono-spaced font, and I don’t want space between individual lines. When I
include code, I want it to look something like this:

int Foo(int n){ if (n < 2) return 1; return n + Foo(n – 1);}

When I typed the above code, I made it a single paragraph using
text-wrapping breaks rather than paragraph marks to start new lines, and
applied the “HTML Code” character style. Now, suppose I don’t want Courier New
as my font. I can redefine the “HTML Code” character style to use the Monaco
font if I want to (but that might not be all that nice to those trying to view
this page from Windows, where the font doesn’t exist). If I do, however, all
code snippets in my document will have the same look.

Most people point out this benefit to creating documents this way, but there
are really two. While it’s really easy to change the formatting of all similar
document elements and keep them consistent simply by applying different
formatting to the style itself, there’s a benefit that’s even better. By
taking advantage of the hierarchical nature of Word’s styles, you can achieve
consistency between document elements for formatting options that ought to be
similar between those elements.

The above code snippet gives an example of this. I don’t want any space
between the lines in the code snippet itself, but I want the space between the
code snippet and the paragraphs above and below it to be the same as the space
between two body-text paragraphs. In this case, the code snippet gets its font
formatting from a character style, but I could just as easily have made the
style a paragraph style that’s based on the “Normal” style. Since I’m using text-wrapping
breaks rather than paragraph breaks in the code snippet, it’s all one paragraph
as far as Word is concerned. That way, if I change the spacing between paragraphs
that have the Normal style, then the space between my code snippet and the
surrounding paragraphs will remain consistent. This is true whether “HTML Code”
is a character style or “HTML Code” is a paragraph style that’s based on the “Normal”
style.

Now, I’ve noted that Word has over 150 built-in styles. For most people,
you can use those styles to mark structure and do everything you want to do.
For those who have structural elements not covered by Word’s built-in styles,
there’s a general rule of thumb to keep in mind: If your style name includes a
formatting description, then you’re probably not thinking about structure. For
example, I’ve often seen people define new styles with names like “Body Text
Italics.” Why should “Body Text Italics” mark a different kind of structure
than “Body Text”? How about “Body Text Emphasis” instead?

As a rule of thumb, there will be exceptions to this, largely because the
English language has some ambiguity. For example, “Indent” is a formatting
description, but it can also serve as a structural definition. So, there will
be some overlap, and times when violating this rule of thumb makes sense.
However, when you find yourself including formatting descriptions in your style
names, it’s time to take a step back and make sure that you’re really thinking
about structure instead of formatting. Note that, for historical reasons that
are probably not worth mentioning in detail, Word’s table styles break this
rule all over the place. I point this out primarily to acknowledge how
sticking to this rule of thumb is not always easy, and requires a level of
discipline that hasn’t always been exercised even by those of us who design and
implement Word’s features.

Another rule of thumb when defining your own styles is to link styles for
similar structural elements using a common base style. For example, footnote
reference marks and endnote reference marks share a common structural function:
they both serve as a reference to some other text in the document. In general,
you’ll want them to have a number of formatting elements in common. It makes
sense, then, to define a “Reference Mark” character style and base your “Footnote
Reference” and “Endnote Reference” styles on the “Reference Mark” style. That
way, if you want to change, say, the height of reference mark superscripts, you
just change the “Reference Mark” style and both the Footnote Reference and
Endnote Reference will remain consistent. You don’t have to change both of
those styles in order to keep them consistent with each other.

This leads to another rule of thumb: when in doubt, create different styles
for different elements even if it’s not clear that these elements should have
different formatting. This can result in some extra work up front, but, more
often than not, you’ll find that you’d wished you’d had separate styles if,
indeed, the elements serve a different function in your document. Thinking in
terms of structure rather than formatting when working with styles can be
difficult at first, but you’ll probably find that it saves you a lot of work when
it comes to putting the finishing touches on your document.

I’ll close this post by pointing out a nice feature we added to Word 2004
that becomes even more useful if you’re using styles to mark structure. In the
Styles panel of the Formatting Palette, there’s a “Select All” button beneath
the “Current style of selected text.” Also, the popup menu for each style item
in the list includes a “Select All” command. They both serve the same
function: select all instances of text in the document that have either the
style and formatting of the current selection in the former case or the
particular style you’ve clicked on in the latter case. This provides an easy
way for you to see what portions of your document are marked using a given
style, and gives a handy way to review your document and see its structure
without having to click all through your document to see whether or not the
various elements have the correct styles applied.

 

Rick