Using Wildcard Search and Replace to switch from manual numbering to automatic numbering

This is again in response to a question from the Word-PC e-mail list.

You have a document where the numbering has been entered manually, and you would like to convert this into a document which uses the different heading styles with associated numbering.

This is a slightly modified version of Example X (that’s ten, by the way) from Application 10.3 (Practical wildcard searches) in my book Doing your dissertation with Microsoft Word.

Students have manually numbered and formatted their thesis before learning about the principles taught in this book which allows Word to do their numbering for them. They want to start using this system (e.g., so as to still be able to use Word to create their table of contents), but cannot simply apply the heading styles, as all the old numbers still have to be deleted manually, and in any case it would be great if Word could actually find all their headings and update them to the styles automatically, without the students having to apply the style to each heading.

The secret is to start with the lowest heading level, hierarchically speaking. Thus, if your numbering is like this, then level 4 is your lowest hierarchical level:

Level

Numbering example

1

Chapter 1

2

1.1

3

1.1.1

4

1.1.1.1

Since the principle is the same for each level, I will only do levels three and higher in this example.

Also note that this assumes that the students very consistently did their numbering—they missed no separating periods, made no formatting mistakes, etc. Every time one of those mistakes is made, it means that the search and replace might miss something. In short, given the human propensity for error, it is best to first make a backup of the document (use my Word uTIlities to make that easy), and then to do a thorough check once the search and replace process has been completed.

For heading level three, the search specification is “([1-6].[1-9].[1-9] )(*^13)”—obviously without the quotes, here and further—which assumes that the students did not ever use more than nine third level subheadings to a single second level heading, the same for second to first level headings, and that the student has six chapters in the thesis. When in doubt, go big and specify it as follows: “([1-9].[0-9]{1,2}.[0-9]{1,2} )(*^13)” which allows for up to a single digit first level, a two digit second level, and a two digit third level (i.e., 1.1.1 through 9.99.99). Very important here is to note the space before the first right parenthesis.

To explain what this is doing, the search specification consists of two groups (as defined by the two sets of parentheses): The first group consists of the number, which is, in the first example, a digit between 1 and 6 for the chapter, followed by a period, a digit between 1 and 9 for the second level heading, followed by a period, and a digit between 1 and 9 for the third level heading, followed by a space. The second group is any text (in this case, the heading text) up to a paragraph mark. The replace with criteria is simply \2 with the formatting specification of Style: Heading 3 (Click on Format, Style in the Find and Replace dialog, and choose Heading 3). This (\2) puts only group 2 (the text and the paragraph mark) back in the replace action. The style is what adds the numbering.

Thus the number is stripped away, and the style applied, all at the same time.

In addition, the formatting for the Find What box should be set to the formatting used for the third level heading. This is actually quite necessary, as without that, the search and replace will also find cross-references in the text to those heading numbers, which is not what you want to do!

So it would look something like this:


The process can then be repeated, with ([1-6].[1-9] )(*^13) for the second level heading, and exactly the same replace with specification, except that now the formatting is set to Style: Heading 2, and of course the appropriate formatting for the Find what box too.

For the Chapter titles, again the appropriate formatting for the Find what box is set, and then the specification is (Chapter [1-6] )(*^13) with exactly the same replace with criteria and with the formatting specification of Style: Heading 1. In this way, an entire manually numbered thesis can be transformed into an automatically numbered thesis in a matter of minutes.

Since you have made a backup of the document, give it a bash, thrash it out, and see if you can get it working. I have actually used this technique on a number of theses already, and while I do concede that it is complex and heady, I can also attest that it is amazingly effective, giving great results and saving hours of manual work. I have sometimes just done a few Find Next operations until I am certain that it is finding what it needs to be finding, and is not finding the cross references, and then, when I feel bold enough, I hit Replace All (easy enough to do if you have a backup!).

Share

Writing and publishing WordPress Blog posts in MS Word

I suppose the first question I have to ask, before getting to the ‘How,’ is the ‘Why’ question: Why write blog posts in Word in the first place?

Why Blog with Word in the first place?

