A simple way to quote from bibTeX in MediaWiki

⇠ Back to Blog:Hacks

I would like to quote references in MediaWiki from a $\mathrm{B{\scriptstyle{IB}}\TeX}$ (.bib) file.

The key indexing scheme I use is:

name-of-first-authortwo-last-digits-of-year-of-publication⇿$\alpha$

where ⇿ means concatenation and $\alpha$ runs over the alphabet to discriminate publications from the first author in the same year. Extracts from my bib file read:

@Article{laussy04a,

 author = 	 {F. P. Laussy and G. Malpuech and A. Kavokin},
 title = 	 {Spontaneous coherence buildup in a polariton laser},
 journal = 	 pssc,
 year = 	 2004,
 volume =	 1,
 pages =	 {1339},
 pdf =          {sci/laussy04a},
 url =          {doi:10.1002/pssc.200304064}

}

@Article{delvalle10d,

 author = 	 {E. del Valle and F. P. Laussy},
 title = 	 {Mollow Triplet under Incoherent Pumping},
 journal = 	 prl,
 year = 	 2010,
 volume = 	 105,
 pages = 	 233601,
 pdf = {sci/delvalle10d},
 url = {doi:10.1103/PhysRevLett.105.233601}

}

In a $\mathrm{\TeX}$ file, I simply call the reference like this~\cite{delvalle10d}, which should read:

like this [1]

In MediaWiki, I would like to have something similar like {{cite|delvalle10d}} to similarly add a reference inline[1] and list its details in a References section at the bottom of the page.

What is available in the Matrix

The Referencing extensions category lists what is available in the MediaWiki Extension Matrix.

Cavila compiled a table on his/her user page.

The closest to what I want is maybe to be found in Miranche's BiblioTeX extension, but this is a work in progress with no code yet available.

My solution

My proposal is to use templates and the Cite extension.

To each entry of the bibTeX file is associated a template with the same name; in the cases above, {{laussy04a}} and {{delvalle10d}}, which can be quoted online, like this "Mollow Triplet under Incoherent Pumping. E. del Valle and F. P. Laussy in Phys. Rev. Lett. 105:233601 (2010). Pdf-48px.png" (I wrote like this "{{delvalle10d}}"), or in a list:

  1. Spontaneous coherence buildup in a polariton laser. F. P. Laussy, G. Malpuech and A. Kavokin in Phys. Stat. Sol. C 1:1339 (2004). Pdf-48px.png
  2. Mollow Triplet under Incoherent Pumping. E. del Valle and F. P. Laussy in Phys. Rev. Lett. 105:233601 (2010). Pdf-48px.png

or in a mouse rolloverMollow Triplet under Incoherent Pumping. E. del Valle and F. P. Laussy in Phys. Rev. Lett. 105:233601 (2010). Pdf-48px.png or quoted through the cite template.

The definition of {{cite}}, to work as described, could be:

{{#tag:ref|{{{{{1}}}}}|name={{{1}}}}}

This allows to separate the reference itself from its quotation and has the advantage that multiple quotations of the same reference[1] refer to the same number.

A dirty hack allows to define a working
{{onlinecite|...}}
to have references be cited like this Ref. [1].

Quoting many references is done like this{{cite|delvalle10d}}{{cite|laussy04a}} with a result like this[1][2]. Quoting more references reads [1][2][3] rather than [1-3] to allow each reference to be clickable.

This also allows to track all pages linking to a particular reference through the Special page WhatLinksHere on the corresponding template: Special:WhatLinksHere/Template:delvalle10d.

There remains to create the templates from the bibTeX file, which can be done by hand (merely copy-pasting the output from bibtex2html, say) or with a bot for large databases. I think that the best approach, rather than indiscriminately uploading an entire database, is to generate the templates as they become required. Given that references not yet present in the wiki will show up as red-links, on can think of a script, say bib2wiki, which takes as arguments bibTeX keys of references:

bib2wiki laussy04a delvalle10d

and create the associated templates in the database, e.g., for the first entry:

'''[http://dx.doi.org/10.1002/pssc.200304064 Spontaneous
 coherence buildup in a polariton laser]'''. [[F. P. Laussy]], [[G. Malpuech]]
 and [[A. Kavokin]]. Phys. Stat. Sol. C '''1''', 1339 (2004).

The bib2wiki script is not yet available but is not necessary for the scheme to work effortlessly. I will write it if this simple idea performs well in its testing phase. For the time being, I've tweaked bibtex2html to generate an output that I can easily copy-past in a template:

Bibtex-laussy.png

Update.png16 July 2023 bib2wiki was finally written on 16 July (2023).

References

The texts below are used as illustrations and their actual content is not related to the topic of this post.

  1. 1.0 1.1 1.2 1.3 Mollow Triplet under Incoherent Pumping. E. del Valle and F. P. Laussy in Phys. Rev. Lett. 105:233601 (2010). Pdf-48px.png
  2. Spontaneous coherence buildup in a polariton laser. F. P. Laussy, G. Malpuech and A. Kavokin in Phys. Stat. Sol. C 1:1339 (2004). Pdf-48px.png