Style with coloured in-text citations

Hey guys,

I've been looking all over for this but seems like it all comes down to my lack of knowledge of HTML code.

All I want is to edit the Elsevier style so that my in-text citations show up in colour (so as to better discriminate them when quickly reading through my thesis).

Where in the .cls can I edit this? I tried to understand the syntax, but I'm kinda lost. (Say for example that I'd like "color:#8A4B08")

Thanks for your help!

Damnation
  • You can't. CSL supports a very limited subset of html (italics, bold, small caps, underline, superscript, subscripts).
    You're aware that Word allows you to highlight fields (and all Zotero citations are fields): https://wordribbon.tips.net/T006107_Controlling_Field_Shading ?
  • Thanks adamsmith.

    Seems crazy though, for such a simple edit to be impossible.

    I find the option of highlighting the fields using Word to be very ugly, and it only lets you highlight in grey. Eww.

    Thanks for your fast feedback. I guess I'm only left wit the option of changing the colour of my citations one by one.
  • You could write a Word macro that changes the font color or applies highlighting on all citations if you really want to -- one concern would be updating citations. I'm pretty sure Zotero will balk at that since you've manually edited them.

    It's honestly not at all a common request and it's very much not simple, since CSL is output agnostic, which means this would need to be translated into and implemented in different formats, not just html.
  • Could this somehow be implemented with an add-on and something placed in the Zotero extra field? It would certainly require changes to the style used. Could a style call a Word macro? The style could be changed to the more standard version just before the final document version and the removal of field codes.

    There is one more complication that would make it nearly impossible to implement this automatically. How is Zotero to "itself know" the publisher of each journal? That would require an enormous journal/publisher look-up table. This table would need to be updated regularly as new journals are released and journals change publishers. I try to maintain such a table for my database of ~16,000 journals and doing so requires significant effort. The total number of journals in the world is several orders of magnitude greater than what I work with.

    As someone who personally is very interested in journals and publishers, authoring, and information-seeking behavior; I'm quite curious about how it might benefit you to keep track of the publisher of the cited items in your thesis. Please explain your thinking behind this interesting request. E-mail me directly (click on my username above) if your explanation requires more than a sentence or two.

  • DWL -- I think you're misreading the request. It's much simpler than what you seem to be thinking about. They just want every Zotero citation in color. "Elsevier" is the citation style they use, not a subset of citations to highlight.

    Which is why a simple Macro would be all that's needed (and no, a citation style cannot call a macro, but a macro can read metadata embedded in the document).
  • I'm sorry. I see now that I was overthinking.
  • @adamsmith: I disagree that this is not a common request. I myself (and others) have asked similar questions on the forum, that all boil down to the ability to change the formatting of *all* in-text citations at once. The simplest way to do that would be to have a dedicated Word style for in-text citations, that one can edit.

    In addition to this feature not being yet available, the formatting of in-text citations is also quite buggy (at least in the current version of Zotero, in Word 2016): my citations often appear with random font-faces&-sizes, that appear to reflect how my Normal style was a while ago. Zotero doesn't follow the current settings in the Normal style (not even after nudging it by switching back and forth between a few styles, or after using the Refresh button in the Zotero add-in for Word).

    I love Zotero but it would be great if future versions fixed these bugs with the in-text citations, and also possibly implement this very-commonly-requested-indeed ( ;-) ) feature about the dedicated style.
  • well, I was referring to the specific request of having citations appear in color, not the generalized case you're pointing to.
    Given what I know about how Word styles interact with inserted RTF (which is what Zotero does), I'm actually not sure applying a different style to in-text citations is even possible -- I think Word will just apply any style to the whole paragraph.
  • OK, I see. Well, in that case I'll just share the workaround I found, for anyone who might be struggling:
    - Ctrl+H, the Find tab
    - from Replace|Format|Font, specify the font that Zotero mistakenly applies to the in-text citatiions
    - Find In -> Main Document
    - manually change the font to the main one in your doc (Normal-style-based)
  • Just my 2 cents. Citation coloring is extremely common in Latex-produced working papers and I can attest to the fact that it facilitates parsing through the information considerably. It's a pity this cannot be implemented in Zotero/Word. Perhaps a Z-related style in Word would be a convenient if feasible addition.
  • I have found a solution to this problem in case someone else is interested. I am assuming you are using Mac OS. If you are using Windows just try and find a way to display field codes. So, In mac:
    -Go to Word->Preferences->View and check "Field codes instead of values" (close that window)
    -Press Ctrl+H (in word)
    -In the replace button type the following without the brackets (^19 ADDIN) you can copy paste what's in the bracket from here anyways
    -The next explanation is where the trick lies.
    -There is a small "setting" button just besides the Find button with a drop down, Click it and choose Advanced Find and Replace
    -In the dialogue box that appears, Select Main Document in the button box written "Highlight all items found in"
    -Under the Search option select ALL
    -Click Replace button and ENSURE THAT YOU CLICK THE EMPTY TEXT AREA where it is written Replace with: (Do not type anything here!!! Just click it to select it)
    -At the bottom where it is written Replace, Select Format
    -Then Select Style
    -Scroll down to your favorite style (You should have decided before or at least modified the settings of the style you are choosing at this stage before starting all this procedure anyways)
    -Choose it and click ok (Do not forget to click OK)
    -Then while still under replace,
    -(Just to be sure) Click the empty space where it is written Replace with:
    - Click Replace all.
    -Word SHOULD alert you that it has made some changes. If not Repeat the procedure above carefully!!
    -Close the window and undo the field codes. This should give you what you want
  • @rogo101 It worked!!! Thank you very much for sharing the whole procedure. It saved me a lot of time!!!
  • @Adenora My Pleasure. In case word mess up your citation style (for example IEEE to something else). Just choose another one and select the one you had again, it will work.
  • Great, it works in Windows too. If you can change the colour of citation in text only, then use (^19 ADDIN ZOTERO_ITEM) instead of (^19 ADDIN). Respectively for changes only list of literature use (^19 ADDIN ZOTERO_BIBL )
  • I don't know if it is applicable to you, but for me using Word 2019, I found the following info and made my in-text citation grey (better than nothing):


    "By default, Zotero stores the reference data for citations and the bibliography in Fields (Word) or Reference Marks (LibreOffice), which stores items' reference data hidden behind the formatted text.

    Word and LibreOffice will highlight Fields/Reference Marks on your screen to indicate that the text is automatically generated. This can help you avoid accidentally manually typing in the fields (to edit the text shown in a Zotero citation, see Customizing Cites). These highlights are only shown on screen and won't appear if you print or save the document as a PDF.

    You can change the settings for highlighting Fields/Reference Marks in your word processor:

    Word for Windows: In Word Options, open “Advanced”, then set “Field shading” to “Never”, “Always”, or “When selected”.
    Word for Mac: Open Word → Preferences → View and set “Field shading” to “Never”, “Always”, or “When selected”.
    LibreOffice: Open Tools → Options → LibreOffice → Application Colors and check/uncheck the “Field shadings” box. You can also control the color used for field shadings."

    https://www.zotero.org/support/kb/citations_highlighted
  • I can confirm @rogo101 's solution works in Word 365 (office apps for enterprise version) on Windows 10. It took me some time to get that the option to pick all instances and highlight them is under Find and not under Replace, and that it is called in my version "Reading Highlight". I then switched back to Replace and applied (Replaced-All with) a custom Character-type style in Word that is based on the background paragraph style ("based on Underlying Properties"). In my case it's just a style that turns a character to superscript+purple. I do not know how to edit CSL entries to do any or both of these
  • Can you makle a tutorial? @rogo101
  • Hello, I'm chiming in from 2023 just to put my vote in for the desire to highlight, color, or otherwise style in-text citations. This ability does have some benefits to me, for example, if I'm co-writing with someone who refuses to use a citation manager, and their in-text citations are entered manually. I've read this thread and I recognize that highlighting of field codes can be done in Word, and I've done so (also I haven't delved into the more complicated instructions here, but I'm glad they are available so that I can look into it later).

    However...I do want to add an additional complication :-). I'm stuck working on a paper with a collaborator who will only use Google Docs. I'm very glad that the Zotero addon enables citation management within Google Docs, but as far as I can tell, there is no option at all for highlighting field codes or similar for Google Docs. Maybe my searching skills aren't what they once were, but generally I find its documentation/support to be dreadfully sparse compared to the decades of documentation for MS Word. I do realize this is a niche request, but if anyone has any ideas or suggestions, I'd be grateful.
Sign In or Register to comment.