This project is read-only.

Sorting ciatations within brackets

Mar 10, 2011 at 12:55 AM

While working on in-text citations of the AMA style I stumbled on another problem.

The style organises all citations in the citation sequence (order). And it works perfectly.

But sometimes you have to use several citations in one place (inside brackets). Or you decide to add some citations to already existing ones.
For example: [122, 51, 32, 78].

According to the requirements of the university I work for - all numbers within brackets must be sorted from the lowest to the highest number:  [32, 51, 78, 122].
Do you think it's possible to improve the XSL script so that the numbers are sorted in this way after updating the bibliography?


Mar 10, 2011 at 7:16 AM

No. Due to a design flaw this is not possible. In-text citations are not aware of their neighbours or their position within a group. So it is not possible to write code to sort them, even if you would do it from scratch.

It might be possible to write a complex macro which grabs the field code for each citation field and then tries to sort them but that's going to be a lot of work as flags have to be taken into account.


Mar 10, 2011 at 7:02 PM

Yeah, I thought so :-(
Thanks yves.

It would be more comfortable if Word could show (display) those numbers in the citation list (the list which appears after clicking the Insert Citation button).
This way I could check the numbers assigned to citations I want to insert and add them in a desired order.

BTW, are there any improvements in Word 2010 comparing to 2007 in this area?

Mar 10, 2011 at 7:16 PM

You can change what is displayed in that list. See the last post by me at

In your case, you probably want to use b:RefOrder over b:Tag and not take b:RefOrder into account when building your b:SortKey.

Not however that the numbers are pretty useless if the citations is not yet cited in the text as the number reflects the reference order. Uncited sources will just get a number higher than the highest cited one.

Mar 10, 2011 at 8:49 PM

Hmm... You are right. The numbers are useful only for already cited sources.
I think the alphabetical order of the "Insert Citation..." list (with authors names) is the best idea since it is much easier to find a given source.
But some additional info in the list would be helpful. So maybe the best solution would be to display numbers and also (probably more useful) to somehow mark all cited sources.

Mar 11, 2011 at 6:41 PM

I modified the code you posted in the mentioned link.
I thought the following format would look better for me:
Author - [ref No]
Title and rest

And here is the code:
   <xsl:value-of select="$displayAuthor"/>
   <xsl:text> - [</xsl:text>
   <xsl:value-of select="b:RefOrder"/>  

Is it correct?

If I don't want to change the the way the list is sorted then I don't have to implement any changes in the <b:SortKey> section, right?

It would be really wonderful if it was possible to somehow mark all cited items in the list.

Mar 12, 2011 at 3:10 PM

I believe that should work.

The sources passed to the xsl are not aware of their environment. They have no idea if they have been cited or not.

The information on which sources have been cited and which have not is stored in the Word object model though. So in theory you could create your own dropdown in Word where you take this information into account. A lot of work, but doable.

Mar 12, 2011 at 5:02 PM

I see. Once again, thanks for your help and all advices!