[Tex/LaTex] Move names of editors followed by (Ed./Eds.) and a comma before title in biblatex

biblatex

For a stylesheet I am following, I need to move the names of the editors of a book before the book title. In biblatex, the default behavior is to print Ed. by followed by the names. A similar question has been asked before (Citing @inbook with biblatex: how to put authors/editors before book title?), but the only answer given differs in many respects from what I need, and I don't know how to modify it to suit my needs here.

In the MWE, the printed result is:

Lennon, John (1965). This is my article in this book. In A book with articles. Ed. by Paul McCartney, John Lennon, George Harrison & Richard Starkey. Liverpool: Cavern Club. 65-87.

Whereas I need it to be:

Lennon, John (1965). This is my article in this book. In Paul McCartney, John Lennon, George Harrison & Richard Starkey (Eds.), A book with articles. Liverpool: Cavern Club. 65-87.

Notice the uppercase E in Eds. (which should be Ed. in the case of a single editor) and the comma following it.

\documentclass{article}
\usepackage[style = authoryear-comp, maxnames = 99]{biblatex}

\renewcommand*{\finalnamedelim}{\addspace\&\space} % use '&' before last author in citations and bibliography
\renewcommand*{\intitlepunct}{\space} % remove colon after "In:" for articles in books
\DeclareFieldFormat[article, incollection, unpublished]{pages}{#1} % no word 'pages' for articles in the bibliography (print as is)
\DeclareFieldFormat[article, incollection, unpublished]{title}{#1} % no quotes for article titles (print as is)
\renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace}} % colon between volume and page ranges for journal articles, period plus space for articles in books

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@incollection{lennon1965,
    AUTHOR = "John Lennon",
    BOOKTITLE = "A book with articles",
    EDITOR = "Paul McCartney and John Lennon and George Harrison and Richard Starkey",
    TITLE = "This is my article in this book",
    YEAR = "1965",
    LOCATION = "Liverpool",
    PAGES = "65--87",
    PUBLISHER = "Cavern Club"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

enter image description here

Best Answer

Shameless plug: The styles of the biblatex-ext bundle have a slightly more sophisticated version of this implemented as an option. Load ext-<standardstyle>, e.g. ext-authoryear-comp and set the option innamebeforetitle to true.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber,
  style=ext-authoryear, innamebeforetitle=true]{biblatex}

\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DeclareDelimFormat{editortypedelim}{\addspace}

\DeclareFieldAlias{translatortype}{editortype}
\DeclareDelimAlias{translatortypedelim}{editortypedelim}

\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{sigfridsson,gaonkar:in,westfahl:space,vizedom:related}
\printbibliography
\end{document}

Gaonkar, Dilip Parameshwar (2001). ‘On Alternative Modernities’. In: Dilip Parameshwar Gaonkar (ed.). Alternative Modernities. Durham and London: Duke University Press, pp. 1–23. isbn: 0-822-32714-7.//Sigfridsson, Emma and Ulf Ryde (1998). ‘Comparison of methods for deriving atomic charges from the electrostatic potential and moments’. In: Journal of Computational Chemistry 19.4, pp. 377–395. doi: 10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P.//Vizedom, Monika B. and Gabrielle L. Caffee (trans.) (1960). The Rites of Passage. University of Chicago Press. Trans. of Arnold van Gennep. Les rites de passage. Paris: Nourry, 1909.//Westfahl, Gary (2000). ‘The True Frontier. Confronting and Avoiding the Realities of Space in American Science Fiction Films’. In: Gary Westfahl (ed.). Space and Beyond. The Frontier Theme in Science Fiction. Westport, Conn. and London: Greenwood, pp. 55–65.

This is really where biblatex is not that flexible.

We can use xpatch to patch the drivers for @inbook, @incollection and @inproceedings

\xpatchbibdriver{inbook}
  {\usebibmacro{in:}%
   \usebibmacro{bybookauthor}%
   \newunit\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {\usebibmacro{in:}%
   \usebibmacro{bybookauthor}%
   \newunit\newblock
   \usebibmacro{byeditor:in}%
   \newunit\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {}{}

\xpatchbibdriver{incollection}
  {\usebibmacro{in:}%
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {\usebibmacro{in:}%
   \usebibmacro{byeditor:in}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor}}
  {}{}

\xpatchbibdriver{inproceedings}
  {\usebibmacro{in:}%
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{event+venue+date}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {\usebibmacro{in:}%
   \usebibmacro{byeditor:in}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{event+venue+date}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {}{}

We also redefine byeditor:in

\newbibmacro*{byeditor:in}{%
  \ifnameundef{editor}
    {}
    {\printnames[editorin]{editor}%
     \addspace\bibsentence%
     \mkbibparens{\usebibmacro{editorstrg}}%
     \clearname{editor}%
     \printunit{\addcomma\space}}}

and a new name format

\DeclareNameAlias{editorin}{first-last}

MWE

\documentclass{article}
\usepackage{xpatch}
\usepackage[style = authoryear-comp, maxnames = 99]{biblatex}

\renewcommand*{\finalnamedelim}{\addspace\&\space}
\renewcommand*{\intitlepunct}{\space}
\DeclareFieldFormat[article, incollection, unpublished]{pages}{#1}
\DeclareFieldFormat[article, incollection, unpublished]{title}{#1}
\renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace}}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@incollection{lennon1965,
  author    = {John Lennon},
  booktitle = {A book with articles},
  editor    = {Paul McCartney and John Lennon and George Harrison and Richard Starkey},
  title     = {This is my article in this book},
  year      = {1965},
  location  = {Liverpool},
  pages     = {65--87},
  publisher = {Cavern Club},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\DeclareNameAlias{editorin}{first-last}

\newbibmacro*{byeditor:in}{%
  \ifnameundef{editor}
    {}
    {\printnames[editorin]{editor}%
     \addspace\bibsentence%
     \mkbibparens{\usebibmacro{editorstrg}}%
     \clearname{editor}%
     \printunit{\addcomma\space}}}

\xpatchbibdriver{inbook}
  {\usebibmacro{in:}%
   \usebibmacro{bybookauthor}%
   \newunit\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {\usebibmacro{in:}%
   \usebibmacro{bybookauthor}%
   \newunit\newblock
   \usebibmacro{byeditor:in}%
   \newunit\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {}{}

\xpatchbibdriver{incollection}
  {\usebibmacro{in:}%
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {\usebibmacro{in:}%
   \usebibmacro{byeditor:in}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor}}
  {}{}

\xpatchbibdriver{inproceedings}
  {\usebibmacro{in:}%
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{event+venue+date}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {\usebibmacro{in:}%
   \usebibmacro{byeditor:in}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{event+venue+date}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {}{}



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

enter image description here