Sort Bibliography by Reference Type
I searched the forums and did not see a thread on this. If I overlooked it please accept my apologies.
I would like to see a feature that sorts the bibliography (with headings) by reference type, then alphabetical by author last name. For some humanities using Chicago Style we are required to format our bibliography with subheadings for reference type and under each subheading list the references alphabetically.
The most common subheadings are listed below, but there may be others for other disciplines.
Books and Scholarly Journal Articles
Newspapers and Magazines
Government Documents
Doctoral Dissertations and Masters Theses
Manuscripts and Archival Material
Audio and Video Recordings
Oral References
Thanks.
I would like to see a feature that sorts the bibliography (with headings) by reference type, then alphabetical by author last name. For some humanities using Chicago Style we are required to format our bibliography with subheadings for reference type and under each subheading list the references alphabetically.
The most common subheadings are listed below, but there may be others for other disciplines.
Books and Scholarly Journal Articles
Newspapers and Magazines
Government Documents
Doctoral Dissertations and Masters Theses
Manuscripts and Archival Material
Audio and Video Recordings
Oral References
Thanks.
Is there a way to do this sorting?
Thanks.
There is no "type" variable in CSL 1.0, so it would not be valid CSL, and the style code might well break if it were run on other systems. Also, the sort would be done on the underlying type identifier (so "Newspaper Article" would sort on the CSL "identifier article-newspaper"), without localization (CSL locales don't contain terms for the various item types, that label is known only to Zotero itself).
I thought Frank had some experimental code for sectional bibs?
But sadly, a lot of your technical language went over my head. I was hoping to have a plug-in or simple click or two to make this happen!
I feel dumb.
@mccorkell: The idea would be to do a rough sort of the bibliography that pretty much clusters the material in each of your target categories together (then sorting by author or date or whatever the style requires). You could then freeze a copy of the document at the last stage of production by deleting Zotero codes, and insert the headings and whatnot by hand. For the reasons given above, it's not really recommended (not because it's dangerous or anything, but because it's non-standard). The code for it would look like this (right below the <bibliography> tag):
<sort>
No guarantees, but it seems like it might work.<key variable="type"/>
<key macro="author"/><!-- or whatever -->
</sort>
http://www.zotero.org/support/csl_simple_edits?s[]=csl
I suspect this won't do and we'd need further modifications, as the sort by type would, e.g. separate journal articles from books and book chapters.
If yes, I frankly don't think Zotero supports this now, and that it's probably easier to just manually reshuffle the bibliography after you're done with the document.
Thanks!
And I don't think sections should be based on type, because often people want sections that don't really correspond to the Zotero or CSL type systems.
<macro name="type-sorting">
<choose>
<if type="case statute" match="any">
<text value="1"/>
</if>
<else>
<text value="2"/>
</else>
</choose>
</macro>
and then, in the
section of the bibliography, which currently looks something like this:
<sort>
<key macro="author"/>
<key variable="title"/>
</sort>
add the macro as the first parameter, i.e.
<sort>
<key macro="type-sorting"/>
<key macro="author"/>
<key variable="title"/>
</sort>
See here for general instructions on style changes:
http://www.zotero.org/support/dev/citation_styles/style_editing_step-by-step
This handling is specific to the style, and not a personal choice by the author, so CSL and its processors should explore whether this is feasible for a future revision of the language.
The alternative would seem to me to, for example, handle this in the word-plugin - maybe as part of an edit-bibliography dialogue, where you could specify how many bibliographies to create, what sub-headings they should have, what they should be sorted by and, if desired, move items between bibliographies. I understand Bruce as proposing something along those lines.
The magic in the CSL processors that make this happen would hopefully be made flexible enough that it could support sections defined by the user and not just those defined by the style. Essentially, I'm talking about adding sectioned bibliographies with limited functionality (including grouping by language and type, although we know the latter may be a little difficult) as part of CSL.
Additional work with sectioning, which many scholars use in large monographs, could be treated as outside the spec, could be handled by CSL processors and by Zotero and other clients without further implications for CSL. But I'd like to get the basic functionality of sectioning into the core of CSL.
While adamsmith's workaround is pretty neat, I guess it would be helpful if you could also define section headers. E.g. (not claiming this is a good idea), we could add a cs:sections element, similar to cs:sort. E.g.
<bibliography>
<sections>
<section type="book thesis" header="Books"/>
<section type="article-journal" header="Peer-reviewed Journal Papers"/>
<section header="Other"/>
</sections>
</bibliography>
The contents of each section would then be subject to the general sorting algorithm defined with cs:sort.
For now, adamsmith's sorting trick is the best solution. The problem is a pretty well-known one, and I suppose we'll try to keep this and the other forum threads abreast of any developments.
However, bibliographies sorted by types are quite common (at least in France). What I suggest is to rely on tags-saved searches or collection with a support of citeproc-js.
ATM, you can put items in different collections ("Primary source"/"Secondary source") and then generate a bibliography. But it lacks automaticity: user must have put all items he cites in a collection (or tags) and create his bibliography from zotero ui.
Do you think that would be possible (and desirable) to rely on collections/saved searches in order to create bibliographies sorted by types?
With this option selected (e.g: something like "sort-by-collections=yes" like particle management in csl 1.0), the processor will generate the bibliography when one clicks on the "Zotero insert bibliography" but after having checked that cited items belongs to differents collections.
The problem is that we don't use collections/tags only for that. A dialog could be useful in order to let the user decide which collections have to be taken into account.
The way the bibtex world handles sectional bibs is to allow citations to be assigned to named groups ("primary", "peer-reviewed", "other", "media", "legal", whatever). This is the solution I tend to prefer, as I'm pretty certain it will prove more flexible.
E.g. consider a CV where one needs to distinguish between peer-reviewed and non-peer-reviewed book chapters, or an article manuscript where you need a section for primary documents that includes audio tapes, photographs, and letters.
why dont´t a <text value="3"/> or 4 or 5... worked?
it would be great
Is somebody working on the type sorting issue? ;)
thank you for your great work
<macro name="type-sorting">
<choose>
<if type="book thesis" match="any">
<text value="1"/>
</if>
<if type="article-journal article-newspaper" match="any">
<text value="2"/>
</if>
</choose>
</macro>
Here the my code
<macro name="sort-key-bibliogroup">
<choose>
<if variable="archive archive_location URL" match="any">
<text value="2"/>
</if>
<else-if variable="publisher edition" match="any">
<text value="3"/>
</else-if>
<else>
<text value="1"/>
</else>
</choose>
</macro>
<bibliography ... >
<sort>
<key macro="sort-key-bibliogroup"/>
<key macro="sort-keysort-key"/>
<key variable="issued"/>
</sort>
The output was weird; I couldn't recognize a ordering - it was looking like the ordering was coming from the ordering in the Zotero window.
Why don't you add the the sort-key-bibliogroup macro as a variable before each items to see if it does what you want.
The general idea is right.
http://www.zotero.org/support/dev/citation_styles
@adamsmith: thank you to be patient with me ;-) It was late and as non-usal-coder (or experienced programmer) I had forgotten about the debug behaviour of output a function/variable and also linking to the full file.
I had tested two upgrades of my code. To understand this better here the important code and the link to the full file:
The base of my mod is http://www.zotero.org/styles/chicago-note-bibliography (but it is modded a lot now)
BIBLIOGRAPHY SORTING Variant a
Code Link http://pastebin.com/uBbARWMb
<macro name="bibliogroup-key">
<choose>
<if variable="publisher ISBN edition" match="any">
<text value="3"/>
</if>
<else-if variable="archive archive_location URL call-number" match="any">
<text value="2"/>
</else-if>
<else>
<text value="1"/>
</else>
</choose>
</macro>
<macro name="sort-key">
<text macro="bibliogroup-key" suffix=" "/>
<text macro="contributors-sort" suffix=" "/>
<date variable="issued" suffix=" "/>
<date variable="accessed" suffix=" "/>
<text variable="title" suffix=" "/>
<text variable="genre"/>
</macro>
...
<bibliography ...>
<sort>
<key macro="sort-key"/>
<key variable="issued"/>
</sort>
<layout suffix=".">
<group delimiter=". ">
<text macro="sort-key"/>
<text macro="contributors"/>
<text macro="title"/>
...
trying to insert in the layout gave me javsscript error
BIBLIOGRAPHY SORTING Variant b
same like in variant a, sort-key and biblio output is changed:
Code Link http://pastebin.com/EhFmLycV
<macro name="sort-key">
<text macro="contributors-sort" suffix=" "/>
...
<bibliography ...>
<sort>
<text macro="bibliogroup-key"/>
<key macro="sort-key"/>
<key variable="issued"/>
</sort>
<layout suffix=".">
<group delimiter=". ">
<text macro="bibliogroup-key" suffix=" "/>
<text macro="contributors"/>
<text macro="title"/>
...
While variant a seems to not work, variant b sorts the list correctly by the group key, but the alphabetical sorting in every group is not working.
I am tired now and thinking about giving up on this feature wish. Or can you help me find the error in thinking/coding?
<macro name="sort-key">
<text macro="contributors-sort" suffix=" "/>
</macro>
Before there I had the date variable.