Word: Possibility to link references and bibliography in a document?
After searching through the forums I couldn't find a related topic, so I'll create a new discussion. If anyone knows where to find the answer, feel free to point me there.
Actually, I wonder why this does not show up anywhere as I think it would be a rather important feature of the Zotero Word plugin.
My problem:
I'd like to have the in-text Zotero references in a Word document, e.g. [1] in IEEE style, to be linked and clickable (within the Word document) so that Word jumps to the appropriate entry in the bibliography (which was created by Zotero at the end of the document), e.g. [1] John Doe et al., "Title of the paper"...
I imagine it the same way you can click on an entry in the outline of a document and Word jumps to the linked section.
I would have expected that this behavior of references is already included in the Word plugin. Obviously, it isn't, at least not for me.
Moreover, this would be very helpful when exporting documents to PDF, as the links within a Word document can be included in the exported file, so that the PDF would contain the same links.
Thanks for your comments on this issue!
Actually, I wonder why this does not show up anywhere as I think it would be a rather important feature of the Zotero Word plugin.
My problem:
I'd like to have the in-text Zotero references in a Word document, e.g. [1] in IEEE style, to be linked and clickable (within the Word document) so that Word jumps to the appropriate entry in the bibliography (which was created by Zotero at the end of the document), e.g. [1] John Doe et al., "Title of the paper"...
I imagine it the same way you can click on an entry in the outline of a document and Word jumps to the linked section.
I would have expected that this behavior of references is already included in the Word plugin. Obviously, it isn't, at least not for me.
Moreover, this would be very helpful when exporting documents to PDF, as the links within a Word document can be included in the exported file, so that the PDF would contain the same links.
Thanks for your comments on this issue!
My understanding is that it's at least not trivial to do in the plugin.
The only workaround I've figured out so far, is to remove the Zotero code from the Word document, i.e. convert the Zotero references into plain text, then add (Word-)bookmarks to the bibliography and link every single reference in the text manually.
In practice, however, even for a few references, that's too tedious to do.
Does anyone know any better workarounds?
There's the problem to come back to the (AUTHOR 2010), in particular when there are multiple pages where the item is used, I don"t know how it could be done, but being able to go to end of document could be fine to start.
I know that this comment isn't very helpful but it showed that this 2-way linking is possible in a pdf document.
I think from the Zotero side, the question is if RTF even supports it. If it does this would likely be possible, if not, I'm not seeing how that'll happen.
I think two way linking (as described by DWL-SDCA) would also be possible in Word, with a bit of work. I don't think that it would be possible to transfer such pop-ups to a PDF document however. You can make all sorts of fancy things in PDFs using software like InDesign, but I'm pretty sure that Word's PDF generator will not support such elaborate features.
Edit: two other recent threads on this: [1] [2]
It's an important functionality for thesis, since usually there are lots of references there and it's useful to navigate them with hyperlinks. Looking forward to developers willing to contribute this feature! :D
@aurimas In my experience, one-way linking is possible in Word but it doesn't work reliably.Two-way linking is not (yet) possible. In my experience the MS Office pdf converter goes a bit crazy when 1) the document is long (pagination and page breaks can differ between the doc and pdf versions) and 2) any linking in the doc format doesn't transfer to pdf. I quit using MS Word for LO Writer primarily because the LO pdf converter was much more reliable.
I really think this should be a functionality in zotero, since many people, AFAIK, use it to write their thesis. Maybe not so important for individual papers, but definitely a must for bigger stuff.
edit: probably this thread shoouldn't be in the "plugins" section...?
One way linking in EndNote is possible though (from the citation in text to the bibliography) and it caries over to the exported PDF.
See here for an example
http://scholar.harvard.edu/files/msen/files/sen_ratings.pdf
It searches the Field for a number (either a year or a sequential number), selects it and then links it to the title that is in the zotero field. The zotero fields shouldn't get harmed. Multiple citations should work too.
Unfortunately, Superscript Styles are not supported yet, as selecting the number would result in the whole field to be replaced with the link. I don't know how one could change the resulting text of the field, because then one could add hidden text to it.
(Hidden Text could also be placed into or after the field for having a clickable "edit citation" button.)
Feedback or improvements are welcome! The code is in the public domain.
Public Sub ZoteroLinkCitation()
Dim nStart&, nEnd&
nStart = Selection.Start
nEnd = Selection.End
Application.ScreenUpdating = False
Dim title As String
Dim titleAnchor As String
Dim style As String
Dim fieldCode As String
Dim numOrYear As String
Dim pos&, n1&, n2&
For Each aField In ActiveDocument.Fields
' check if the field is a Zotero in-text reference
If InStr(aField.Code, "ADDIN ZOTERO_ITEM") > 0 Then
fieldCode = aField.Code
pos = 0
Do While InStr(fieldCode, """title"":""") > 0
n1 = InStr(fieldCode, """title"":""") + Len("""title"":""")
n2 = InStr(Mid(fieldCode, n1, Len(fieldCode) - n1), """,""") - 1 + n1
title = Mid(fieldCode, n1, n2 - n1)
titleAnchor = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(title, " ", "_"), "&", "_"), ":", "_"), ",", "_"), "-", "_"), ".", "_"), "(", "_"), ")", "_"), "?", "_"), "!", "_")
titleAnchor = Left(titleAnchor, 40)
Selection.GoTo What:=wdGoToBookmark, Name:="Literature"
Selection.Find.ClearFormatting
With Selection.Find
.Text = Left(title, 255)
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Paragraphs(1).Range.Select
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:=titleAnchor
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
aField.Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^#"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=pos
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
numOrYear = Selection.Range.Text & ""
pos = Len(numOrYear)
style = Selection.style
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="", SubAddress:=titleAnchor, ScreenTip:="", TextToDisplay:="" & numOrYear
aField.Select
Selection.style = style
'Selection.style = ActiveDocument.Styles("CitationFormating")
fieldCode = Mid(fieldCode, n2 + 1, Len(fieldCode) - n2 - 1)
Loop
End If
Next aField
ActiveDocument.Range(nStart, nEnd).Select
End Sub
and write your style there.'Selection.style = ActiveDocument.Styles("CitationFormating")
You can use it in combination with my other macro for styling the citations: http://forums.zotero.org/discussion/16540/exempt-zotero-fields-from-being-spellchecked-word-2010/#Comment_148244
Bookmark does not exists and debugging that, it happens on this line:
Selection.GoTo What:=wdGoToBookmark, Name:="Literature"
Any help is appreciated.
You can manually create a bookmark that selects the zoteto bibliography field and call it literatue. It should work then.
Ill soon update this so that it looks for the field itself.
My next plan is backreferencing with (1a) and (1b) in the text and a:pagenumber, b:pagenumber in the bibliography. I dont know yet how to handle this with author-date, but ill probably use roman numerals (as year+letter is already used as disambiguation.
Public Sub ZoteroLinkCitation()
Dim nStart&, nEnd&
nStart = Selection.Start
nEnd = Selection.End
Application.ScreenUpdating = False
Dim title As String
Dim titleAnchor As String
Dim style As String
Dim fieldCode As String
Dim numOrYear As String
Dim pos&, n1&, n2&
ActiveWindow.View.ShowFieldCodes = True
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^d ADDIN ZOTERO_BIBL"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Zotero_Bibliography"
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
ActiveWindow.View.ShowFieldCodes = False
For Each aField In ActiveDocument.Fields
' check if the field is a Zotero in-text reference
If InStr(aField.Code, "ADDIN ZOTERO_ITEM") > 0 Then
fieldCode = aField.Code
pos = 0
Do While InStr(fieldCode, """title"":""") > 0
n1 = InStr(fieldCode, """title"":""") + Len("""title"":""")
n2 = InStr(Mid(fieldCode, n1, Len(fieldCode) - n1), """,""") - 1 + n1
title = Mid(fieldCode, n1, n2 - n1)
titleAnchor = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(title, " ", "_"), "&", "_"), ":", "_"), ",", "_"), "-", "_"), ".", "_"), "(", "_"), ")", "_"), "?", "_"), "!", "_")
titleAnchor = Left(titleAnchor, 40)
Selection.GoTo What:=wdGoToBookmark, Name:="Zotero_Bibliography"
Selection.Find.ClearFormatting
With Selection.Find
.Text = Left(title, 255)
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Paragraphs(1).Range.Select
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:=titleAnchor
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
aField.Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^#"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=pos
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
numOrYear = Selection.Range.Text & ""
pos = Len(numOrYear)
style = Selection.style
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="", SubAddress:=titleAnchor, ScreenTip:="", TextToDisplay:="" & numOrYear
aField.Select
Selection.style = style
'Selection.style = ActiveDocument.Styles("CitationFormating")
fieldCode = Mid(fieldCode, n2 + 1, Len(fieldCode) - n2 - 1)
Loop
End If
Next aField
ActiveDocument.Range(nStart, nEnd).Select
End Sub
But I still have some problems by using this nice macro.
Some References were linked and some (the most of them :-( ) were not linked with the bibliography.
Another problem is given by runtime error 5828.
Line:
.Add Range:=Selection.Range, Name:=titleAnchor
Thank you very much indeed!
I have replaced
.Add Range:=Selection.Range, Name:=titleAnchor by
.Add Range:=Selection.Range, Name:="Zotero_Bibliography"
(line 67)
Now it works more convenient!
But one problem is already existing, only the first two items in a bracket were linked.
I am just new in that topic, I did not really understand what happens.
So thanks for your comments.