Making Citations Clickable Hyperlinks

If I'm using Zotero to write articles, research papers, etc., that are published electronically (e.g., online), is there any way to make the citations (in the body of the text) clickable so that the reader is taken to the abstract, full study, etc.?

For example, let's take the following excerpt about supplementation with oral glutathione:

"Setria (oral) glutathione has been shown to increase blood levels of glutathione. (1) Sublingual glutathione has also been shown blood levels of glutathione. (2) However, is there any head-to-head comparative data?"

In this example, I'd like to hyperlink citation 1 to this study: https://www.ncbi.nlm.nih.gov/pubmed/24791752

And I'd like to hyperlink citation 2 to this study: https://www.ncbi.nlm.nih.gov/pubmed/26262996

Is there any way to do this automatically through Zotero? Or, is this something that needs to be done manually (e.g., after writing, unlink citations, then manually add hyperlinks)?

Thank you very much for your time and help!
  • This can’t be done automatically by Zotero, but you could use a Word macro to replace the contents of the underlying Zotero Field Codes with hyperlink information.

    There are also several methods discussed in various places on these forums to link the numeric citations to the bibliography entry, and you can include the DOI or URL there and use Word AutoFormat to make them clickable links.
  • Hi bwiernik,

    Thanks so much for taking the time to provide such a thoughtful reply. I should have noted that I did attempt to do my due diligence in searching these forums before posting my question. I know it's a cardinal sin not to do so :)

    I don't know much about using Word macros, so I'll need to look into that.

    In another thread here on the forums, I think I saw someone mention that the Zotero plug-in for WordPress may have the capability to do what I'm looking for. The articles I'm writing are published in WordPress -- although that's done by someone else in my organization -- so maybe that's something for me to consider as well.

    Thank you very much for your time and help!
  • WordPress is a website platform. Are you sure that’s what you mean?
  • I think that this is definitely something that Zotero should be able to do and is a much needed update. The whole point of using a citation manager is to avoid having to by hand implement each citation, and asking users to hack together code for msword is not a good solution either, even if it is possible. Unless I'm missing something, this is easily implemented by Zotero (for example by linking each citation to it's DOI URL), and should be an option in their msword add-on. Please add this ASAP! Ideally, the user could select between no links, links to bibliography, or direct links to DOI URLs.
  • @tskwiat could you please share one of the attempts that you consider easier to implement?
  • For reference, the way I'm usually seeing it implemented in collaborative documents without proper library tool is to create a bibliography manually and use textual references to the identifier listed in the bibliography.

    In Word this would be done with bookmark references.
  • It is possible to do this for author-date citations (at least in libreoffice - see crude python code below). When it comes to numbered references, I cannot see any sensible way to deal with grouped numbers such as 5-10. There is no place to put the links.
    Feel free to improve the code.


    import uno
    from ast import literal_eval as to_dict
    document = XSCRIPTCONTEXT.getDocument()

    #alter this for citations divided by comma
    ns = ";"

    def copylinks():
    oSearch = document.createSearchDescriptor()
    oSearch.SearchRegularExpression = True
    oCurs = document.getText().createTextCursor()
    refmarks = document.ReferenceMarks
    for refmark in refmarks:
    a = refmark.Name
    b, _ = a.rsplit(" ", 1)
    _,_, c = b.split(" ", 2)
    d = to_dict(c)
    cite = d["properties"]["formattedCitation"]
    plain_cite = d["properties"]["plainCitation"]
    plain_cite = plain_cite.replace("(", "")
    plain_cite = plain_cite.replace(")", "")
    #alter this for citations divided by comma
    names = list(plain_cite.split(ns))

    if "citationItems" in d.keys():
    list_e = d["citationItems"]
    else:
    continue

    for g in list_e:

    if "itemData" in g.keys():
    h = g["itemData"]
    authors = h["author"]
    m = authors[0]
    author = m["family"]
    citatation = list(filter(lambda x: author in x,names))
    oCurs = refmark.getAnchor()
    oCursor = oCurs.getStart()
    oSearch.SearchString = citatation[0]
    oFound = document.findNext(oCursor, oSearch)
    oCursor2 = oFound.Text.createTextCursorByRange(oFound)

    if "DOI" in h.keys():
    DOI = h["DOI"]
    else:
    DOI = ""
    if "source" in h.keys():
    source = h["source"]
    else:
    source = ""
    if "note" in h.keys():
    note = h["note"]
    else:
    note = ""
    else:
    continue
    if DOI:
    oCursor2.HyperLinkURL = "https://doi.org/" + DOI
    aaa = oCursor2.HyperLinkURL
    elif source == "PubMed":
    _, n = note.split(": ")
    oCursor2.HyperLinkURL = "https://pubmed.ncbi.nlm.nih.gov/" + n
    else:
    pass
  • Dear community,

    I found this answer in another place and I just apply a small Word macro that automatically turns numeric Zotero citations like [1] into clickable links that jump to the corresponding entry in the bibliography.

    Instructions:

    - Finish your document using Zotero (add/remove citations, finalize style, etc.).

    - [optional, but recommended] Save a backup copy of your file.

    - In Word, go to the Zotero tab and click Unlink Citations (this converts all citations and the bibliography to plain text).

    Press Alt + F11 to open the VBA editor.

    Go to Insert → Module and paste the macro below into the new module.
    """
    Option Explicit

    Sub MakeZoteroNumericCitationsClickable()
    Dim doc As Document
    Dim i As Long
    Dim blockStart As Long, blockEnd As Long
    Dim lastBlockStart As Long, lastBlockEnd As Long
    Dim p As Paragraph
    Dim listType As WdListType
    Dim bibStartPos As Long
    Dim num As Long, maxNum As Long
    Dim rngSearch As Range
    Dim findRange As Range
    Dim n As Long

    Set doc = ActiveDocument

    ' 1) Find the LAST numbered list block (assumed bibliography)
    blockStart = 0
    blockEnd = 0
    lastBlockStart = 0
    lastBlockEnd = 0

    For i = 1 To doc.Paragraphs.Count
    Set p = doc.Paragraphs(i)
    listType = p.Range.ListFormat.ListType

    If listType <> wdListNoNumbering Then
    If blockStart = 0 Then blockStart = i
    blockEnd = i
    Else
    If blockStart <> 0 Then
    lastBlockStart = blockStart
    lastBlockEnd = blockEnd
    blockStart = 0
    blockEnd = 0
    End If
    End If
    Next i

    ' If document ends inside a list
    If blockStart <> 0 Then
    lastBlockStart = blockStart
    lastBlockEnd = blockEnd
    End If

    If lastBlockStart = 0 Then
    MsgBox "No numbered list (bibliography) was found.", vbExclamation
    Exit Sub
    End If

    bibStartPos = doc.Paragraphs(lastBlockStart).Range.Start

    ' 2) Create bookmarks ref1, ref2, ... in the bibliography
    maxNum = 0
    On Error Resume Next
    For i = lastBlockStart To lastBlockEnd
    Set p = doc.Paragraphs(i)
    num = p.Range.ListFormat.ListValue
    If num > maxNum Then maxNum = num

    doc.Bookmarks.Add Name:="ref" & CStr(num), Range:=p.Range
    Next i
    On Error GoTo 0

    If maxNum = 0 Then
    MsgBox "No list numbers were detected in the bibliography.", vbExclamation
    Exit Sub
    End If

    ' 3) Find [n] in the main text and turn them into hyperlinks
    Set rngSearch = doc.Range(0, bibStartPos - 1)

    For n = 1 To maxNum
    Set findRange = rngSearch.Duplicate

    With findRange.Find
    .ClearFormatting
    .Text = "[" & CStr(n) & "]"
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False

    Do While .Execute
    doc.Hyperlinks.Add Anchor:=findRange.Duplicate, _
    SubAddress:="ref" & CStr(n), _
    TextToDisplay:="[" & CStr(n) & "]"
    findRange.Collapse wdCollapseEnd
    Loop
    End With
    Next n

    MsgBox "Numeric citations linked to bibliography.", vbInformation
    End Sub

    """

    Close the VBA editor.

    Press Alt + F8, select MakeZoteroNumericCitationsClickable, and click Run.

    The macro assumes:

    You are using numeric citations like [1], [2], …

    Your bibliography is the last numbered list in the document.


    Now, clicking on any [n] in the text will jump directly to reference n in the bibliography.
    (If you have a long document, Word may lag a little bit while the macro runs, just wait.)
  • edited 16 days ago
Sign In or Register to comment.