1

Following suggestions by @moewe in the questions Enable "firstinits" in biblatex only for editors and Move names of editors followed by (Ed./Eds.) and a comma before title in biblatex, I have the code you see below. The problem here is that it prints a superfluous period after In when the collection has no editor, as seen in the Brekke entry.

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

\renewcommand*{\intitlepunct}{\space} % remove colon after "In:" for articles in books

%% Abbreviate first names of editors
\DeclareNameAlias{byeditor}{first-last-inits}
\DeclareNameFormat{first-last-inits}{%
  \usebibmacro{name:first-last}{#1}{#4}{#5}{#7}%
  \usebibmacro{name:andothers}}
%%

%% Move names of editors before the book title, and add "(Eds.)"
\usepackage{xpatch}
\DeclareNameAlias{editorin}{first-last-inits}
\newbibmacro*{byeditor:in}{%
  \ifnameundef{editor}
    {}
    {\printnames[editorin]{editor}%
     \addspace\bibsentence%
     \mkbibparens{\usebibmacro{editorstrg}}%
     \clearname{editor}%
     \printunit{\addcomma\space}}}
\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}}
  {}{}
%%

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@INCOLLECTION{brekke1881,
    AUTHOR = "K. Brekke",
    BOOKTITLE = "Indbydelsesskrift til den offentlige examen i juni og juli 1881 ved Aars og Voss's latin- og realskole",
    TITLE = "Bidrag til dansk-norskens lydl{\ae}re",
    YEAR = "1881",
    LOCATION = "Kristiania",
    PAGES = "1--66",
    PUBLISHER = "W. C. Fabritius"}
@INCOLLECTION{jahr2007,
    AUTHOR = "Ernst H{\aa}kon Jahr",
    BOOKTITLE = "{\AA} sj{\aa} samfunnet gjennom spr{\aa}ket",
    EDITOR = "Gunnstein Akselberg and Johan Myking",
    TITLE = "Bruk av omgrepa 'standardtalem{\aa}l', 'normalisering' og 'knot' for {\aa} skildre spr{\aa}ktilh{\o}va i Noreg i dag",
    YEAR = "2007",
    LOCATION = "Oslo",
    PAGES = "93--98",
    PUBLISHER = "Novus"}
\end{filecontents}
\addbibresource{\jobname.bib}

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

enter image description here

Another option is to follow the suggestion by @Guido (also to my question Move names of editors followed by (Ed./Eds.) and a comma before title in biblatex), and use the code below. The problem here is that the first names of the editors are not abbreviated (naturally enough, since I didn't ask for it in connection with that question).

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

\renewcommand*{\intitlepunct}{\space} % remove colon after "In:" for articles in books

%% Move names of editors before the book title, and add "(Eds.)"
\usepackage{xpatch}
\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}
  }
  {}%
}%%

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@INCOLLECTION{brekke1881,
    AUTHOR = "K. Brekke",
    BOOKTITLE = "Indbydelsesskrift til den offentlige examen i juni og juli 1881 ved Aars og Voss's latin- og realskole",
    TITLE = "Bidrag til dansk-norskens lydl{\ae}re",
    YEAR = "1881",
    LOCATION = "Kristiania",
    PAGES = "1--66",
    PUBLISHER = "W. C. Fabritius"}
@INCOLLECTION{jahr2007,
    AUTHOR = "Ernst H{\aa}kon Jahr",
    BOOKTITLE = "{\AA} sj{\aa} samfunnet gjennom spr{\aa}ket",
    EDITOR = "Gunnstein Akselberg and Johan Myking",
    TITLE = "Bruk av omgrepa 'standardtalem{\aa}l', 'normalisering' og 'knot' for {\aa} skildre spr{\aa}ktilh{\o}va i Noreg i dag",
    YEAR = "2007",
    LOCATION = "Oslo",
    PAGES = "93--98",
    PUBLISHER = "Novus"}
\end{filecontents}
\addbibresource{\jobname.bib}

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

enter image description here

So my question is: How can I modify the suggestion by @moewe to get rid of the unwanted period in case of missing editors, or how can I modify the suggestion by @Guido to abbreviate the first names of editors?

  • If you want to continue using my modifications, the problem you're facing seems to be at first glance of the same kind like When author field is empty, do not put colon after prenote in authortitle-comp. I'm guessing a \printunit for \intitlepunct in the in: bibmacro might help: \renewbibmacro*{in:}{\printtext{\bibstring{in}}\printunit{\intitlepunct}}. (I will investigate this properly tomorrow though.) – moewe Sep 2 '14 at 21:36
  • If you prefer to use Guido's solution, changing the line \DeclareNameAlias{editor}{first-last} to \DeclareNameAlias{editor}{first-last-inits} and copying \DeclareNameFormat{first-last-inits}{\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}\usebibmacro{name:andothers}} to that document should help (untested, but I should think it does the job). That is, you should be able to apply the answer to Enable “firstinits” in biblatex only for editors here as well, but the name format in question is editor, not byeditor (so we have to change that). – moewe Sep 2 '14 at 21:43
  • @moewe I followed your suggestion for modifying the suggestion by @Guido. It works, but now I notice that his code prints (ed.), with a lowercase e instead of (Ed.), when there is only one editor. I've put a comment about that to his answer. – Sverre Sep 3 '14 at 11:30
  • @moewe I've also noticed that @Guido's code inappropriately prints the title of the volume directly after (Eds.),, where rather the main title should be. I'll await the fix for your own code, then :). – Sverre Sep 3 '14 at 11:59
  • It seems my first guess about what to do to fix my modification was not at all far off, see my answer below. – moewe Sep 3 '14 at 14:18
1

To fix my code, you can modify the in: bibmacro to

\renewbibmacro*{in:}{%
  \printtext{\bibstring{in}}%
  \printunit{\intitlepunct}}

that is, we use \printunit (a explanation as to why we need to use \printunit can be found in this answer of mine).

MWE

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

\renewcommand*{\intitlepunct}{\space} % remove colon after "In:" for articles in books

%% Abbreviate first names of editors
\DeclareNameAlias{byeditor}{first-last-inits}
\DeclareNameFormat{first-last-inits}{%
  \usebibmacro{name:first-last}{#1}{#4}{#5}{#7}%
  \usebibmacro{name:andothers}}
%%

%% Move names of editors before the book title, and add "(Eds.)"
\usepackage{xpatch}
\DeclareNameAlias{editorin}{first-last-inits}
\newbibmacro*{byeditor:in}{%
  \ifnameundef{editor}
    {}
    {\printnames[editorin]{editor}%
     \addspace\bibsentence%
     \mkbibparens{\usebibmacro{editorstrg}}%
     \clearname{editor}%
     \printunit{\addcomma\space}}}
\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}}
  {}{}
%%

%% this is to fix the punctuation after "In"
\renewbibmacro*{in:}{%
  \printtext{\bibstring{in}}%
  \printunit{\intitlepunct}}
%%

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@INCOLLECTION{brekke1881,
    AUTHOR = "K. Brekke",
    BOOKTITLE = "Indbydelsesskrift til den offentlige examen i juni og juli 1881 ved Aars og Voss's latin- og realskole",
    TITLE = "Bidrag til dansk-norskens lydl{\ae}re",
    YEAR = "1881",
    LOCATION = "Kristiania",
    PAGES = "1--66",
    PUBLISHER = "W. C. Fabritius"}
@INCOLLECTION{jahr2007,
    AUTHOR = "Ernst H{\aa}kon Jahr",
    BOOKTITLE = "{\AA} sj{\aa} samfunnet gjennom spr{\aa}ket",
    EDITOR = "Gunnstein Akselberg and Johan Myking",
    TITLE = "Bruk av omgrepa 'standardtalem{\aa}l', 'normalisering' og 'knot' for {\aa} skildre spr{\aa}ktilh{\o}va i Noreg i dag",
    YEAR = "2007",
    LOCATION = "Oslo",
    PAGES = "93--98",
    PUBLISHER = "Novus"}
\end{filecontents*}
\addbibresource{\jobname.bib}

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

enter image description here

  • 1
    If you are using \renewbibmacro{in:}{\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}} (as you do here), the fix would obviously be \renewbibmacro{in:}{\ifentrytype{article}{}{\printtext{\bibstring{in}}\printunit{\intitlepunct}}}. – moewe Sep 3 '14 at 14:21
  • I was just about to ask that :) – Sverre Sep 3 '14 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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