TransWikia.com

How do you check whether an author list consists of only one or multiple authors in a custom driver in BibLaTeX?

TeX - LaTeX Asked by Palpatimo on November 9, 2021

I’m trying to hack myself together an APA 7 compliant driver for the movie bibliography type which should, for example look like the following:

SurnameA, InitialA. & SurnameB, InitialB. (Executive Producers). (Year). Title [Format]. ProductionCompany.

I’ve so far written a driver using DeclareBibliographyDriver{movie}{...} which does the above, with the exception of using the correct plural form of "Executive Producer" when more than one producer is present. It should then show "Executive Producers" instead.

How do I check whether a BibLaTeX list contains more than one item? I have skipped through the BibLaTeX documentation but I’m unable to comprehend the vast size of it whilst staying focused on the task at hand. Search engines have not helped either as most search strings I have entered supplied me with questions regarding the "end-user" use of BibLaTeX and not the package-development/customization use.

Further, I’ve tried string comparing
printnames[apaauthor][-1]{author}
and
printnames[apaauthor][-value{listtotal}]{author}
which first of all sounds like a massive unnecessary hack and doesn’t seem to work either, even though it is showing up equal when having just one author, and different when there are more.

I’m looking for something of this sort

ifnumgreater{listcount{author}}{1}{%
  biblstring{execproducers}%
}{%
  biblstring{execproducer}%
}

but I can’t seem to find out how to access lists of fields outside of printnames[][]{}.

One Answer

Of course I had to find it shortly after posting the question. But here we go anyway. The documentation says as follows.

For every list, there is also a counter by the same name which holds the total number of items in the corresponding list. For example, the author counter holds the total number of items in the author list. These counters are similar to listtotal except that they may also be used independently of list formatting directives.

See: BibLaTeX Documentation, v3.14 (2019-12-01), p. 181, http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf

This means by using value{author} I could get the counter (and therefore the size) for the corresponding author list and I can use that compare it with 1. This is the resulting code, which looks very similar to what I have had in mind earlier:

ifnumgreater{value{author}}{1}{%
  ifbibstring{execproducers}{biblstring{execproducers}}{Executive Producers}%
}{%
  ifbibstring{execproducer}{biblstring{execproducer}}{Executive Producer}%
}%

Edit: In my use case it turns out nothing had to be hacked in the first place. See moewe's comment on the question.

Answered by Palpatimo on November 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP