CiteInPages is a suite of four Applescripts that allow the open source reference manager BibDesk to be integrated with Apple's word processor, Pages (v. 3, from iWork '08). Using BibDesk templates, "working citations" containing BibTeX cite keys in a defined format can be dragged or inserted by script from BibDesk into Pages documents as the documents are edited. CiteInPages replaces these working citations with numbered or author-date in-text citations, creates a correctly-ordered bibliography based on a BibDesk template, and pastes the bibliography into the Pages document. It has advantages over commercial reference managers for use with Pages because it works on native Pages files through Pages itself and does not require converting the file to rtf, which may cause some loss of information, inserted images or layout features. CiteInPages is freely available for use and modification with a BSD license.
Download: CiteInPages v. 1.01 (201K zip file containing four scripts, a citation template, two bibliography templates and installation instructions). Version 1.01 requires BibDesk 1.3.14 or beyond. Notes: CiteInPages numbered bibliography scripts require Leopard (OSX 10.5). It is best not to hide File extensions in the Finder when using CiteInPages (see note #16 in the Notes section below). CiteInPages is not compatible with separate footnotes in Pages documents (see note #9 in the Notes section below).
Below: Summary - Installation - Configuration - Usage - Error alerts - Notes - Contact
Also: TemplateNotes - Other templates & scripts
Changes from 0.99a to 1.01. A new script is included, "alpha-numbered," which sorts and numbers the bibliography alphabetically and uses those numbers for in-text citations. A property, italicCitations, was added to the numbered and alpha-numbered scripts that allows full-sized in-text numbered citations to be styled as italic. In-text citations may now include an internal notation that suppresses enclosure with delimiters or superscripting for that citation. Users may insert an XML tag into Pages documents that allows setting script properties on-the-fly. Scripts now check for the presence of the specified bibliography template file at the start of the run and warn if it is not found. Versioning and author information is included in templates using InfoKey tags. The text citation script has been modified to accommodate a new Applescript or Pages bug. Version 1.01 fixes a bug in the v. 1.0 processing sequence to allow a template file name to be passed in from a CiteInPages XML tag.
- OldCIPReleaseNotes -
BibDesk is an excellent open source BibTeX reference database manager that was designed to work with LaTeX/BibTeX publishing systems. However, it is also a capable general-purpose reference manager with very good import/export capabilities, and a flexible templating system that allows citations in defined formats to be dragged from BibDesk into text editing programs and for bibliography lists to be generated in defined formats. BibDesk is also Applescriptable, with an Applescript menu from which scripts can be chosen to run.
Pages is a word processor from Apple with a number of nice features, including page layout capabilities, ability to read and export Word documents and, in version 3, Word-compatible change tracking and commenting. Some find it a more comfortable editing environment than Word. However, reference managers don't work smoothly with Pages; you generally must save as RTF and then process inserted citations, which is unwieldy and may cause the loss of some content or layout. This limits the usefulness of the program for academic writing.
The CiteInPages scripts are designed to be placed in BibDesk's Applescript menu. When selected from the menu, the bibliography scripts duplicate the frontmost open Pages document, scan through the duplicate and replace "working citations" containing BibDesk cite keys with numbered or author-date citations in the text, assemble the cite keys into a correctly-ordered list, extract a corresponding formatted bibliography from the frontmost open BibDesk database using a specified BibDesk template, and insert that bibliography into the duplicate document at the end or in another specified location (the original document is unchanged). All document processing is handled within Pages and thus the scripts allow replacing citations and inserting bibliographies into Pages documents without the problems associated with converting the documents to other file formats. CiteInPages supports sequentially-numbered, alphabetically-numbered and author-date citation styles in three separate scripts. A script is also provided to insert selected citations to references in BibDesk at the insertion point in Pages. The ReplaceCite script from the Scripts page of the BibDesk Wiki was used as a starting point for CiteInPages, and the scripts may still contain a few lines of that code.
Two bibliography template files are supplied with CiteInPages. By default, the "numbered" script uses a template based on the AMA style (a modified Vancouver) and the "alpha-numbered" and "author-date" scripts use a template based on the APA style. Both templates provide layout for articles, books, in-books, in-proceedings, conference presentations, tech reports, electronic references, web pages and generic layout for other types of references. Templates can be edited, new templates can be created and in-text citations can be adjusted to support other bibliographic styles.
The download (above) contains the CiteInPages Applescripts, the working citation template that I use, and two styled bibliography templates to help start things off. Step-by-step installation instructions are included as a readme text file in the download. In summary, the CiteInPages scripts (CiteInPages numbered.scpt, CiteInPages alpha-numbered.scpt, CiteInPages author-date.scpt and CiteInPages text citation.scpt) should be placed in BibDesk's Scripts folder:
~/Library/Application Support/BibDesk/Scripts
The template files (inTextCitationTag.txt, CIP-AMAstyle.rtf and CIP-APAstyle.rtf) should be placed in BibDesk's Templates folder:
~/Library/Application Support/BibDesk/Templates
The scripts can be renamed. The templates should not be renamed unless corresponding changes are made in the template properties at the top of each script (see Configuration below). Scripts can also be re-directed to use other templates by changing the template properties in the scripts as described in Configuration below.
After copying the files into the appropriate folders, references can be selected in BibDesk and copied to the insertion point or selection in Pages documents by choosing "CiteInPages text citation" from BibDesk's scripts menu. Users who wish to drag-and-drop formatted in-text working citations from BibDesk to Pages will also need to add the in-text citation template file (inTextCitationTag.txt) as a text export template in BibDesk's Templates preference pane, and set the Default Format popup menu under "Copying and Dragging" in BibDesk's Citations preference pane to "Template" and the Template popup menu just below to the name of the new template (see BibDesk's help file or the link above for specific instructions about adding and selecting templates). Step-by-step instructions for installing this file as a template in BibDesk are provided in the readme file included in the download.
CiteInPages is distributed with default values that should allow it to operate in English language installations without additional configuration, if the supplied scripts and templates are installed according to the included directions. For those wishing additional flexibility, the following sections explain how template files can be edited by users, and how the properties at the top of the scripts can be edited by the user to target the scripts to other templates or control other aspects of formatting and document processing.
The citation template specified in the file inTextCitationTag.txt defines the content and delimiters of the in-text "working citations" that are pasted into Pages when a reference is inserted by script or dragged from BibDesk (both the author-date and numbered scripts can use the same working citation template). Although the built-in TeX citation command that is the default drag format from BibDesk can also be used for in-text citations, there are several drawbacks to this (see notes below). The citation template file inTextCitationTag.txt contains:
[* <$publications.citeKey.@componentsJoinedByComma/> *]
This string uses "square bracket - asterisk - space" for the leading working citation delimiter and the reverse for the trailing delimiter. There is a space before the first character so that a space will be inserted when citations are dropped directly behind a text character. If other delimiters are desired, this file can be edited in a text editor to replace the default delimiters: be sure to save as plain text and change the script properties tagStart and tagEnd to match the starting and ending delimiters in each script that will process in-text citations inserted with this template. Delimiters must be unique strings dedicated to marking citations but need not be the reverse of each other. Start and end delimiters for working citations must be different from each other and must be different from those for final formatted citations. The command in the angle brackets inside the delimiters specifies a list of one or more BibDesk cite keys separated by commas. It should not be changed because the scripts assume this format for working citations. The format of the final citations is not controlled by this template; final citations are coded into the scripts and can be varied using script properties (see below).
The format of the bibliography lists created by the numbered and author-date scripts are specified in the bibliography template files CIP-AMAstyle.rtf and CIP-APAstyle.rtf. These files provide a reasonable starting implementation of the AMA style (a modified Vancouver style widely used in biomedical science) and the APA style, respectively. As is, they provide specific templates for journal articles, books, book sections (inbook), proceedings papers, conference presentations, technical reports, electronic documents and Web pages, with a generic template for other types of references. Some notes about these templates are available at TemplateNotes.
The template files can be edited in an rtf editor such as TextEdit to add additional specific templates, modify existing templates or change text styles. The bibliography template files specify only the format of the bibliography list; as noted above, the format of the in-text citations is controlled by properties in the scripts (see script properties, below). In each CiteInPages script, the BibliographyTemplateName property contains the name of the file that is used by the script as a bibliography template; the numbered script is set to the AMA template file and the author-date script is set to the APA template file by default. To use another template file, place it in BibDesk's Templates folder and set the BibliographyTemplateName property of each script that should use that template to the name of the file.
Many people may ultimately want more template files (i.e., for multiple journals with different formatting requirements). To accommodate this, multiple bibliography template files with different names can be placed in the Templates folder, the CiteInPages scripts may be duplicated and their properties edited individually to use desired settings and templates, and the scripts can be renamed appropriately so that formatting alternatives are easily available and distinguishable in the BibDesk scripts menu. More information on creating export templates is available in BibDesk's help file and in the BibDesk Wiki.
A number of properties (described below) are specified at the top of each script so that they may be edited easily, if desired, to adjust in-text citation styles, replace templates or accommodate non-English settings. To edit a property, double-click a script to open it in the Script Editor, change the text string that is assigned to the property (the text after the colon) and save. If quotes are present, be sure not to remove them. Script properties can also be modified on-the-fly using a special XML tag inserted into the Pages document (see Usage, below). Editing script properties is optional. Both scripts for numbered in-text citations have the same list of properties; the author-date script shares some of these properties and also has some unique properties. If a property is defined only in the numbered or author-date scripts, that is noted after the property name.
tagStart: Specifies the initial delimiter string that will be recognized as starting an in-text "working citation" that will be replaced by CiteInPages. This must match the initial delimiter specified in the citation template (see above) and should be unique to citations within the document. The default is square bracket - asterisk - space. If you're interested in using TeX commands for citations (of the form \cite{citeKeyList}), see note #13 below.
tagEnd: Specifies the trailing delimiter string ending in-text "working citations." As above, this must match the trailing delimiter specified in the citation template (see above), it should also be unique to citations within the document and it doesn't need to be similar to tagStart (though most people will probably want symmetrical start and end delimiters for visual reasons). The default is space - asterisk - square bracket.
CitationStartChar: Specifies the character or string that will be the leading delimiter for the in-text citation number(s) after replacement of the working citation. It should be different from tagStart. The default is a square bracket.
CitationEndChar: Specifies the character or string that will be the trailing delimiter for in-text citation number(s) after replacement. It should be different from tagEnd. The default is a square bracket.
superscriptCitations (numbered only): Default false. Set to true to superscript the in-text citations. Normally, you would also set CitationStartChar and CitationEndChar to "" (the empty string) when you're using superscripts. The AMA style usually uses superscript in-text citations, but for the moment CiteInPages numbered ships with full-size in-text citations because confirming their accuracy seems easier. Switching to superscripts when needed is simple.
italicCitations (numbered only): Default false. If true, full-sized numbered citations in text (including delimiters) will be italicized. Superscript in-text citations are not affected.
inCitationSeparator (author-date only): Default comma-space. This defines the character(s) that will separate author names from year in the in-text citations
betweenCitationSeparator (author-date only): Default semicolon-space. This defines the character(s) that will separate citations from each other when several citations are included together within parentheses.
initialsLast (author-date only): Default false. This determines whether initials will precede (the default) or follow the first authors name in in-text citations when references have similar last author names and years, but the author initials differ.
initialPunctuation (author-date only): Default true. This determines whether in-text citations that include first author initials will use punctuation with the initials. With punctuation, the initials are followed by periods and separated by a space, and if initials follow the last name there is a comma after the last name. Without punctuation, periods, spaces between the initials, and commas if the initials follow the last name are suppressed.
maxTagLength: If an in-text citation is longer than this, CiteInPages will identify it as an error (this can catch tags with missing or malformed trailing delimiters). The default is 700 characters, but it can be changed as desired.
BibliographyTemplateName: Contains the name of the template file that will be used to format the bibliography list. As of BibDesk version 1.3.13, a file name rather than a template name may be specified here, which avoids the need to install a template in BibDesk's preferences. By default, the value of the template name is "plainTemplateNonNumbered.txt" so if the supplied bibliography template file is to be used, and is copied to BibDesk's Template folder as directed above, no further configuration is necessary.
useNumberedListStyle (numbered only): If set to "true" (no quotes needed), CiteInPages will set the span of the bibliography to the Numbered List style in Pages, so that Pages will number the bibliography list. In this case, the BibDesk template should not itself number the references. If having BibDesk number the references is preferred (i.e., a special numbering style such as numbers in square brackets is required), this property can be set to "false" and numbering and leading tabs can be specified in the BibDesk template. Note that the author-date script should not use a template that specifies numbering. By default, this property is "true" and the supplied bibliography template does not include numbering. Either way is fine; if the latter is used, a final simple adjustment of the Pages ruler will be required to get nice hanging indents.
listStyleName (numbered only): This property specifies the Pages list style that will be applied to the bibliography if useNumberedListStyle is true. It is set to "Numbered list" by default, which is a default list style in English installations of Pages. With other languages, or if a special numbering style is defined, this value can be set to another style name. Note that special numbering styles, such as square-bracketed numbers, can be created within Pages. If a special Pages list style is used, this property should be set to its name, which should be visible in the list styles popup at the right of the format bar in Pages.
insertString: By default, CiteInPages appends the bibliography at the end of the Pages document. If desired, the bibliography can be inserted anywhere else in the document by placing a special unique string (specified by insertString) in the document that is replaced by the bibliography after the whole document has been processed. This can be useful when the bibliography should be inserted prior to figure legend and table pages. The default value of the insertString is "insert bibliography here" enclosed in angle brackets, but this can be edited to any value desired. CiteInPages can also insert multiple independent bibliographies per document (see note #15).
hangingIndent (author-date only): Allows the user to set a hanging indent width for author-date bibliographies. Default is 0.25 (assumes an inch-based ruler); adjust as desired or for other metrics.
bibSpacing: Extra vertical spacing in points between individual entries in the bibliography. Default 6 points.
matchDocumentFontAndSize: Determines whether bibliography lists will acquire the font and font size of the point at which they are inserted in a document, or whether they will retain the font and font size specified in the rtf template. Default is true (font and size will match the document). Other styles such as bold, italic, underlining, etc., are always as specified in the template.
Temporary "working citations" containing cite keys are dragged from BibDesk into a Pages document, or are selected in BibDesk and placed at the insertion point in Pages using the included text citation script. The working citations represent the bibliographic references while the document is being written and edited. Cite keys are (typically) unique representations for references in a BibTeX library file. They may be generated in several ways and are usually recognizable combinations of author name, year, and possibly other information about a reference. When editing is complete, the CiteInPages numbered or author-date script is run from BibDesk to duplicate the Pages document, replace the cite key citations in the duplicate with numbered or author-date citations, and insert or append a formatted bibliography to the duplicate file. Note that if a cite key is not unique, CiteInKeys will replace it with the first reference with that cite key, so generating or confirming unique cite keys before insertion into documents is a good idea.
Adding working citations to a Pages document. Just set the insertion point in the Pages document where the citation should be inserted, select one or more citations from a BibDesk reference list and choose the text citation script from BibDesk's script menu. Alternatively, if the citation template has been specified as the export template for dragging, citations can be dragged directly from BibDesk to the desired point in a Pages document. Working citations should drop into Pages as comma-delimited cite keys inside the citation delimiters specified in the citation template. All citations in one Pages document should be from a single BibDesk library; it's easy to drag references between BibDesk libraries, if needed, to get them all together. Citations in Pages can be edited just like any text, but be careful not to change the delimiters and to make sure that the contents of the citation remains a comma-separated list of valid cite keys for one library file.
The text citation script in BibDesk works well with Spaces in OSX 10.5. Pages can be set up on one screen and BibDesk on a second screen. To insert a citation, just place the insertion point as desired in Pages, click BibDesk on the dock to move to BibDesk's screen, select the desired reference(s) and choose the in-text citation script, and the screen will flip back to Pages with the citations inserted.
Suppressing delimiters or superscripting for specific citations. If "d" or "s" is placed at the start of an in-text working citation, inside the initial delimiter and separated from the first cite key by a space, delimiters or superscripting will not be placed on that citation in the output file. The recommended syntax is "-d", "-s", or "-ds":
[* harrison:2007 *] --> [3] [* -d harrison:2007 *] --> 3
Setting script properties on-the-fly for a particular file. For convenience, any script properties (Editable Script Properties, above) can be set for a particular file by including a CiteInPages XML tag that specifies new values for the properties somewhere in the Pages document. The tag should be in its own paragraph, which will be deleted in the output document, and can be located anywhere in the document. Capitalization of property names is not significant, and quotation marks can be "curly" or straight. The script will show the properties that are being changed and their new values in a dialog, with the option to continue or cancel the script. If a property that is not in the script is referenced, a dialog with that property name and a message requesting a correction will appear and the script will terminate. The tag should be of the form:
Replacing working citations and generating the bibliography. Just open the Pages file you wish to process, make sure it's the frontmost Pages file and that change tracking is turned off (see Note #7 below), open the BibDesk library that you wish to use and make sure it's the frontmost library in BibDesk, and choose the desired CiteInPages script from BibDesk's scripts menu. The Pages file is saved (in case unsaved changes are present) and duplicated to a file with "-bib" appended to its name in the same location as the initial file. The initial file remains open underneath, but is not touched by the script. With the author-date script a colored text box appears in the new Pages document and provides feedback about the progress of the script; the numbered script does not use the feedback box because it starts inserting citations almost immediately. The document is scrolled as in-text working citations replaced by numbered or author-date citations, and the formatted bibliography is appended to the Pages document (by default) or can be inserted anywhere else in place of the defined insertString (see Configuration, above). Finally, some feedback is provided in a dialog box before the script exits and the document is scrolled to the start of the bibliography. Author-date bibliography entries that have the same authors and years will have a note appended to them indicating the letter that the user should append to the year of that entry to distinguish it (for example "a" or "b"). The corresponding letters have already been appended to the in-text citations (see Note #4 below for more detail).
Cheers!
Jim Harrison
University of Virginia
james-dot-harrison-at-virginia-dot-edu
| subtopics: |
Source: jhh Wikis URL: http://jhh.med.virginia.edu/main/CiteInPages