Using the "extra" field to add more info. (Citation count)
Hi all,
I'm doing something non-standard and want to add "Number of citations: X" to the end of my bibliography.
So it would look like:
McInnis, M. D., & Nelson, L. P. (2011). Shaping the body politic: Art and political formation in early america. Charlottesville, VA: University of Virginia Press. Number of citations: X.
I wanted to pull "X" variable from the "extra" field since that seems unused.
Can I just add
<text variable="extra" prefix="Citations: "/>
To somewhere in the publisher macro? (I tried and didn't work and I guess I've got the wrong placement). Should I just place it inside all the if/then statements? Zotero didn't like what I did and said my CSL wasn't a Zotero CSL.
Any suggestions? I just want to have some text like "Cited" XX "times" with the XX coming from a field in Zotero. Thanks!
Here's the code.
<macro name="publisher">
<choose>
<if type="report" match="any">
<group delimiter=": ">
<text variable="publisher-place"/>
<text variable="publisher"/>
</group>
</if>
<else-if type="thesis" match="any">
<group delimiter=", ">
<text variable="publisher"/>
<text variable="publisher-place"/>
</group>
</else-if>
<else-if type="post-weblog webpage" match="none">
<group delimiter=", ">
<choose>
<if variable="event" type="speech" match="none">
<text variable="genre"/>
</if>
</choose>
<choose>
<if type="article-journal article-magazine" match="none">
<group delimiter=": ">
<choose>
<if variable="publisher-place">
<text variable="publisher-place"/>
</if>
<else>
<text variable="event-place"/>
</else>
</choose>
<text variable="publisher"/>
</group>
</if>
</choose>
</group>
</else-if>
</choose>
</macro>
I'm doing something non-standard and want to add "Number of citations: X" to the end of my bibliography.
So it would look like:
McInnis, M. D., & Nelson, L. P. (2011). Shaping the body politic: Art and political formation in early america. Charlottesville, VA: University of Virginia Press. Number of citations: X.
I wanted to pull "X" variable from the "extra" field since that seems unused.
Can I just add
<text variable="extra" prefix="Citations: "/>
To somewhere in the publisher macro? (I tried and didn't work and I guess I've got the wrong placement). Should I just place it inside all the if/then statements? Zotero didn't like what I did and said my CSL wasn't a Zotero CSL.
Any suggestions? I just want to have some text like "Cited" XX "times" with the XX coming from a field in Zotero. Thanks!
Here's the code.
<macro name="publisher">
<choose>
<if type="report" match="any">
<group delimiter=": ">
<text variable="publisher-place"/>
<text variable="publisher"/>
</group>
</if>
<else-if type="thesis" match="any">
<group delimiter=", ">
<text variable="publisher"/>
<text variable="publisher-place"/>
</group>
</else-if>
<else-if type="post-weblog webpage" match="none">
<group delimiter=", ">
<choose>
<if variable="event" type="speech" match="none">
<text variable="genre"/>
</if>
</choose>
<choose>
<if type="article-journal article-magazine" match="none">
<group delimiter=": ">
<choose>
<if variable="publisher-place">
<text variable="publisher-place"/>
</if>
<else>
<text variable="event-place"/>
</else>
</choose>
<text variable="publisher"/>
</group>
</if>
</choose>
</group>
</else-if>
</choose>
</macro>
See here for a complete mapping:
http://aurimasv.github.io/z2csl/typeMap.xml#map-journalArticle
With that this will work, just make sure you don't place it inside some if condition that's may not be met.
<text variable="note" prefix="Citations: "/>
this will work.
<macro name="publisher">
<choose>
<if type="report" match="any">
<group delimiter=": ">
<text variable="publisher-place"/>
<text variable="publisher"/>
<text variable="note" prefix="Citations: "/>
</group>
</if>
<else-if type="thesis" match="any">
<group delimiter=", ">
<text variable="publisher"/>
<text variable="publisher-place"/>
<text variable="note" prefix="Citations: "/>
</group>
</else-if>
<else-if type="post-weblog webpage" match="none">
<group delimiter=", ">
<choose>
<if variable="event" type="speech" match="none">
<text variable="genre"/>
</if>
</choose>
<choose>
<if type="article-journal article-magazine" match="none">
<group delimiter=": ">
<choose>
<if variable="publisher-place">
<text variable="publisher-place"/>
<text variable="note" prefix="Citations: "/>
</if>
<else>
<text variable="event-place"/>
<text variable="note" prefix="Citations: "/>
</else>
</choose>
<text variable="publisher"/>
<text variable="note" prefix="Citations: "/>
</group>
</if>
</choose>
</group>
</else-if>
</choose>
</macro>
Doe, J. (2015b, August 13). Jane De's Plight. New York Times. Citations: 2: Citations: 2. Retrieved from http://www.nytimes.com/2015/08/14/janedoesplight.
<macro name="publisher">
<group delimiter=". ">
<choose>
<if type="report" match="any">
<group delimiter=": ">
<text variable="publisher-place"/>
<text variable="publisher"/>
</group>
</if>
<else-if type="thesis" match="any">
<group delimiter=", ">
<text variable="publisher"/>
<text variable="publisher-place"/>
</group>
</else-if>
<else-if type="post-weblog webpage" match="none">
<group delimiter=", ">
<choose>
<if variable="event" type="speech" match="none">
<text variable="genre"/>
</if>
</choose>
<choose>
<if type="article-journal article-magazine" match="none">
<group delimiter=": ">
<choose>
<if variable="publisher-place">
<text variable="publisher-place"/>
</if>
<else>
<text variable="event-place"/>
</else>
</choose>
<text variable="publisher"/>
</group>
</if>
</choose>
</group>
</else-if>
</choose>
<text variable="note" prefix="Citations: "/>
</group>
</macro>
The problem are the various nested if conditionals here to fit APAs (I assume) rather convoluted requirements. Easier if -- since you want this for all item types I assume -- you take this out of any if/else-if conditional entirely.
Or even in the bibliography as the last element, with prefix=". "
*goes and tries*
Same error message. Not Zotero CSL file. My version works but just repeats due to the if-then structure.
I tested my code above pasted into APA and that definitely works.
Otherwise try
<text macro="access" prefix=" "/>
<text macro="original-date" prefix=" "/>
<text variable="note" prefix=". Citations: "/>
</layout>
all the way at the bottom. That would be the easiest solution.
https://gist.github.com/anonymous/ef4a084053c6e6455a7c
I am fine with APA. Sort order change is easy to do. I just would like to have a place which says "number of citations:" X, preferably at the end of citation after the "retrieved from" and everything at the very very end.
https://gist.github.com/adam3smith/90273f809beb82a6e91b/raw/5c07534a332ee9db4150fba5d4ccae9229fe8d3a/unc-cv-cite.csl (direct download link), which will actually place the citation count at the end.
1. The universal way of adding the extra field at the end of every bibliography entry for any style is to add
<text variable="note" prefix=". "/>
in the third last line of the style, right above</layout>
You can then add anything else you want to the prefix field. See the general instructions on modifying styles here.2. In case you or anyone wants to use this as part of an online CV based on the Zotero API, it's now possible to use any style hosted online (e.g. a link to the raw github version) to get formatted Zotero reference lists. API basics here. An example request could look like this: https://api.zotero.org/users/475425/items/X42A7DEE?format=bib&style=https://raw.githubusercontent.com/citation-style-language/styles/master/apa.csl