Skip to content

Latest commit

 

History

History
 
 

word-citation-management

page_type urlFragment products languages extensions description
sample
word-citation-management
office-word
office
javascript
contentType technologies createdDate
samples
Add-ins
11/28/2023 4:00:00 PM
Shows how to manage citations in a Word document.

Manage citations in a Word document

Summary

This sample shows how to manage citations in Word with an add-in. The add-in uses the insertEndnote API to list inserted citations at the end of the document.

Description

The user updates their Word document to include their citations and quotations. The user selects their bibliography file (.bib) through the add-in UI. The add-in lists the references found in the .bib file. The user selects the text in the document to cite then picks the option from the reference list displayed in the add-in UI. The inserted citations are listed at the end of the document.

The sample uses the @orcid/bibtexParseJs JavaScript library to parse the .bib file.

Citation management add-in task pane.

Applies to

  • Word on Windows
  • Word on Mac
  • Word on the web

Prerequisites

  • Office connected to a Microsoft 365 subscription (including Office on the web).
  • Node.js version 16 or greater.
  • npm version 8 or greater.

Solution

Solution Authors
How to manage citations in a Word document Microsoft

Version history

Version Date Comments
1.0 11-28-2023 Initial release

Run the sample

  1. Clone or download this repo.

  2. Go to the Samples\word-citation-management folder via the command line.

  3. Run npm install.

  4. Run npm run build.

  5. Start the local web server and sideload your add-in.

    • To test your add-in in Word, run the following command in the root directory of your project. This starts the local web server (if it's not already running) and opens Word with your add-in loaded.

      • Windows: npm start
      • Mac: npm run dev-server
    • To test your add-in in Word on the web, follow the instructions in Sideload a Yeoman-created add-in to Office on the web.

  6. If the add-in task pane isn't already open in Word, go to the Home tab and choose the Show Taskpane button in the ribbon to open it.

Try it out

  1. In the "Bibliography sources" section of the add-in UI, select the Choose File button. Navigate to the local location of your .bib file then open the file.

    The initial screen displaying the button to choose a file.

    For convenience, the resources folder of this project includes a sample.bib file.

    Screen showing selected file.

  2. In the document, select the text that you cited or quoted, or place the cursor.

    Screen showing text selected in the Word document.

  3. In the list of references in the "References" section of the add-in UI, search for and select the reference you want to insert then select the Insert citation button. To unselect the selected radio button, choose the Clear selection button.

    Screen showing selected reference option.

  4. In the document, the reference mark appears at the end of the selected text and an endnote with the reference information is displayed at the end of the document.

    Screen showing citation inserted in the Word document.

Make it yours

The following are a few suggestions for how you could tailor this to your scenario.

  • Include single sign-on (SSO) to support managing sessions and persisting settings for the user.
  • Update the citation style used to display the references in the endnotes, or allow the user to choose the style.
  • Use footnotes instead of endnotes, or allow the user to choose.

Related content

Questions and feedback

  • Did you experience any problems with the sample? Create an issue and we'll help you out.
  • We'd love to get your feedback about this sample. Go to our Office samples survey to give feedback and suggest improvements.
  • For general questions about developing Office Add-ins, go to Microsoft Q&A using the office-js-dev tag.

Copyright

Copyright (c) 2023 Microsoft Corporation. All rights reserved.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.