Automating citations

By Sancho McCann · , edited:

I wrote the code that con­trols how this web­site ap­pears to you. This is of course built on top of the work of oth­ers, like the pollen pub­lish­ing sys­tem. I want to share how I’ve cus­tomized and au­to­mat­ed the ci­ta­tion sys­tem for this site. I know that foot­notes are not com­mon nor nec­es­sary in a blog for­mat and I al­most al­ways in­clude a link that you can just click to get to a source. But I do write some ma­te­r­i­al that may be im­proved, at least for some of my au­di­ence, by in­clud­ing tra­di­tion­al ci­ta­tions. And if I don’t have to do much ex­tra work to pro­vide these, why not?

I also en­vi­sion blogs as a medi­um for aca­d­e­m­ic ex­change of ideas. Not every­thing has to be a pa­per in or­der to get feed­back from peers. But if I’m ever go­ing to use this plat­form for that, I don’t want to be held back by ci­ta­tions.

First attempt

I pre­sent­ed my first at­tempt at a foot­note sys­tem here. That was most­ly about get­ting their mere ap­pear­ance as foot­notes cor­rect (that they ac­tu­al­ly show up, with the right num­bers, ei­ther along­side their re­lat­ed text or at the bot­tom of the page with link-backs, etc.). I still had to lay them out in my source text.

I'd have to write a foot­note like this.◊note{See Angela
Fernandez, "◊a[#:href
"https://www.js­tor.org/sta­ble/27641649"]{The Lost Record of Pierson
v. Post, the Famous Fox Case}," ◊em{Law and History Review}
27, no. 1 (2009): 149–78.}

