[Tex/LaTex] Bibliography style per language with biblatex/polyglossia

biblatexlanguagespolyglossia

This is a followup to Russian and Japanese and biblatex oh my. I've got a lot further now, using the polyglossia-enabled bib latex and writing my own Japanese csquotes and lbx files, but now I'm hitting another problem. It's a bit similar to How to create multilingual (English, Japanese) bibliographies with biblatex, biber and polyglossia, but different.

Japanese and English/Russian bibliography entries have quite different format. Here is an example of what I am trying to achieve:

Aizawa & Kumagai (1983) 相沢英資、熊谷信男編『中新田ハリストス正教会沿革史 開教100周年記念』中新田:中新田ハリストス正教会、1983。

Brower & Lazzerini (1997) Brower, Daniel R. and Edward J. Lazzerini, eds., Russia’s Orient: imperial borderlands and peoples, 1700-1917. Bloomington: Indiana University Press, 1997.

Notice that in the Japanese entry, there is no "and" joining the names (I can manage that in the lbx file) but also that the book title is quoted, and that the authors' names are not reordered or abbreviated but appear in both cases as last-first with no space between them, and no space between the names and "eds." (編)

Can I change the bibliography style on a per-entry basis, and is there anything like a Japanese bibliography style available? (If not, where do I start?)

Best Answer

General Introduction

This is do-able; but it is not easily doable. So I'm afraid this is not an answer to the question that anyone is going to be able to accept: just a record of the problem. The person to do this would have to understand intimately the conventions of the languages involved, and have at least some idea of how biblatex works, though that isn't any harder than escaping from the Cretan labyrinth -- just follow the thread as it snakes around.

To understand why it's possible, and why it's hard, you need to know a bit about how biblatex works.

At the heart of every biblatex style are three files:

  • One (or more) file(s) with the .lbx extension contain language definitions, such as the appropriate strings for things like "editor", "commentator" (obviously, different in every language), but also macros for producing dates (consider, e.g., the difference between English-English and American-English date conventions).

  • One file .cbx is responsible for generating the in-text citations, such as "[1]" or "(Chuzzlewit 1975)".

  • One file .bbx is responsible for generating the bibliography list.

That is a slight oversimplification, because in some styles there is a close linkage between .cbx and .bbx files, because in some styles the in-text citations are (at least sometimes) more or less identical to the full bibliographical entry. But it's sufficiently accurate to say that the actual printing of the bibliographical data, whether it is done in-text or in a separate bibliography or both, is largely the work of the .bbx files.

For present purposes, let's ignore that complexity. Let's concentrate on the .bbx files.

What a .bbx file looks like

If you look at a .bbx file, you will see a lot of things that look like this:

\DeclareBibliographyDriver{article}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \usebibmacro{in:}%
  \usebibmacro{journal+issuetitle}%
  \newunit
  \usebibmacro{byeditor+others}%
  \newunit
  \usebibmacro{note+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{issn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

Basically what this does is work systematically through the various "chunks" that make up any bibliographical entry, printing them as appropriate. But note two things. First, the order of those chunks is fixed. And secondly, within each chunk, the driver makes heavy use of \usebibmacro to call subsidiary bits and pieces that deal with the logic within chunks. One of the things they often do is print bibstrings, which are defined in .lbx files: things like "editor" or "translator" or "volume". But where a bibmacro generates output it, like the BibliographyDriver usually does so in an order that is hardwired.

How different languages are handled

Biblatex is able, while sticking with this same driver in every case, to make certain concessions to differences in language: so \bibstring for instance can work out whether to print "editor" or "Herausgeber"; the .lbx files also define some macros which are used to print dates and the like. And it can make (which is really the most important) hyphenation patterns depend on the original language.

But so much is hard baked into the .bbx despatcher system, that the sort of reorganisation that involves fundamentally altering the order of what is printed is tiresome to achieve. There is no "off-the shelf" solution. One can easily say "take your bibstring definitions for Japanese from this file, but your bibstring definitions for English from that one; but you cannot say "take your bibliographic template for English works from this .bbx, but your bibliographic template for Japanese ones from that .bbx. The .bbx files can load others, but in the end there is a single point of entry. From this, the basic structure is hard-baked.

In order to allow the choice of language to have a more than largely superficial effect, therefore, you have to work as follows:

  • Write (or copy) a bibliography driver and/or set of macros for each entrytype and language.
  • Write a mechanism which somehow examines the language and then despatches to the right driver.

I can think of at least two ways to do this, and there are very likely more. One would involve playing with the data before it ever got into Biblatex, while it was in biber, effectively re-writing the entrytypes so that, say, book became book-japanese, and then distinguishing between the book and book-japanese types by providing them with different types. This is suggested in the comments above. There are downsides to that for the user, though, who would have to know and understand the implications, for instance if s/he wanted to have a bibliography divided by type.

The other, which I used when I faced an analogous problem when dealing with cases from different jurisdictions, is to keep a single type, but to make the driver a wrapper whose only job is to examine the relevant field, and then despatch on it, as well as doing bits and pieces of cleanup, leaving it for a set of \bibmacros to do the actual formatting. That produces some rather unlovely code, but it does the job.

But it is key to note, that whichever of these you do, you have to produce a new .bbx, specialised for just the languages you are willing to handle. Even if you just copied definitions from existing and appropriate .bbx file and renamed them as necessary (and I don't know whether, for instance, anyone has even done one for Japanese), you'd still have a great deal of work and testing, because you would find that your source files made heavy use of bibmacros with the same name, but with different definitions, and you'd have to work out which macros were safe to use, and which need specialising, and do all that. Theoretically dull work, but painstaking.

(Often--mostly--the bibmacros are dealing with the sort of obscure corner-cases beloved of those who dictate bibliography rules. They are capable of requiring all sorts of odd little things.)

Could one do this just from Biblatex?

I have nothing to do with maintaining biblatex, but from the outside I don't think one can realistically hold on to one's hat for this to be tidied up in Biblatex in the near future -- even though Biblatex has a really creditable record of being written, as far as possible, to be expandable and adaptable. The problem is that it would not be enough to change drivers by language (that would be fairly simple, I expect): the .bbx files do a lot of work using bibmacros, and those often share names. Some method for putting these macros in different namespaces depending on where they were defined would be needed, when the classic pattern in the existing codebase is for promiscuous redefinition without renaming, and in various ways that approach is cooked in.

Edited to add Also, as moewe points out in the comments, it is hard to conceive of any way of adding this feature that would not cause compatibility problems. A tiny recent change in this direction (designed to remove the parochial assumption that one's first name is also one's given name), simple as it was, hints at the possible problems. And now that Biblatex has a reasonable range of working styles, maintaining compatibility is pretty important.