[Tex/LaTex] Adjusting biblatex bibliography style

babelbiblatex

I previously asked a question about adjusting the style of natbib 1, but gave up an switched to biblatex.

I am working on my bachelor's thesis and need help adapting the bibliography and citation style to match my schools requirements. Below is what I've got so far:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[norsk]{babel}


\usepackage[style=authoryear-comp,firstinits=true,backend=biber,maxcitenames=3,citetracker=true,maxbibnames=99,dashed=false]{biblatex}

\DeclareNameAlias{sortname}{last-first}
\renewcommand*{\nameyeardelim}{\addcomma\space}

\addbibresource{bachelor.bib}
\usepackage{breakurl}

%from https://tex.stackexchange.com/questions/48846/biblatex-et-al-beginning-from-second-citation
\usepackage{xpatch}

\AtEveryCitekey{\ifciteseen{}{\clearfield{namehash}}}

\xpatchbibmacro{cite}
  {\printnames{labelname}}
  {\ifciteseen
     {\printnames{labelname}}
     {\printnames[][1-99]{labelname}}}
  {}
  {}

\xpatchbibmacro{textcite}
  {\printnames{labelname}}
  {\ifciteseen
     {\printnames{labelname}}
     {\printnames[][1-99]{labelname}}}
  {}
  {}

\begin{document}
\printbibliography[title=Kilder]
\addcontentsline{toc}{chapter}{Kilder}
\end{document}

Using the above @book is showing correctly both in citations and in the bibliography if there's a single author. With multiple authors there is "og" (Norwegian translation of "and") between the two last authors. I would like to change this to &.

@inbook needs some modifications to the bibliography. Currently it's:

Author(s) (year). Title. I: booktitle. Red. av editor(s). Address: Publisher, s. pagefrom-pageto

I need this to be:

Author(s) (year). Title. I editor(s) (red.), booktitle (s. pagefrom-pageto). Address: Publisher

In the above the "I" is Norwegian translation of "In" and "mfl." is Norwegian translation of "et al.".

Also I can not figure out how to prevent that "et al" is being translated to "mfl.". I guess I would need to do something like:

\addto\captionsnorsk{%
  \renewcommand{\something}%
    {et al}%
}

but I can't figure out what to replace something with.

Thanks.

Best Answer

Well, there are quite some modifications to be done here.

To change the translation of "and others" from "med flere" to "et al.", we define.

\DefineBibliographyStrings{norsk}{%
  andothers        = {et\addabbrvspace al\adddot},
  andmore          = {et\addabbrvspace al\adddot},
}

You can find a list of all the bibstrings (the localisation kyes) in the biblatex documentation in §4.9.2 Localization Keys. For more on this topic, §4.9 Localization Modules is worth a read.

To change the last name delimiter from "og" ("and") to "&", we redefine

\renewcommand*{\finalnamedelim}{%
  %\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}% there really should be no funny Oxford comma business here
  \addspace\&\space}

Note that the second line that normally deals with Oxford commas is uncommented here, but that does not concern Norwegian as that does not use the Oxford comma anyway.

Now, over to @inbook and @incollection.

First, the easy part, to get rid of the colon after "I:" ("In:"), define

\renewcommand*{\intitlepunct}{\space}

This will get rid of the colon for all entry types, however; if you prefer to keep it for all the other entry types (Why would you want to do that? It would be pretty pretty inconsistent.), try

\newbibmacro*{in:}{%
  \printtext{%
    \bibstring{in}%
    \ifboolexpr{test {\ifentrytype{inbook}} or test {\ifentrytype{incollection}}}
      {\addspace}%
      {\intitlepunct}}}

The biggest problem is reordering the output. One could copy and paste the whole driver to the document and modify it, but since you use xpatch anyway, why not use that?

% This gets rid of page numbers, don't worry they will be re-added later
\xpatchbibdriver{inbook}
  {\newunit\newblock
   \usebibmacro{chapter+pages}}
  {}
  {}
  {}

\xpatchbibdriver{incollection}
  {\newunit\newblock
   \usebibmacro{chapter+pages}}
  {}
  {}
  {}

\xpatchbibdriver{incollection}
  {\usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\renewbibmacro*{date+extrayear}{}%
   \usebibmacro{editor+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \ifboolexpr{not (test {\iffieldundef{chapter}} and test {\iffieldundef{pages}})}
     {\nopunct\printtext[parens]{\usebibmacro{chapter+pages}}}%
     {}%
   \newunit\newblock
  }%
  {}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{editor+others} in BibliographyDriver{incollection}}}%


