Mar

3

2009

I use Papers to search, download, and organize journal articles. After downloading articles, I read them, take notes, then export them into an EndNote XML file that can be later imported into my EndNote library. By doing this, I can take advantage of EndNote’s “Cite While You Write” function and let it automatically generate references in APA style (or any other style I have to work with).

It sounds like a great workflow. However, there is a glitch: the default way in which the Papers’s EndNote Exporter processes author names would output their first names as initials. That is, Jane Doe would be imported as “Doe, J.” instead of “Doe, Jane.” This would cause a disaster if you have multiple articles authored by people sharing the same last names and first name initials: EndNote would treat them as the same person and their works would be mixed up.


To solve the problem, I did a hack on the built-in EndNote Exporter in Papers. Using the Papers’s plugin SDK, it is fairly easy.

1. After mounting papers_sdk.dmg, you would see a couple of folders. Drag the folder Sample Exporters to your desktop or anywhere on your computer.

2. I assume you have had Xcode installed. If not, please install it from your Mac OS X install disc or download it from Apple. Double click on the mtEndnoteExporter.xcodeproj file and it should be opened in Xcode.

3. In the Xcode project window, you would see a list of files. Open the file named mtEndnoteExporter.m in the editor.

4. Search for the word authors and you will be directed to the code snippet we will work on.

5. on line 334, you would see the code

334
NSString *initials = [[[author objectForKey: @"initials"]spacedInitials]stringByAddingXMLEscapes];

The @”initials” is the cause of the problem. Now let’s change [[[author objectForKey: @"initials"]spacedInitials]stringByAddingXMLEscapes] to [[[author objectForKey: @"firstName"]stringByAddingXMLEscapes]

5. This should have fixed the problem. However, the variable name “initials” might be misleading and needs a new name. Now double click on initials and pause your cursor for a second till a blue triangle shows up. Click on the triangle and choose “Edit All in Scope” from the drop-down menu. Type firstName. Then save the file.

6. Now you need to build the plugin, then copy it to ~/Library/Application Support/Papers/PlugIns/Exporters to replace the original EndnoteExporter.exporter.

7. Export articles to EndNote and see the effect!

The //author code block should read like the following. You can simply copy and paste it into your own file.

326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
// authors
if([paper objectForKey: @"authors"]){
    [xmlstring appendString: (endnote7Format ? @"<AUTHORS>" : @"<contributors><authors>")];
 
    NSEnumerator *authors = [[paper objectForKey: @"authors"]objectEnumerator];
    NSDictionary *author;
    while (author = [authors nextObject]){
        NSString *lastName = [[author objectForKey: @"lastName"]stringByAddingXMLEscapes];
        NSString *firstName = [[author objectForKey: @"firstName"]stringByAddingXMLEscapes];
        if(firstName){
            if(endnote7Format)
                [xmlstring appendString: [NSString stringWithFormat: @"<AUTHOR>%@, %@</AUTHOR>", lastName, firstName]];
            else
                [xmlstring appendString: [NSString stringWithFormat: @"<author><style face="normal" font="default" size="100%%">%@, %@</style></author>", lastName, firstName]];
        }
        else{
            if(endnote7Format)
                [xmlstring appendString: [NSString stringWithFormat: @"<AUTHOR>%@</AUTHOR>",lastName]];
            else
                [xmlstring appendString: [NSString stringWithFormat: @"<author><style face="normal" font="default" size="100%%">%@</style></author>",lastName]];
        }
    }
    [xmlstring appendString: (endnote7Format ? @"</AUTHORS>" : @"</authors></contributors>")];
}

You can also download my hack file and place it into the folder in Step 6. However, I do encourage you to play with Xcode and explore the plug-ins yourself. Let me know if you have any questions.

1 comment

    chris on August 20th, 2009 at 3:38 pm
  • Thanks – this was excellent advice and helped a heap with getting the full rather than abbreviated journal name into EndNote : )

    For this to work, just swap out the (abbr ? abbr : name) for:
    [[journal objectForKey: @"name"]stringByAddingXMLEscapes]
    on line

say something