# Distinguishing between a scientific editor and the editor of a text in biblatex

There is a distinction in French between the editor of a volume (for conference proceedings, etc.) and the editor of a text (for critical editions). In the first case, I want to obtain entries of the type:

Doe, John, dir. (1968). My Proceedings.
My Proceedings. Sous la dir. de John Doe. 1968.


In the second, I'd like:

Doe, John, éd. (1968). My critical edition.
My critical edition. Éd. par John Doe. 1968.


To distinguish between the two types of editors, I've amended the bibliography strings editor and byeditor, with a conditional check that tests the presence of a keyword in the entry to determine whether "éd." or "dir." should be used. This works fine when the entry is a "main" entry. For some reason, however, the test systematically fails when the entry is used through the "related" field.

Is there a way to fix this ?

Here is the code:

\documentclass{article}

\usepackage[french]{babel}
\usepackage[style=authoryear,sorting=none]{biblatex}
\usepackage{filecontents}

\begin{filecontents*}{biblio.bib}
editor = "Shastri, V.P.R.R.",
year = "1970",
title = "Kāvyādarśa of Daṇḍin",
publisher = "Bhandarkar Oriental Research Institute",
keywords = "primary",
}
title = "Kāvyādarśa",
keywords = "primary",
}
\end{filecontents*}

\DefineBibliographyStrings{french}{
editor = \ifkeyword{primary}{éd.}{dir.},
byeditor = \ifkeyword{primary}{Éd. par}{Sous la dir. de},
}

\begin{document}
\nocite{*}
\printbibliography
\end{document}


Output:

Shastri, V.P.R.R., éd. (1970). Kāvyādarśa of Daṇḍin. Poona : Bhandarkar
Oriental Research Institute.
Kāvyādarśa (p. d.). V.P.R.R. Shastri, dir. Kāvyādarśa of Daṇḍin. Poona :
Bhandarkar Oriental Research Institute, 1970.


The first entry is as expected. Expected output for the second entry:

Kāvyādarśa (p. d.). V.P.R.R. Shastri, éd. Kāvyādarśa of Daṇḍin. Poona :
Bhandarkar Oriental Research Institute, 1970.


Use the editortype field and define a new type of editor, scied say.

\documentclass{article}
\usepackage[french]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear,sorting=none]{biblatex}
\usepackage{filecontents}

\NewBibliographyString{scied}
\NewBibliographyString{scieds}
\NewBibliographyString{byscied}
\DefineBibliographyStrings{french}{
}

\begin{filecontents*}{\jobname.bib}
editor     = {Shastri, V.P.R.R.},
editortype = {scied},
year       = {1970},
title      = {Kāvyādarśa of Daṇḍin},
publisher  = {Bhandarkar Oriental Research Institute},
}
title    = {Kāvyādarśa},
keywords = {primary},
}
\end{filecontents*}

\begin{document}
\nocite{*}
\printbibliography
\end{document}


Your original approach did not work because of an unexpected behaviour with biblatex's keyword handling. Keywords are not handled like normal entry data. Instead each known keyword is assigned a list of entries with that keyword. (Normally data is a function of the entry, here the entries are a function of the keyword. That makes it easier to use keywords for filtering entries, because the entries don't have to be queried one by one to find out their keyword status.)

related entries are handled by copying the entire related entry to a temporary (dataonly) entry (that means that your .bbl file has three entries: Kavyadarsa, Kavyadarsa_ed and a temporary copy of Kavyadarsa_ed with a random string key, the copy is dataonly that means that it will not appear in any bibliography list on its own - but its data may be requested by other entries).

A quirk of the keyword handling is that dataonly entries are not added to the keyword list. And that means that the related entry does not test positively for its keyword.

https://github.com/plk/biblatex/pull/802 should hopefully fix that weird behaviour and hopefully does not break anything else.

• @michaelmeyer Glad I could help. There is definitely something fishy going on with \ifkeyword in the related loop, but I'm not sure if I'll be able to figure out what. Sep 21 '18 at 6:22
• I think I found the culprit. See the second part of the edited question. Sep 21 '18 at 11:49