\xpatchbibdriver{inbook}
  {\usebibmacro{bybookauthor}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\renewbibmacro*{date+extrayear}{}%
   \usebibmacro{editor+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
   \newunit\newblock
   \ifboolexpr{not (test {\iffieldundef{chapter}} and test {\iffieldundef{pages}})}
     {\nopunct\printtext[parens]{\usebibmacro{chapter+pages}}}%
     {}%
  }%
  {}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{editor+others} in BibliographyDriver{inbook}}}%

We move the editor macro before the title, but use the editor not byeditor macros.

To get the string "editor" in parentheses and to get rid of the comma preceding it, use

\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\xpatchbibmacro{bbx:editor}%
  {\setunit{\addcomma\space}%
  }
  {\setunit{\addspace}%
  }
  {}
  {\typeout{failed to patch bibmacro{bbx:editor}}}

The quite long and not so M WE

\documentclass[norsk,12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{lmodern}
\usepackage[style=authoryear-comp, firstinits=true, backend=biber, maxcitenames=3, citetracker=true, maxbibnames=99, dashed=false,texencoding=ascii]{biblatex}

\DeclareNameAlias{sortname}{last-first}
\renewcommand*{\nameyeardelim}{\addcomma\space}

\addbibresource{biblatex-examples.bib}
\usepackage{breakurl}

\DefineBibliographyStrings{norsk}{%
  andothers        = {et\addabbrvspace al\adddot},
  andmore          = {et\addabbrvspace al\adddot},
}

%from http://tex.stackexchange.com/questions/48846/biblatex-et-al-beginning-from-second-citation
\usepackage{xpatch}

\AtEveryCitekey{\ifciteseen{}{\clearfield{namehash}}}

\xpatchbibmacro{cite}
  {\printnames{labelname}}
  {\ifciteseen
     {\printnames{labelname}}
     {\printnames[][1-999]{labelname}}}
  {}
  {}

\xpatchbibmacro{textcite}
  {\printnames{labelname}}
  {\ifciteseen
     {\printnames{labelname}}
     {\printnames[][1-999]{labelname}}}
  {}
  {}

\renewcommand*{\finalnamedelim}{%
  %\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}% there really should be no funny Oxford comma business here
  \addspace\&\space}

%\renewcommand*{\intitlepunct}{\space}

\newbibmacro*{in:}{%
  \printtext{%
    \bibstring{in}%
    \ifboolexpr{test {\ifentrytype{inbook}} or test {\ifentrytype{incollection}}}
      {\addspace}%
      {\intitlepunct}}}

\xpatchbibdriver{inbook}
  {\newunit\newblock
   \usebibmacro{chapter+pages}}
  {}
  {}
  {}

\xpatchbibdriver{incollection}
  {\newunit\newblock
   \usebibmacro{chapter+pages}}
  {}
  {}
  {}

\xpatchbibdriver{incollection}
  {\usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\renewbibmacro*{date+extrayear}{}%
   \usebibmacro{editor+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \ifboolexpr{not (test {\iffieldundef{chapter}} and test {\iffieldundef{pages}})}
     {\nopunct\printtext[parens]{\usebibmacro{chapter+pages}}}%
     {}%
   \newunit\newblock
  }%
  {}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{editor+others} in BibliographyDriver{incollection}}}%


\xpatchbibdriver{inbook}
  {\usebibmacro{bybookauthor}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\renewbibmacro*{date+extrayear}{}%
   \usebibmacro{byeditor+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
   \newunit\newblock
   \ifboolexpr{not (test {\iffieldundef{chapter}} and test {\iffieldundef{pages}})}
     {\nopunct\printtext[parens]{\usebibmacro{chapter+pages}}}%
     {}%
  }%
  {}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{editor+others} in BibliographyDriver{inbook}}}%

\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\xpatchbibmacro{bbx:editor}%
  {\setunit{\addcomma\space}%
  }
  {\setunit{\addspace}%
  }
  {}
  {\typeout{failed to patch bibmacro{bbx:editor}}}

\begin{document}
  \cite{aksin} again \cite{aksin}.
  \nocite{wilde,kant:kpv,hyman,pines,baez/article}
  \printbibliography[title=Kilder]
\end{document}

yields

enter image description here

Related Question