Well, I can’t really recommend Word as a tool (e.g., in my book), if I’m not willing to use it. I am also practising what I preach, and this blog post you are reading now was written in Word 2013 (the first few blog posts on my site were done with the native WordPress tool).

And I must also admit that the native WordPress tool for creating posts is quite nice. And the WordPress team has really gone to a lot of effort to see to it that you can create typographically professional blog posts.

But there are some distinct advantages to using Word, especially if you write the kind of blog posts that I do. I know that there are probably good responses to each of these, but the fact is that they do act as motivators to me, and I believe will also for many (but not all) other users.

Firstly, I can format my text quickly in Word with Styles. Yes, WordPress also has styles, but it’s quicker and easier to create and use new styles in Word.

Secondly, I have much more keyboard shortcuts in Word, and all told, Word generally gets the job done quicker than WordPress (compare adding a hyperlink in the two, as an example). I don’t have time for doing things slowly.

Third, I can work on the blog post while offline in Word, which is not so easy to do with WordPress.

Fourth, and this is a biggie, adding pictures is a pain in WordPress. Each time the picture needs to be added to the gallery, and then inserted into the post. Yes, WordPress has structured it so that you can do this in one smooth operation, but it just takes far too long. With Word, it’s just a case of simply inserting the pictures where I want them. When I publish the post, all the pictures are uploaded to the gallery in one go.

Fifth, I can use automatic numbering features (such as automatically numbering my figures, using cross-references, etc.). If I rearrange things in my post, Word sorts out the numbering for me. That’s no small advantage!

Sixth, I can do more advanced kinds of spelling and grammar checking, etc.

Seventh, and this is another biggie, tables are a cinch in Word, and a pain in most other programs. Having “cut my teeth” on Word, I sort of took doing advanced tables for granted. Word really is great with tables, all my gripes about minor things aside. It wasn’t until I started looking into the printing of that book, and developing websites with basic tools like Google Sites and even FrontPage, that I began to appreciate how far ahead Word is with tables. Want a table like the one in this post? Word should be your tool of choice.

I suppose I could come up with even more, but I think this pretty much covers my main motives.

How to set up the WordPress Blog account in Word

The first thing to do is to set up the WordPress account to which you are blogging.

Microsoft gives some very short and cryptic advice here:

http://office.microsoft.com/en-us/word-help/help-with-blogging-in-word-HA010164021.aspx

WordPress’s basic guide is here:

http://codex.wordpress.org/Weblog_Client

The basic idea is that you have to tell Word where to find the xmlrpc.php on your site, but both of the above assume that your blog is on the front page of your site—admittedly, many sites are set up like that.

Apart from locating the file, you also have to prepare your site to receive the blog posts. If you have WordPress 3.5 or later, this is enabled by default, but for earlier versions, you need to enable the Remote Publishing setting in the Writing section of the site settings. So step 1 should be: Upgrade to the latest version of WordPress.

Step 2, then, is find the xmlrpc.php file. However, my blog was a bit atypical, in that I wanted a static front page, and my blog page is not the main page. This caused some problems, but that helps explain to you, dear reader, how to get yours set up. Also, if you use some file browsers, the file path given makes (to me) no sense. For example, Figure 1 shows the CPanel file browser. If I had to infer the file path from that, it would be /home/trueinsi/public_html/xmlrpc.php. But when I connect with my trusty Total Commander‘s FTP client, I see that it is actually public_html/insight/xmlrpc.php (Figure 2). This equates to http://trueinsight.za.com/insight/xmlrpc.php. The /insight/ part of the location is, of course, the subdomain.

Figure 1    CPanel file browser

Figure 2    FTP via Total Commander

Now I’m getting somewhere. After having found the location of the xmlrpc.php file, the first thing you want to do in Word is to actually open a blank blog post. This is the easiest way to access the blogging tools in Word. Yes, you can add the tools from the ribbon to a new ribbon of your choice in Word, or to the QAT, but since you want to write a blog post anyway, this is just a lot less effort. Note that this setup needs to be done only for the first post. Word then remembers all your settings, and they are available each time you start your next post.

So, click on New, Blog post (Figure 3). Word opens a new blog post, with a trimmed down set of ribbons (too trimmed down, if you ask me)—Figure 4.

Figure 3    Creating a new blog post in Word

Figure 4    Blog Post ribbons

To set up your accounts (I eventually want to maintain at least two regular blogs) click on Manage Accounts (Figure 5), which will open the Blog Accounts dialog (Figure 6).

Figure 5    Manage Accounts

Figure 6    Blog Accounts dialog

From there, click on New, and in the New Blog Account dialog, select WordPress as your Blog type (Figure 7).

Figure 7    New Blog Account dialog

This, in turn, opens the New WordPress Account dialog (Figure 8), where you have to enter the location of your xmlrpc.php file (as discussed above) and your user name and password.

Figure 8    New WordPress Account dialog

You can also set the Picture options (Figure 9).

Figure 9    Picture options

Figure 10 shows the dialog with all the settings completed.

Figure 10    Completed account settings

When you have added the details and clicked on OK, Word will warn you about the security of the post (Figure 11).

Figure 11    Sending information

So now you’re all set, and from now on, it should be as simple as just selecting your account and writing your blog entry.

Setting up individual blog posts

When the Blog template is opened, it displays a title with the account you want to use (Figure 12). If you have multiple accounts, you can select the right account from the dropdown that will appear when you click on the account line (Figure 13).

Figure 12    Blog title and account

Figure 13    Selecting a different blog account

It is also a useful idea to add categories to your posts. For example, I have set up my menu to include several categories, so that they serve as handy shortcuts to people wanting to read posts related to that category. So, for example, Figure 14 shows my category for Excel blog posts.

Figure 14    Example of a blog-post category in a site menu

Adding categories is easy—just select Insert Category from the Blog Post ribbon tab (Figure 15). The list of categories will be displayed underneath the account information (see Figure 13 above).

Figure 15    Adding categories

For the rest, simply write the blog post, as per normal. The dearth of tools caused by Word hiding normal editing ribbon tabs is a bit annoying, but is easily overcome by adding the tools you want either to the Blog Post ribbon or the QAT.

Publishing the blog post

Once the post is ready, you can publish it straight from Word (Figure 16). I generally recommend first publishing it as a draft, which is exactly the same as saving a blog post as a draft from the WordPress editor. The advantage to this approach is that it allows me to go to WordPress and satisfy my paranoid self that everything looks right before going public with the post (for example, with this post, I forgot to update my fields, so my figure numbering and cross-referencing was out—I could then go back to Word and correct it). If you’re braver, you can go straight to publishing from Word. It stands to reason that while you can write the post offline, you need to be online to publish the post.

Figure 16    Publishing a blog post

Editing existing blog posts

What I find really nice is the fact that you can also open existing posts in Word and edit them. Simply click on Open Existing (Figure 17), choose the post you want to edit from the Open Existing Post dialog (Figure 18), and you’re good to go.

Figure 17    Opening existing blog posts

Figure 18    Open Existing Post dialog

Conclusion

In short, while there are many Blog writing tools out there, I find that for the kind of work I tend to want to include in my Blog posts—captioned figures, tables, fast editing, etc., Word is a good tool of choice, albeit not the only one. After some simple setup, blogging with Word is clean and simple, the way it should be.

Share

Separate table (or figure) numbering for appendices

A question recently came up in the Word-PC e-mail list which is quite typical of something a student doing a thesis or dissertation might come across. I will also modify this post to that context. I was quick to give an answer, and only later thought through all the implications, so that my initial answer would have been less than satisfactory. Here is, what I believe, a more robust solution.

The requirement is as follows:

  1. A dissertation is using chapter-based numbering instead of sequential numbering for its tables (i.e., in Chapter 3, the tables would be 3-1, 3-2, etc.). Note of course, that the student can set the delimiter (here a hyphen) in the process of activating chapter based numbering (the dialog is shown below)—many students use a period.
  2. The dissertation also has appendices, which must be numbered with uppercase letters (Appendix A, Appendix B, etc.).
  3. Those appendices contain tables (or figures, or any other label created with the Insert Caption tool).
  4. Those tables need to be numbered in the chapter-based style, but now reflecting the Appendix number. Thus A-1, A-2, etc. for Appendix A, and so on.

Parts of these are very easy to do. It’s the combination that is a headache.

Requirement 1 is simple. Just use the Insert Caption tool to add the numbers, and set the table-based numbering. See p. 162–163 of Doing your dissertation with Microsoft Word if you have the book (if you don’t some screen caps below will help).

Requirement 2 is equally simple. I have created, in the two templates (Thesis 2010.dotx and Thesis up 2009.dotx) which can be downloaded from the examples page, a style called “Appendix Title” that uses normal upper case alphabetic numbering. This is what the style looks like, showing its definition:

Some pointers. When modifying the style, be sure to go to the paragraph dialog and set its outline level to Level 1. This will ensure that it should be included in your Table of Contents (mine is based on Heading 1, which gives the same end result). Using this style for your appendix headings gives them the desired numbering scheme, thus satisfying requirement 2.

Requirements 3 and 4 are dealt with together, as these are the more tricky ones.

Here are the problems:

When Word adds caption labels, and those caption labels use chapter-based numbering, Word actually adds two fields: One is a STYLEREF field which is set to automatically pull in the heading level 1. The second is a SEQ field, which is set to restart after each occurrence of heading level 1.

Furthermore, whenever you add a table anywhere in the dissertation, Word runs through all instances of the table, and resets all of them. If you thus make changes to the switches of these caption labels in the appendix, they can get nixed by adding any table anywhere else in the dissertation.

To get started, use the Insert Caption tool to insert the caption label for the first table in the first appendix. We will modify the fields it adds afterwards (or, if you are confident writing out fields by hand, you can just skip ahead).

Click on Insert Caption (Captions group, References ribbon). From the Caption dialog, choose Numbering… to open the Caption Numbering dialog, and include the chapter number, also choosing the delimiter (separator). No need to change the Chapter start with style setting here, since all that is allow are the nine built-in heading levels. We will modify this manually later:

Once the chapter-based numbering has been set, the Caption dialog should look more or less like this:

Clicking on OK let’s Word add the caption label, using two fields.

Let’s first look at those fields Word adds. This is what they look like before and after being selected and set to Show field codes (Shift + F9):

So. The field codes (the bits between the braces) and text Word adds, is:

Table { STYLEREF 1 \s }–{SEQ Table \* ARABIC \s 1}

We can’t just change the STYLEREF field from 1 (Word shorthand for the built-in style “Heading 1”) to “Appendix Title,” as Word will nix this each time it updates the caption labels when a table is added somewhere. We also cannot change the restart switch for the SEQ field to anything other than 1-9 (i.e., Word’s nine built-in heading styles).

So we need a slightly different approach.

The first thing is to keep Word from automatically changing these table captions. The second is to get it to restart with each new appendix. Both of these are accomplished by setting the first appendix table caption to:

Table { STYLEREF “Appendix Title” \s }–{SEQ AppendixTable \* ARABIC \r 1}

The change to the STYLEREF field will pull in the required appendix number (from my custom style–if you are using a different style, then you would have to include whatever that style name would be). But note that it is the change to the SEQ identifier (from Table to AppendixTable) that essentially creates a new sequence, and prevents Word from reverting the STYLEREF field from STYLEREF “Appendix Title” back to STYLEREF 1. The SEQ field switch \r 1 which has replaced the \s 1 switch tells Word to restart at 1 here. Note that the 1s in the two switches have vastly different meanings. The \s 1 means restart numbering if there is an instance of “Heading 1” style between me and the preceding similar caption. The 1 refers to Heading 1. The \r 1 means restart right here, using the number 1. Here the 1 refers to 1.

But still more needs to be done. For each subsequent table in each appendix, the caption must be:

Table { STYLEREF “Appendix Title” \s }–{SEQ AppendixTable \* ARABIC \n}

Here the \n switch just tells Word to continue the numbering sequence from the previous similar caption label.

So the first table caption of each appendix will be:

Table { STYLEREF “Appendix Title” \s }–{SEQ AppendixTable \* ARABIC \r 1}

And the table caption of all other tables in each appendix will be:

Table { STYLEREF “Appendix Title” \s }–{SEQ AppendixTable \* ARABIC \n}

Probably the best way to achieve this is to simply copy and paste the caption paragraph for each new table. Yes, it’s a little manual work, but it’s not that bad. If you’re work averse, you could always record a macro writing out the fields (remember to use Ctrl + F9 to add the field braces) and then run that macro each time. Remember to also set the paragraph style to Caption, thus ensuring consistent formatting for your chapter and appendix tables.

Unfortunately, the job is not quite done.

Because we changed the SEQ field from SEQ Table to SEQ AppendixTable, the tables in the appendices will not appear in the list of tables. So we need to fix that.

To get that done, insert (or re-insert) the list of tables.

From the Table of Figures dialog, select the Options button:

In the Table of Figures Options dialog, specify that the table of figures should be built from the Caption Style:

Once you click on OK, notice that back in the Table of Figures dialog, Word will have set the Caption label to (none). This won’t do, because that means that the table will include, tables, figures, and any other caption labels. Compare the Table of Figures dialog below to the one shown above:

Just reset this to Table, and click on OK:

The end result is a list of tables that includes both your chapter and appendix tables:

The great thing about this approach is that it is stable and it works. It will withstand the updating caused by adding new tables or deleting existing tables, updating all fields in the document, closing and re-opening the document, etc.

It does require a small amount of manual work, but I think it is well worth the effort.

Update (2014-03-11):
If you want to do this with multiple captions (e.g., Tables and Figures in your appendices), then a little more work is needed. Read about it here.

Share

Change revision author names

Announcing a new addition to the True Insight Word uTIlities

Change revision authors

It seems that people often encounter problems with the revision author name when using track changes to review a document.

The problem may stem from various circumstances:

  • They forget to set the user name before making their revisions
  • They work on a single document from multiple computers where the registered user name is not the same on the various computers
  • They have made their revisions, but wish to anonymise them before sending them to another person

Regardless of these various situations, the desired end result is the same–to change the author names of revisions once they have been made.

To fully understand the solution, we just need to understand something about reviewing in Word. Essentially, reviewing a document can entail two things: Commenting on the text (done through comments), and suggesting actual changes (either insertions or deletions) through revisions. Interestingly, if you look at the navigation buttons on the Review ribbon, then you will notice that there are buttons that take you from one comment to the next (or previous), and buttons that take you to the next (or previous) revision.

However, while the buttons for the comments do exactly that–take you only to comments, bypassing revisions; the buttons for revisions take you to both revisions and comments. Granted, you can choose to ignore comments (and some other options–even insertions and deletions) from the Show Markup options:

 

In short, while comments are part of the reviewing process, they are viewed differently in the Word object model.

When faced with this problem, the first thought, of course, is to do this manually. However, you will notice that this is not possible, for both comments and revisions.

The next thought is to do it via VBA (if that is an option–if not, see below).

For comments, this is entirely possible. The Comment Object has an Author property, which is read/write. Thus, code like this will change the author name of comments:

For i = 1 To .Comments.Count
  .Comments(i).Author = str_authorname
  .Comments(i).Initial = str_Initial
Next i

But for some odd reason which only the people at Microsoft will know (or sometimes I wonder if even they will know the reason for decisions like this), the Revision Object also has an Author property, but it is read only. Thus, a snippet of code like this, which Word’s VBA IntelliSense will happily allow one to write, will result in an error:

For i = 1 To .Revisions.Count
  .Revisions(i).Author = str_authorname
Next i

This is a problem, since often, being able to change the comment author but not the revision author will not be a satisfactory solution.

What to do?

Well, there are other ways to approach the problem. firstly, if the aim of the exercise relates to my third bullet above (but not the first two), then the document comments and revisions can be anonymised using the Document Inspector:

Note that you want to use the Remove Document Properties and Personal Information button, not the Remove Comments, Revisions, Versions, and Annotations button–you want the revisions and comments to remain, but not be attributed to any author. This approach can be seen in Office help articles like this one: http://office.microsoft.com/en-us/word-help/change-the-author-name-for-review-comments-HA010036415.aspx

 Ok. what about the first two problems I mentioned above? This sort of change can also be made manually, as described by Andrew Savikas and Andy Bruno in Andrew Savikas’ book Word Hacks: Tips & Tools for Taming Your Text. The basic technique is described here: http://oreilly.com/catalog/wordhks/chapter/hack41.pdf, but even this process can seem daunting to less advanced users.

After all that, it does seem as if this new tool in the uTIlities set is a bit moot, but at the end of the day, it has firstly been requested by some users, and secondly, presents what I believe Microsoft should have allowed for these functions. It is simple and effective, and requires you the user, not to have to use VBA or a relatively complex hack to get the job done.

The use of the tool is simple. Once the document is open, select the tool from the uTIlities ribbon, decide how to manage the document (make a backup and do the changes in the original, or do the changes in a renamed copy of the original):

And then choose the author names to replace (any number of names can be replaced with a single new name), add the new author name, and decide whether to change the comments too (and if so, what Initials to use):

If all goes well, clicking OK will do the job. Simple enough.

To date, I know of no other tool that automates this process, and yes, I did get it right to make the change using VBA (naturally!), but of course, I had to take the long way around to get past that read only property. I’ll leave you to speculate about the details!  🙂

So, if you want to give it a spin, go visit the Word uTIlities page and download it today!

Share

Numbered equations in Word

Microsoft boasts of its academic staff, but really, I often get the impression that no-one involved with Word has any idea of what academics do, need, or want. When the referencing tools in Word came out I got all excited, only to be severely disappointed (you can read about all my gripes in my book). Basically, after more than six years now (from Word 2007 to Word 2013), Microsoft is still more than two decades behind in the reference management field. Then again, is it fair to expect Word to do what is actually the domain of a whole difference class of software? Probably not, but then why did Microsoft even try?

One thing that Word should be able to do, and that you will find people regularly complaining about, is to neatly number equations. It seems that waaaaaaay back (I can’t even recall how far back, but I am certain that it was pre-Word 95), someone at Microsoft thought that being able to add a caption titled “Equation” with the Insert Caption tool was all that any academic would ever want (they probably have never worked through a statistics textbook).

The generally touted workaround (it remains a workaround until Microsoft actually addresses the problem, which seems as likely as Microsoft ever building true 3D capabilities into Excel) is this: Add an unbordered table consisting of one row and three columns, and then add the equation in the middle column, and the number in the right column. See, for example:

http://ist.uwaterloo.ca/ec/equations/equation2007.html

http://blogs.office.com/b/microsoft-word/archive/2006/10/20/equation-numbering.aspx

http://word.tips.net/T000273_Numbering_Equations.html

Here’s my suggested method. I admit that it still requires more manual labour than I feel should be necessary, but I do believe it presents a more robust solution than that presented by Microsoft’s employees. The first step is to add two blank paragraphs, position yourself in the first of these, and then add the equation. Then position yourself to the right of the equation (i.e., just before the first of the two paragraph marks), and press Ctrl + Alt + Enter to add a Style Separator. Now add a tab, and then insert an Equation caption (remembering to set the numbering so as to include the chapter number, and the caption itself so as to Exclude the label from the caption).

Adding an equation caption

The convention, again, is for the equations to be enclosed in parentheses, which can now be added.

This will leave your equations, properly centred on the page, with auto-numbering equation captions properly aligned, that can easily be used to generate a list of equations using the Insert Table of Figures tool.
Admittedly, this may not be an ideal list of equations, as the fact that the actual caption “Equation” is excluded from the caption, means that the list will not contain entries like “Equation 2.1                p.13,” but rather “(2.1)            p.13.”
However, using some bookmark-modification techniques, the parentheses can easily be removed from the reference, and with some creativity, the remaining list can be formatted quite effectively (this need only be done once). Also, very often the idea behind numbering is not to generate a list of the actual equations, but rather to have an auto-numbering list that can be cross-referenced. Because the Caption tool uses the SEQ field, it remains ideal for this purpose. This list will show the equations with the right numbers, in the right order, with the right page references.
By this stage, you should have something similar to this:

Equation separated from caption by Style Separator.

The last thing that needs to be done is to align the equation number. By some quirk, it seems that, while the Style separator does allow you to combine two paragraphs into one, only the first paragraph’s tab stops seem to apply—since Microsoft has totally neglected documenting the Style separator, we are left at a loss as to whether this is by design or by oversight. And yet, if you close and save the file, and re-open it, you may find Word wanting the tab stop for the second “paragraph.” Thus, the safest thing to do seems to be to add the same tab stop on both sides of the Style separator—you need to position the I-beam both to the right and the left of the Style separator, and then add a right tab stop (remember that the Tabs dialog can easily be opened with Alt, O, T) equal to the text width of your page (e.g., if the ruler width is 16 cm, then add a 16cm right tab stop), as is demonstrated below:

Adding a tab stop to align an equation caption

The end result should be something like this:

A properly aligned equation caption

 Of course, all that work can get quite tedious, which is why I have created a simple macro to automate the work for you. You could add this yourself, or you could install my Word uTIlities, which includes this macro where it can be run with a click on the ribbon.

Sub AddCaptionedEquation()
'Created by J. Raubenheimer, 2012
'Adds an empty equation box and a right-aligned equation caption
  With Selection
    .TypeParagraph
    .TypeParagraph
    .MoveUp Unit:=wdLine, Count:=2
    .OMaths.Add .Range
    .MoveRight Unit:=wdCharacter, Count:=1
    .InsertStyleSeparator
    .TypeText Text:=vbTab
    .TypeText Text:="("
    .InsertCaption Label:="Equation", ExcludeLabel:=1
    .TypeText Text:=")"
    .HomeKey Unit:=wdLine
    Dim intPos As Integer
    With .PageSetup
      intPos = .PageWidth - .LeftMargin _
      - .RightMargin - .Gutter
    End With
    .ParagraphFormat.TabStops.Add Position:=intPos, _
     Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
    .HomeKey unit:=wdLine
    .ParagraphFormat.TabStops.Add Position:=intPos, _
     Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
  End With
End Sub
 
Please note, though, that this macro must only be run in a document which already uses the Heading styles to divide and number the chapters.

One last thing about this method needs to be said. Because of the way Word handles cross-references, you will notice that a cross-reference in your text to the equation will include the parenthesis on the left of the equation number. This problem, is caused by the hidden bookmark Word adds around the caption number when you add the cross reference. Again, my uTIlities contain two tools (the Bookmark Manager or the Shrink bookmark tool) that fix this.

After all is said and done, I admit that this approach is still not ideal–the ideal would be a real fix from Microsoft–but it does, to me, present several advantages over other methods, and the fact that I have automated it means that this is not a bad solution to the student who needs numbered equations–it’s what I use.

Share

Using BibWord for extended referencing capabilities in Word

What options does a postgraduate student who wants to automate their referencing have? Should they buy an “expensive” RMS program? Should they consider an open source alternative? Or can Word’s citation tool  still make the grade for a thesis or dissertation despite it’s shortcomings?

