Sorting by editor substituting authors
Hi everyone,
I'm currently finishing the style for my institute. So far, I'm pretty happy, but I can't get the sorting to work. I wish to sort the bibliography alphabetically by authors, which should be substituted by editors if no authors are available. However, currently, those publications are placed at the bottom.
Current behaviour:
A-Surname, Name…
C-Surname, Name…
B-Surname, Name (ed.)…
Should be:
A-Surname, Name…
B-Surname, Name (ed.)…
C-Surname, Name…
I can't get it to work and have no idea why. Relevant code:
<sort>
<key macro="sort-key"/>
</sort>
<macro name="sort-key">
<text macro="contributors-long" suffix=" "/>
<text macro="issued"/>
<text macro="title-long" suffix=" "/>
</macro>
<macro name="contributors-long">
<choose>
<if variable="author">
<names variable="author" font-variant="normal">
<name font-variant="normal" and="text" delimiter-precedes-last="never" name-as-sort-order="all">
<name-part name="family" font-variant="normal"/>
</name>
<et-al term="et-al"/>
</names>
</if>
<else>
<choose>
<if type="bill book graphic legal_case motion_picture report song" match="any">
<names variable="editor">
<name name-as-sort-order="all" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="never">
<name-part name="family" font-variant="normal"/>
</name>
<et-al term="et-al"/>
<label form="short" prefix=" (" suffix=")"/>
</names>
</if>
</choose>
</else>
</choose>
<date variable="issued" prefix=" (" suffix=")">
<date-part name="year"/>
</date>
</macro>
Any help would be greatly appreciated!
I'm currently finishing the style for my institute. So far, I'm pretty happy, but I can't get the sorting to work. I wish to sort the bibliography alphabetically by authors, which should be substituted by editors if no authors are available. However, currently, those publications are placed at the bottom.
Current behaviour:
A-Surname, Name…
C-Surname, Name…
B-Surname, Name (ed.)…
Should be:
A-Surname, Name…
B-Surname, Name (ed.)…
C-Surname, Name…
I can't get it to work and have no idea why. Relevant code:
<sort>
<key macro="sort-key"/>
</sort>
<macro name="sort-key">
<text macro="contributors-long" suffix=" "/>
<text macro="issued"/>
<text macro="title-long" suffix=" "/>
</macro>
<macro name="contributors-long">
<choose>
<if variable="author">
<names variable="author" font-variant="normal">
<name font-variant="normal" and="text" delimiter-precedes-last="never" name-as-sort-order="all">
<name-part name="family" font-variant="normal"/>
</name>
<et-al term="et-al"/>
</names>
</if>
<else>
<choose>
<if type="bill book graphic legal_case motion_picture report song" match="any">
<names variable="editor">
<name name-as-sort-order="all" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="never">
<name-part name="family" font-variant="normal"/>
</name>
<et-al term="et-al"/>
<label form="short" prefix=" (" suffix=")"/>
</names>
</if>
</choose>
</else>
</choose>
<date variable="issued" prefix=" (" suffix=")">
<date-part name="year"/>
</date>
</macro>
Any help would be greatly appreciated!
This is an old discussion that has not been active in a long time. Before commenting here, you should strongly consider starting a new discussion instead. If you think the content of this discussion is still relevant, you can link to it from your new discussion.
Upgrade Storage
Also, your contributors macro probably won't work as intended. Rather than
<choose>elements, you want to use use<substituteparameters within the<names>elements.You also don't need to specify font-variant="normal", as this is the default, and you only need to use the et-al parameter to change the formatting (to italics, for example). If it is in normal text, the parameter can be omitted.
The macro as written also doesn't print author/editor first names/initials; is that intended?
Finally, it's unusual to include the issued date in a contributors macro. What is your thinking there?
Here is code that should work for you (it includes the issued year):
The sorting code:
<sort><key macro="contributors-long"/>
<key macro="issued"/>
<key macro="title-long"/>
</sort>
The contributors macro, with creator initials
<macro name="contributors-long"><names variable="author">
<name name-as-sort-order="all" and="text" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="never"/>
<label form="short" prefix=" (" suffix=")"/>
<substitute>
<names variable="editor"/>
<names variable="translator"/> <!-- Including translator is a good idea for items that have neither an author or editor listed -->
<text macro="title" form="short"/> <!-- You probably want to include the title as a substitute option for items that have no creators -->
</substitute>
</names>
<date variable="issued" prefix=" (" suffix=")">
<date-part name="year"/>
</date>
</macro>
The contributors macro, without creator initials
<macro name="contributors-long"><names variable="author">
<name form="short" name-as-sort-order="all" and="text" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="never"/>
<label form="short" prefix=" (" suffix=")"/>
<substitute>
<names variable="editor"/>
<names variable="translator"/> <!-- Including translator is a good idea for items that have neither an author or editor listed -->
<text macro="title" form="short"/> <!-- You probably want to include the title as a substitute option for items that have no creators -->
</substitute>
</names>
<date variable="issued" prefix=" (" suffix=")">
<date-part name="year"/>
</date>
</macro>
Seemingly, the date-part was breaking the sorting. After removing it (putting it in it's own macro), sorting is back to usual. I have used your way of substituting, working well. Thanks again.
I'm back with another question. Trying to add disambiguate-add-year-suffix="true", but not sure where / how. Adding it so cs:citation and cs:bibliography doesn't seem to work.
Here's the full style, with author and contributors stripped:
https://gist.github.com/anonymous/a53ea0acb204e0e1be14ea2950d5e20d
Thanks alot!
I'm getting:
Author (2000): Title. Place: Publisher.
Author (2000): Different title. Place: Publisher.
Instead of:
Author (2000a): Title. Place: Publisher.
Author (2000b): Different title. Place: Publisher.