Editor for this issue: Annemarie Valdez <avaldez
emunix.emich.edu>
Heartfelt thanks to all those who responded to my recent posting (6-1581) about numbering examples in MS-Word on Mac: bao (fasbaozmMail to author|Respond to list|Read more issues|LINGUIST home page|Top of issueleonis.nus.sg); Karl-Michael Schneider; Manuel Sifre; Eddy Ruys; Scott Herron; h. kelly shuldberg; Jeff Lidz, J.C.Davis; John E. Koontz; Chris Culy; Wayne Cowart; Angela Williams; Cassian Braconnier; Stuart Luppescu; Peter Avery; Carsten Breul; Dawn MacLaughlin; Kathi Taylor (& Susan Freel); Robert Poletto; Annabel Cormack; Kjetil Raa Hauge; Scott Randal To those who suggested moving to another software package (e.g. LaTeX, FrameMaker), thanks for the tips, but I should have mentioned that there are budgetary constraints here! As a number of you pointed out, further tips are contained in an earlier posting to this list from Jon Aske. The key is in using Fields (a common observation that I was relieved to read is that this is not at all obvious from the manual). Use the menu bar (with a sequence of commands which can also be recorded as a macro), or write a macro directly. Macros can also be assigned to a toolbar button or key-combination for more efficient operation. I give below a menu-based approach, then several macros people kindly sent me, and finally two macros I have designed based on what I have learned - one for setting up an example number, one for cross-referencing to examples thus set up. 1. This menu-based approach is based on info from Scott Heron: (A) Choose: Insert/Field, click SEQ, which will give you a SEQ in the bottom window; add "ex \n" to the right of the SEQ code in lower window, press RETURN (the ex is the name or identifier for the counter, the \n is to increase the number by 1). The first time you do this a 1 will show up, the second a 2, etc. (You can set up more than one such counter/sequence by giving each sequence a diferent name an Identifier; there are many predefined sequences, e.g. {SEQ chapter} refers to chapter numbers.) (B) Cross-referencing examples: Very easy. First you have to create a bookmark for an example you want to cross-reference: a) Highlight the number created in (A) above (with or without the parentheses). b) Choose Edit/Bookmark, give the bookmark a name (40 characters), e.g. donkey_sentence c) When you want to refer to it, you type, e.g., "As we saw in example "; then you click Insert/Cross-reference, click bookmark, click the name of the bookmark, click insert. When you add a new example between two other examples, Word will give it the number following the previous number, so for example, if you insert a new example between (9) and (10) then the new example will also be given the number (10). To update the numbers, select the whole document and press F9 [turns out to be shift+F10 in Word 6 on my PowerMac. You can also do this with a key press - look this up under "updating fields" in the manual - it's Command+Option+click in Word 6 on PowerMac - PW] 2. Macros: a) Robert Poletto sent the following macro, which puts in caption labels for the example numbers. Word automatically renumbers the labels for captions, which is one advantage over using SEQ fields. You need to define a style called "Ex1" as a favourite style for examples. Sub MAIN InsertCaption .Label = "(", .TitleAutoText = "InsertCaption1", .Title= ")", .Position = 1 REM this does the main work StartOfLine CharRight 2 EditClear - 1 REM this deletes the extra space between the ( and # EndOfLine Style "Ex1" REM change "Ex1" to your favorite style for data End Sub These can then also be cross-referenced, of course. b) Kathi Taylor passed on the following macro from Susan Freel: You will need: Paragraph Style named 'Example Body' - this will be the format of the example text; Character Style named 'Example Tag' - this will be the format of the actual "Example 1:" tag Sub MAIN 'Insert tag text, section number, and auto number field Insert "Example " InsertField .Field = "AUTONUM " Insert ": " ParaUp 1, 1 Style "Example Tag" CharRight 1 'Format paragraph to the style 'Example' ParaDown 1, 1 Style "Example Body" CharLeft 1 Style "Default Paragraph Font" End Sub c) Annabel Cormack sent the next one: Sub MAIN Style "ex1" FormatFont .Bold = 0 Insert "(" InsertField .Field = "SEQ ex \* MERGEFORMAT" Insert ")" + Chr$(9) + Chr$(9) FormatFont .Bold = 0 End Sub d) Finally, I list two macros that I have put together using tips from various of the above-mentioned, and other discoveries made since. The first (i) enters a new example number, in (), AND sets up a bookmark for it via a dialog in which the user enters a name - note that this must begin with an alphabetic character, and note that no check is made for existing bookmarks of the same name. The second macro (ii) provides a cross-reference at the current insertion point to an example already defined using the first macro (i.e. using the 'bookmarks' thus established, selected from a dialog window). Formats can be added, of course - see examples in the macros above. Please note that these macros have not been extensively road-tested - I'd be grateful for any suggestions for improvement. (i) Sub MAIN 'first set up the number for the example, in () Insert "(" InsertField .Field = "SEQ example \n \* MERGEFORMAT" Insert ")" EndOfLine WordLeft 3, 1 REM selects "(-number-)" as text for bookmark 'then put up a dialog for getting a bookmark name for cross referencing Begin Dialog UserDialog 290, 122, "Name" Text 10, 6, 260, 12, "& Enter bookmark name " TextBox 10, 43, 236, 20, .TextBox1$, 0 OKButton 10, 87, 88, 21 CancelButton 117, 87, 88, 21 End Dialog Dim dlg As UserDialog DisableInput 1 REM this bit allows ESC to work during dialog Dialog dlg DisableInput 0 'add the bookmark name to the list of bookmarks EditBookmark .Name = dlg.TextBox1$, .SortBy = 0, .Add ' add a tab after the example number EndOfLine Insert Chr$(9) End Sub (ii) Sub MAIN 'first get the list of bookmarks for the current document size = CountBookmarks() - 1 Dim marks$(size) For count = 0 To size marks$(count) = BookmarkName$(count + 1) Next 'then put up a dialog to select the example to cross-refer Begin Dialog UserDialog 320, 50, "Example list" Text 27, 8, 200, 13, "Choose example for x-ref:" DropListBox 29, 25, 160, 20, marks$(), .DropListBox1 OKButton 226, 5, 88, 21 CancelButton 226, 29, 88, 21 End Dialog Dim dlg As UserDialog DisableInput 1 REM this bit allows ESC to work during dialog Dialog dlg DisableInput 0 'finally, enter the example number into the text name$ = marks$(dlg.DropListBox1) InsertCrossReference .ReferenceType = "Bookmark", .ReferenceKind = "1", .ReferenceItem = name$ End Sub