Using the institution name as a substitute author name

I recently learned the basics of customizing CSL styles. Is it possible to use the institution name (which is one of the available fields for a report in Zotero) as a substitute author name? The problem is that institution is not one of the available name variables.

Is there a workaround?

Thank you!
  • edited August 2, 2022
    You'll want to look at this. Zotero has different names for the CSL variables available.
    I'd guess institution is mapped to publisher in your case.

    https://aurimasv.github.io/z2csl/typeMap.xml

    Note however that you can also put the name of the body into the author field using single-field mode. Maybe that solved your issue without editing the style. It depends.
  • Thanks, that's interesting information. However, "publisher" is not a CSL name variable, and only name variables are displayed in the dropdown box in the CSL Visual Editor. Is there a way out?

    Yes, I've been managing this issue by pasting in the name of the institution into the author field, but I'm wondering if there's a way to directly use the Institution field in Zotero.
  • edited August 2, 2022
    Which item type are you talking about? Hard to help without knowing ;)

    And no, "Institution" will never be a name variable. But you can set a substitute with normal variables also.

    E.g. line 39 here: view-source:https://www.zotero.org/styles/advanced-pharmaceutical-bulletin?source=1

    It could be a variable or a macro like in this case.
  • Report item. CMoS 17th edition.

    I want to set a substitute author name in the bibliography to the institution name.
  • This is the basic structure of what you want:
    <names variable="author">
    <name text="and" name-as-sort-order="first"/>
    <label form="short" prefix=", "/>
    <substitute>
    <choose>
    <if type="report">
    <text variable="publisher"/>
    </if>
    <else>
    <names variable="editor"/>
    </else>
    </choose>
    </substitute>
    </names>
  • edited August 3, 2022
    Thanks for the suggestion, adamsmith. I modified my style file as follows:


    <macro name="contributors-short">
    <names variable="author">
    <name form="short" and="text" delimiter=", " initialize-with=". "/>
    <substitute>
    <choose>
    <if type="report">
    <text variable="publisher"/>
    </if>
    <else>
    <names variable="editor"/>
    </else>

    </choose>
    <text macro="substitute-title"/>
    <text macro="title"/>
    </substitute>
    </names>
    </macro>


    Unfortunately, it's not working. I tried it on an entry in Zotero that has "SBTi" in the Institution field. This is the bibliographic entry generated:

    “From Ambition to Impact: How Companies Are Cutting Emissions at Scale with Science-Based Targets.” 2020. SBTi. https://sciencebasedtargets.org/sbti-progress-report-2020.

    I want SBTi to be in front of the entry as the author.

    What could the problem be?

  • edited August 3, 2022
    <code>asdf</code> for code snippets, larger pieces via pastebin.com please.

    But if you get the title, then there is obviously a title substitute set before it can print out the institution. Either remove (not recommended) or change the order or build in a conditional somehow.
  • Thanks, damnation! Fixed it now.
  • That's the contributor-short macro, that's used in subsequent (or in-text, if you are using author -date) citations, not the big biography or the first footnote.
  • Thanks, adamsmith! It's working now for both citations and bibliographic entries. It look as though I've unwittingly killed two birds with one stone.

    This is magical! What should a newbie to CSL know (the prerequisites) to be able to write code snippets like this? Any suggestions regarding resources/tutorials/books would be helpful. I'm not a programmer, though I've dabbled with it in an amateurish way. I've begun watching your 6 May 2020 webinar, which should help.

    A big thank you to everyone who contributed to this thread.
  • I think that webinar together with a lot of trial & error are the best way to go.
    https://zoteromusings.wordpress.com/2013/10/28/writing-csl-features-and-best-practices/
    Has some best practices.
  • Right! I love your teaching approach in the webinar, starting with a skeleton and then dressing it up one step at a time. Very illuminating.

    I had first tried to implement the code snippet you suggested in the visual editor, but had no idea how to begin. So I pasted the code into the code editor instead.

    But after watching a few of the nifty things you did in the visual editor at the start of the webinar, I felt like taking another stab at it. This time I was able to enter the code through the visual editor (I checked this by examining the code editor). But how to test it with my example bibliography item? I eventually figured out how to do this. I exported the item in CSL JSON format and pasted it into the Advanced citation window of the visual editor to pull it in.

    Disappointment! The institution was not getting printed as the author. I then recalled something you showed in the webinar: conditionals can be moved up and down the tree. So I moved my conditionals up, just below the Substitute node. That did the trick! It's working now. I suppose this little experiment was an example of the webinar-plus-trial-and-error approach.

    Thanks for the linked musings page. Very useful.
  • Great -- have fun exploring. We (mainly damnation, bwiernik, and I) are always happy to help with specific CSL questions -- just post here, typically with a link to the current version of your custom style on pastebin.com or gist.github.com and you'll typically get a pointer quickly.
Sign In or Register to comment.