citeproc - emacs-citar/citar GitHub Wiki

Formatting references

Custom name formatting

CSL has rich configuration options for author and such name formatting. You can use citeproc like so.

First, define a CSL style, like so:

;; example borrowed from org-csl
;; https://github.com/rougier/org-bib-mode
(defvar my/author-name-csl
  "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<style xmlns=\"http://purl.org/net/xbiblio/csl\" class=\"in-text\" version=\"1.0\" demote-non-dropping-particle=\"never\">
  <macro name=\"author-bib\">
    <names variable=\"composer\" delimiter=\", \">
      <name name-as-sort-order=\"all\" and=\"symbol\" sort-separator=\", \" initialize-with=\". \" delimiter=\", \" delimiter-precedes-last=\"always\"/>
      <substitute>
        <names variable=\"author\"/>
        <names variable=\"illustrator\"/>
        <names variable=\"director\">
          <name name-as-sort-order=\"all\" and=\"symbol\" sort-separator=\", \" initialize-with=\". \" delimiter=\", \" delimiter-precedes-last=\"always\"/>
          <label form=\"long\" prefix=\" (\" suffix=\")\" text-case=\"title\"/>
        </names>
        <names variable=\"editor\" delimiter=\", \">
          <name name-as-sort-order=\"all\" and=\"symbol\" sort-separator=\", \" initialize-with=\". \" delimiter=\", \" delimiter-precedes-last=\"always\"/>
          <label form=\"short\" prefix=\" (\" suffix=\")\" text-case=\"title\"/>
        </names>
        <names variable=\"editorial-director\">
          <name name-as-sort-order=\"all\" and=\"symbol\" sort-separator=\", \" initialize-with=\". \" delimiter=\", \" delimiter-precedes-last=\"always\"/>
          <label form=\"short\" prefix=\" (\" suffix=\")\" text-case=\"title\"/>
        </names>
        <names variable=\"collection-editor\">
          <name name-as-sort-order=\"all\" and=\"symbol\" sort-separator=\", \" initialize-with=\". \" delimiter=\", \" delimiter-precedes-last=\"always\"/>
          <label form=\"short\" prefix=\" (\" suffix=\")\" text-case=\"title\"/>
        </names>
      </substitute>
    </names>
  </macro>
  <bibliography >
     <sort>
       <key macro=\"author-bib\"/>
     </sort>
     <layout>
       <text macro=\"author-bib\" />
     </layout>
   </bibliography>
</style>"
  "CSL style to get only author names (as used in preview mode).")

Then you can use citar-citeproc-format-reference like so:

(citar-citeproc-format-reference '("citekey") my/author-name-csl)
⚠️ **GitHub.com Fallback** ⚠️