Enter BibWord. BibWord was developed by Yves Dhondt of MIT in an attempt to overcome some of these limitations to the Word Citations & Bibliography tool. It is downloadable freely from the website (http://bibword.codeplex.com).

Essentially, BibWord allows you to “hotwire” Word’s citation styles and add styles of your own. The tool basically consists of two parts: Firstly, the “end user” tools are for students who just want to use the tools, you will find some extra styles which Yves created on the site. These can be copied to the Bibliography Styles folder on your PC  Also, there is the BibWord Extender which allows for the creation of numerically ordered in-text citations (e.g., when referencing according to the Vancouver referencing style). Secondly, there are the “developer” tools, the BibWord template and the BibType tool, for more advanced users, who wish to develop their own styles. I have, for example, used the BibWord template to develop a (relatively complete) South African Harvard style for Word.

If you want to use the developer set of tools, details can be found on the BibWord site. I will briefly show how to use the BibWord end user tools here.

The first thing to do is to copy the BibWord styles to the Style folder of your Word installation (typically, for Word 2010,
C:\Program Files\Microsoft Office\Office14\Bibliography\Style, and not
C:\Users\UserName\AppData\Roaming\Microsoft\Bibliography\Style)—you may need administrator access to do this. The figure below shows this folder on my PC (Windows 7, Office 2010, 32-bit), before the BibWord styles were added (i.e., these are the styles provided by Microsoft with Word 2010 SP1 or Word 2007 SP3).

Word-Citation-Styles-folder

Word Citation Styles folder

The styles that are available from the BibWord web page (as at September 2012) are listed in the table below. One more style—HarvardSA.XSL—which I created using the BibWord template, can be downloaded from the examples page.

Referencing Styles Available via BibWord

Style File names
Associação Brasileira de Normas Técnicas (ABNT) ABNT_Author.XSL
ABNT_Num.XSL
ABNT_Num_Alt.XSL
Association for Computing Machinery (ACM) ACMCitSeq.XSL
ACMNameSeq.XSL
American Medical Society (ACS) ACSCitSeq.xsl
ACSCitSeq2.xsl
American Medical Association (AMA) AMA.XSL
American Sociological Association (ASA) ASA.XSL
Chicago Footnotes (beta – not in zip) CMSFootnote.XSL
Council of Science Editors (CSE) CSECitSeq.XSL
CSENameSeq.XSL
Harvard – AGPS HarvardAGPS.XSL
Harvard – Anglia HarvardAnglia.XSL
Harvard – Exeter HarvardExeter.XSL
Harvard – Leeds HarvardLeeds.XSL
Humana Press Humana.XSL
IEEE IEEE_Alphabetical.XSL
IEEE_Reference.XSL
Lecture Notes in Computer Science (LNCS) LNCS.XSL
Modern Humanities Research Association (MHRA) MHRAFootnote.XSL
Nature Nature.XSL
Vancouver Vancouver.XSL

Once these styles have been copied to the Style folder, they will appear in the Style list of the Citations & Bibliography group of the References ribbon, and can be used as described before.

Citation-Style-list-showing-extra-BibWord-styles

Citation Style list showing extra BibWord styles

Note, though, that if the document is opened on another computer which does not have the styles loaded, the Style will display as Unknown, and any attempt to work with the citations or bibliography will result in Word changing the style to the default style for that computer.

BibWord style not found on computer

A last lifeline from Yves is the BibWord Extender, which overcomes two problems with Word’s own referencing system. Firstly, if multiple references are used from the same author(s) in the same year, the convention is to add a date suffix (e.g., 2012a, 2012b, etc.). Word cannot do this. Secondly, while Word can number references in the order they occur in the text (when using numerical referencing styles, of course), Word cannot order the bibliography alphabetically and then assign the numbers in the text accordingly. The BibWord Extender allows both of these possibilities, and it should be noted that the BibWord styles which are suffixed with an asterisk are styles which will benefit from the use of the Extender. Unfortunately, because of the way Word creates citations, making any changes to the references (e.g., adding new sources), may invalidate what has been done by the Extender, requiring it to be rerun. Thus, it is best to use it only when the document has been finalised, and no more changes to the sources will be made. Simply start the tool (it may as for confirmation or an indication of where the bibliography styles are located on your computer), then use the file browser button to load the file to the Word Document text box, and select Extend. Once it has completed, re-open Word, and re-select the same referencing style to force an update of the citation and bibliography fields.

BibWord Extender

A nice touch of this tool, which I recommend you use, is that it first creates a backup of the Word document. The backup is indicated with an “_orig” suffix before the file extension.

Conclusion

So can a thesis be done with this tool? In short, yes. I remain very disappointed by a generally substandard offering from Microsoft, but if you look at the thesis.docx file on the examples page, you will see an example of a thesis that used this for its referencing, and was submitted and accepted. If you’re planning a serious, long-term academic career, then I would say: Don’t waste your time. If you have to do a thesis or even a dissertation so that you can complete your degree and then venture out into the big wide world, then this tool will do the job for you with the minimum of fuss. Just don’t try to add hundreds of references–you will find it becoming unwieldy as you try to manage your references. I suspect that one or two hundred references will be fine, but the more you add, the worse it’s lack of serious sorting, searching and grouping tools will count against it.

Update:

Struggling to view those folders mentioned above to which you need top copy the files? Then read this post: Getting proper access to all the files on your PC

Share