Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

up vote 1 down vote accepted

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

share|improve this answer
    
As with Guido's example, your example flips the order of the names of the first editor from first-last to last-first. Can that be avoided? Also, the abbreviation for editor (Eds.) should be in parentheses with an uppercase E. And there should be a comma following it, i.e. (Eds.),. –  Sverre Apr 27 at 13:20
    
@Sverre Sure! Have a look at the edit. I'm afraid doing things like this are somewhat hard to achieve in biblatex, it might warrant a new style. –  moewe Apr 27 at 13:25
    
And what about (Eds.), instead of (eds.).? :) –  Sverre Apr 27 at 13:31
    
@Sverre See the edit. (I suspect you already have code to add the parentheses.) –  moewe Apr 27 at 13:38
1  
@Sverre Try again (I have re-edited the answer). –  moewe Apr 27 at 13:47

A possibility is to abuse the biblatex in: macro to to format and print the information as desired.

\xpatchbibmacro{editorstrg}{\bibstring}{\bibcpstring}{}{}

\renewbibmacro*{in:}{
  \ifentrytype{incollection}{%
  \DeclareNameAlias{editor}{first-last}
  \printtext{In}
  \ifnameundef{editor}
    {}
    {\printnames{editor}%
     \addspace 
     \mkbibparens{\usebibmacro{editorstrg}}
     \setunit{\addcomma\addspace}% 
    }%
  \printfield[book]{booktitle}
  \clearfield{booktitle}
  \clearname{editor}
  }
  {}%
}

In this case the "simple" in: contains the directives to print the editors and the book title.

The tricks are: (1) use a guard, \ifentrytype{in collection}, to restrict the modification to the specific entrytype; (2) delete the content of the fields booktitle and editor, thus they are no longer a available in the rest of directive in the driver for in collection, and (3) define a new directive to switch last name and first name for the editors: this can be specifying that editor is an "alias" for the predefined name format first-last, i.e., \DeclareNameAlias{editor}{first-last}.

Notice that the excellent and convenient xpatch package (i.e., include \usepackage{patch}) is used to modify how the biblatex string editor(s) is printed.

Here is the outcome:

enter image description here

share|improve this answer
    
In your example, the order of the names of the first editor is flipped from first-last to last-first. –  Sverre Apr 27 at 12:01
    
I overlooked that issue. I just changed it. –  Guido Apr 27 at 23:52

Guidos way, or - without another package, but with a lot of more code lines - you can change the bibliography-driver for @incollection from standard.bbx, to display the data in your wanted order; change the byeditor+others-macro from biblatex.def to put parencites around the editor data; and change the editorstrg from biblatex.def to use the capitalized version \bibcpstring instead of \bibstring.

\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}
\renewbibmacro*{editorstrg}{%from biblatex.def
  \printtext[editortype]{%
    \iffieldundef{editortype}
      {\ifboolexpr{
         test {\ifnumgreater{\value{editor}}{1}}
         or
         test {\ifandothers{editor}}
       }
         {\bibcpstring{editors}}%changed
         {\bibcpstring{editor}}}%changed
      {\ifbibxstring{\thefield{editortype}}
         {\ifboolexpr{
            test {\ifnumgreater{\value{editor}}{1}}
            or
            test {\ifandothers{editor}}
          }
            {\bibcpstring{\thefield{editortype}s}}%changed
            {\bibcpstring{\thefield{editortype}}}}%changed
         {\thefield{editortype}}}}}


\renewbibmacro*{byeditor+others}{%from biblatex.def
  \ifnameundef{editor}
    {}
    {\printnames[byeditor]{editor}%
     \addspace%added
     \mkbibparens{\usebibmacro{editorstrg}}%added
     \clearname{editor}%
     \newunit}%
  \usebibmacro{byeditorx}%
  \usebibmacro{bytranslator+others}}

\DeclareBibliographyDriver{incollection}{%from standard.bbx
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{in:}%changed
  \usebibmacro{byeditor+others}%changed
  \setunit{\addcomma\addspace}\newblock%changed
  \usebibmacro{maintitle+booktitle}%
  \newunit\newblock
  \printfield{edition}%
  \newunit
  \iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{publisher+location+date}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
  \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}}

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



Output:

Output

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.