That would get turned into a foot­note like this. (I was us­ing the Chicago Manual of Style at the time.) Note that in the source, I had to ex­plic­it­ly cre­ate the link (the ◊a[#:href ...]) and spec­i­fy which text need­ed to be ital­i­cized (us­ing ◊em).

This was in­ad­e­quate in three ways:

Second attempt

My sec­ond ap­proach dealt with the last two is­sues by au­tomat­ing the lay­out of an in­di­vid­ual ci­ta­tion. I used some ci­ta­tion tem­plates that gath­ered the ci­ta­tion data and au­to­mat­i­cal­ly for­mat­ted the ci­ta­tion ac­cord­ing to the Chicago Manual of Style.

That let me write a ci­ta­tion like
this.◊note{◊cite-ar­ti­cle[#:ti­tle "The Lost Record of
Pierson v. Post, the Famous Fox Case" #:au­thor "Angela Fernandez"
#:year "2009" #:jour­nal "Law and History Review" #:vol­ume "27" #:is­sue
"1" #:pages "149--78" #:url "https://www.js­tor.org/sta­ble/27641649"]}

This called some code that au­to­mat­i­cal­ly laid out the ci­ta­tion ac­cord­ing to the style guide. That auto-lay­out code (which would be called when­ev­er I wrote ◊cite-ar­ti­cle[...] looked like this:

(define (cite-ar­ti­cle #:au­thor [au­thor #f] #:ti­tle [ti­tle #f] #:jour­nal [jour­nal #f] #:year [year #f] #:vol­ume [vol­ume #f] #:is­sue [is­sue #f] #:pages [pages #f] #:url [url #f])
  ; Chicago Manual of Style, bib­li­og­ra­phy form.
`(span [[class "bib­li­og­ra­phy-en­try"]] ,au­thor ", “" ,(if url `(a [[href ,url]] ,ti­tle) ti­tle) ",” " (em ,jour­nal) " " ,vol­ume ,(when/splice is­sue ", no. " is­sue) " (" ,year "): " ,pages "."))

This isn’t pret­ty code, but you can see that it knows to list the au­thor first, then list the ti­tle in quotes, op­tion­al­ly link­ing to a URL if one was pro­vid­ed, etc. This au­toma­tion re­moved a com­mon source of er­ror. And if I want­ed to up­date the ci­ta­tion style, I’d just have to change what my cite-ar­ti­cle func­tion did, in one place, and all of my ci­ta­tions across the site would be up­dat­ed.

There was still one large source of rep­e­ti­tion and er­ror: cit­ing the same work mul­ti­ple times in an ar­ti­cle. I’d ei­ther need to copy-and-paste that ci­ta­tion tem­plate or man­u­al­ly write ci­ta­tion back-ref­er­ences like “ibid” and “supra”.

Third attempt

My third at­tempt takes an ap­proach sim­i­lar to that of LaTex and my fac­tum/pa­per au­thor­ing tool.

First, I sep­a­rate the de­c­la­ra­tion of a work from its dis­play:

◊de­clare-work[#:type "le­gal-case" #:id "se­ces­sion"
#:ti­tle "Reference re Secession of Quebec"
#:ci­ta­tion "[1998] 2 SCR 217"
#:url "https://scc-csc.lex­um.com/scc-csc/scc-csc/en/item/1643/in­dex.do"
#:short-form "Secession ref­er­ence"]

◊de­clare-work[...] doesn’t do any­thing ex­cept tell the ren­der­ing sys­tem about the work. In or­der to ac­tu­al­ly dis­play that ci­ta­tion to you, I have to call ◊note-cite[“se­ces­sion”].

So, if I write this:

You see a note that cites the se­ces­sion ref­er­ence.◊note-cite["se­ces­sion"]

You see a note that cites the se­ces­sion ref­er­ence.

And if I write this:

You see a sec­ond ci­ta­tion to the se­ces­sion ref­er­ence, this one with a
pin­point.◊note-cite["se­ces­sion" #:pin­point "para­graph 49"]

You see a sec­ond ci­ta­tion to the se­ces­sion ref­er­ence, this one with a pin­point. It isn’t a mis­take that the source calls for a pin­point to “para­graph 49” but what you’re see­ing in the foot­note is “para 49”. The sys­tem knows that para­graphs are prop­er­ly pin­point­ed us­ing “para” in McGill style.

If there is an in­ter­ven­ing foot­note, then the sub­se­quent ci­ta­tion to the se­ces­sion ref­er­ence will use the short-form that was first de­clared in ◊de­clare-work and it will also re­fer back to the ini­tial foot­note in which it was first used.

No one should be spending time laying out citations

How many times did you check your ci­ta­tions?

This is one of the biggest wastes of time in law school. It is cer­tain­ly im­por­tant to be able to find the source a ci­ta­tion refers to, to know what needs to be cit­ed, to un­der­stand what works or cas­es are au­thor­i­ta­tive for par­tic­u­lar propo­si­tions, etc. But we gain noth­ing by re­mem­ber­ing that you say “at 419” and not “at page 419” or that you put a com­ma af­ter the ti­tle of a jour­nal ar­ti­cle but not af­ter the ti­tle of a mag­a­zine or news ar­ti­cle. We spend hours on each pa­per check­ing and cor­rect­ing ci­ta­tions for ad­her­ence to the McGill Guide. And if you move one ref­er­ence, you have to make sure all the back-ref­er­ences are up­dat­ed. This is all work that a com­put­er is per­fect for.

But sys­tems like LaTeX which are ad­e­quate for com­put­er sci­ence ci­ta­tions are in­ad­e­quate for ci­ta­tion lay­out for le­gal writ­ing. Even confining the task to just pa­per-writ­ing, a foot­note in a law pa­per can con­tain mul­ti­ple ci­ta­tions and re­lat­ed tex­tu­al in­for­ma­tion. And fac­tums and mem­o­ran­da have to­tal­ly different lay­out rules than pa­pers. The McGill Guide’s fac­tum style is un­like any­thing in any oth­er field of writ­ing.

I’ve used LaTex for over a decade and now I’ve writ­ten two foot­note/ci­ta­tion au­toma­tion sys­tems: my fac­tum/pa­per au­thor­ing tool, and this web­site’s ren­der­ing sys­tem. I think it would be pos­si­ble to get them both to a state where I nev­er have to think about ci­ta­tion lay­out again. I wrote a mem­o­ran­dum, two pa­pers, and my moot fac­tum this year all us­ing my fac­tum/pa­per au­thor­ing tool. One bar­ri­er to com­plete re­liance on an au­to­mat­ed sys­tem is col­lab­o­rat­ing with oth­ers. Most (maybe all?) jour­nals use Microsoft Word for sub­mis­sions and edit­ing. So, af­ter writ­ing my jour­nal pa­per us­ing my own au­thor­ing tool, I had to ex­port it to Word in or­der to sub­mit it to the jour­nal, and had to man­u­al­ly edit the ci­ta­tions in Word through­out the edit­ing process.

Another bar­ri­er is the com­plex­i­ty and un­ex­pect­ed vari­a­tion in le­gal ci­ta­tions. It just isn’t pos­si­ble to take care of every lit­tle edge case. I know I just said that no one should spend any time on this, but even a com­plete sys­tem will have to al­low the au­thor to en­ter a cus­tomized ci­ta­tion, in a for­mat that doesn’t match any pre-defined lay­out, with­out throw­ing off the rest of the ci­ta­tions that are be­ing man­aged au­to­mat­i­cal­ly.

Code

These are all in var­i­ous stages of readi­ness, but take a look at them, use them or use ideas from them, and let me know how they could be bet­ter:

Related projects: