Skip to Main Content
It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.

Zotero

A Bibliography Sorted by Document Types

In most styles, bibliographies are primarily sorted by authors names. Some authors would like to sort it also by document types, to distinguish between primary and secondary sources, for instance. This can easily be done by adding a simple macro and then adding it as the first sorting criteria of the bibliography. The subheadings must be added manually.

Click on "macros", then on the "+" at the top of the column, click on the "macro" button in the pop-up window, and give her a name, "sort-by-type", for instance. The "macro: Sort-by-type" appears in the macro list on the left, you can select it, click on the "+" and start entering the following instructions:

  • Select "Conditional", then "If": the default conditional which appears is "if the document type is", and you can select in the drop-down menu the document types you would like to put in your first category, for instance "book" and "chapter".
  • Then select the "if book OR chapter", click on the "+", and "Text", and enter "1" in the "value" field.
  • Select "Conditional" again, "+", "Else-if" and select the document types you would like to put in your second category. Enter "2" in the "value" field.
  • Do it again, and again, until you reach the last category (end with "Else").
  • Then click on "sort", add a new sort-key, type "macro", and select your new macro. Drag and drop it in the first position of the sort-keys.

If you prefer to work directly on the code, it would look more or less like this:
<macro name="sort-type">
    <choose>
      <if type="book chapter paper-conference article-magazine article-newspaper article-journal manuscript report speech entry-encyclopedia" match="any">
        <text value="1"/>
      </if>
      <else-if type="legal_case">
        <text value="2"/>
        <text variable="title"/>
      </else-if>
      <else-if type="bill legislation" match="any">
        <text value="3"/>
        <choose>
          <if type="legislation">
            <text variable="title"/>
          </if>
        </choose>
      </else-if>
      <else-if type="treaty">
        <text value="4"/>
      </else-if>
      <else>
        <text value="1"/>
      </else>
    </choose>
  </macro>
(this macro is taken from the Oscola Zotero style, which is already using this sorting criteria).