[Tex/LaTex] Customizing biblatex styles using \usebibmacro

biblatex

I am currently trying to adapt a biblatex style to my needs. I was able to do most tweaks by reading all the answers to similar demands here (such as Suppress "In:" biblatex or Guidelines for customizing biblatex styles).

However, despite all my efforts, I have not been successful in my attempts to work with \usebibmacro.

I had started with the authoryear style, and I want to arrive at the citation style for the Cambridge Review of International Affairs.

I have been able to change everything, except for the @incollection entries.

This is their example:

Cottier, Thomas (2001) 'Risk management experience in WTO dispute
settlement' in David Robertson and Aynsley J Kellow (eds)
Globalization and the environment: risk assessment and the WTO (Cheltenham, United Kingdom: Edward Elgar Publishing), 41-62

And this is what I've got so far:

Cottier, Thomas (2001) ‘Risk management experience in WTO dispute
settlement’. In: ed. by David Robertson and Aynsley J Kellow.
Globalization and the environment: risk assessment and the WTO.
Cheltenham, United Kingdom: Edward Elgar Publishing, 41–62.

So the differences I have not been able to address are:

  1. Remove the punctuation after the title, the editors and the collection title.
  2. Remove capital letter from "In:" as well as the ':'.
  3. Move the 'ed. by' and change it to '(eds)'.
  4. Put the publisher in brackets.

Actually, I prefer the punctuation at the end of each bibliography ending, but just in case: how to remove it?

I know that the key to this lies in the \renewcommand and \usebibmacro, but I just cannot make it work. How can I change these parameters per reference type?

Thank you very much in advance for showing me where I have to move from here.

PS: I just realized that I have to change some dots to commas as well in for other reference types, but I guess that won't be a problem once I understood how to make these changes here.

EDIT: attempt at MWE

paper.tex:

\documentclass[a4paper,oneside,12pt,notitlepage]{article}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage[style=authoryear-comp,maxnames=2,maxbibnames=4,bibstyle=mybibstyle,autocite=inline,useprefix=true,backend=bibtex]{biblatex}
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{pages}{#1}
\bibliography{lit} 

\begin{document}

This is just a test sentence to show you how I cite within my text. \autocite[]{cottier2001}

\newpage

%%%%%%%%%%%%%% BIBLIOGRAPHY
\renewcommand*{\bibfont}{\small}
\printbibliography[title=Bibliography]

\end{document}

lit.bib:

@incollection{cottier2001,
  title={Risk management experience in WTO dispute settlement},
  author={Cottier, Thomas},
  booktitle={Globalization and the environment: risk assessment and
the WTO},
  pages={41--62},
  year={2001},
  publisher={Cheltenham, United Kingdom: Edward Elgar Publishing},
  editor={Robertson, David and Kellow, Aynsley J}
}

mybibstyle.bbx (adapted from the above-mentioned thread):

\ProvidesFile{mybibstyle.bbx}
\RequireBibliographyStyle{standard}
\RequireBibliographyStyle{authoryear-comp} 
\DeclareFieldFormat[article,incollection,unpublished]{title}{ `#1'}%
\DeclareBibliographyDriver{incollection}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{in:}%
  \usebibmacro{byeditor+others}%
  \newunit\newblock 
 \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
  \usebibmacro{related}%
  \usebibmacro{finentry}}

I don't have anything left from my tinkering with \usebibmacro 😉

Best Answer

Typically a driver contains the instructions about the order of the elements in a bibliography entry. The instructions for how to print the various elements are encoded in \usebibmacro commands. To change the content of a \usebibmacro{<name> you can use the command \renewbibmacro{<name>}{<instructions>}. In your case you have to modify in:, publisher+location+date and byeditor+other. For the last you have to modify how the editor field is rendered. The rendering of names can be modified using \DeclareNameFormat{<name>}. The changes for the style you want to achieve can be done by something like:

\renewbibmacro{in:}{\printtext{in}}

\DeclareNameFormat{editor}{%
  \ifblank{#3}{}{#3\space}%
  \ifblank{#5}{}{#5\space}#1%
  \ifthenelse{\value{listcount}<\value{liststop}}
    {\addcomma\space}%
    {\space\ifthenelse{\value{listcount}>1}
      {(\bibstring{editors})}
      {(\bibstring{editor})}}%
}
\renewbibmacro{byeditor+others}{
  \ifnameundef{editor}
    {}
    {\printnames{editor}}
}

\renewbibmacro{publisher+location+date}{
  \iflistundef{publisher}
    {}
    {\printtext{(}%
     \printlist{publisher}%
      \iflistundef{location}
        {}
        {\printlist{location}}%
        \printtext{)}%
    }
}

To change the period at the end of the various element use

\renewcommand{\newunitpunct}{\addspace}

By the way it is better to use \addbibresource{lit.bib} instead of \bibliography{lit}

Related Question