[Tex/LaTex] format @book and @inbook entries in biblatex

biblatex

I've just turned to biblatex from bibtex. I am newbie to the biblatex. I am trying to figure out how to use the biblatex to meet my uni's bibliography requirements. My LaTex code is

\documentclass[12pt,a4paper, british]{article}
\usepackage{babel} % Switch to English style quotation mark, remember to add british to document option
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{xpatch}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{hyperref}
\hypersetup{unicode=true}

\usepackage{filecontents}
\begin{filecontents}{test.bib}
@Article{Vanschoenwinkel2016,
  author  = {Vanschoenwinkel, Janka and Mendelsohn, Robert and Van Passel,
             Steven},
  title   = {Do Western and Eastern Europe have the same agricultural climate
             response? Taking adaptive capacity into account},
  journal = {Global Environmental Change},
  year    = {2016},
  volume  = {41},
  number  = {7},
  pages   = {74-87}
}

@InBook{Adams1999,
  pages     = {1-18},
  title     = {Economic effects of climate change on US agriculture},
  publisher = {Cambridge University Press},
  year      = {1999},
  author    = {Adams, Ricahard M. and Mccarl, Bruce A. and Segerson, Kathleen and Rosenzweig, Cynthia and Bryant, Kelly J and Dixon, Bruce L and Conner, Richard and Evenson, Robert E and OJima, Dennis},
  editor    = {Mendelsohn, Robert and Neumann, James E.},
  type      = {Book Section},
  address   = {Cambridge, UK},
  isbn      = {0521607698},
  booktitle = {The Impact of Climate Change on the United States Economy},
}

@Book{Cline2007,
  title     = {Global Warming and Agriculture:Impacts Estimates by Contry},
  publisher = {Edward},
  year      = {2007},
  author    = {Cline, William R.},
  address   = {Washington DC},
  type      = {Book},
}

@TechReport{Dasgupta2007,
  author      = {Dasgupta, Susmita and Laplante, Benoit and Meisner, Craig and Wheeler, David and Yan, Jianping},
  title       = {The Impact of Sea Level Rise on Developing Countries: A Comparative Analysis},
  institution = {World Bank},
  year        = {2007},
  type        = {Report},
  number      = {World Bank Policy Research Working paper 4136},
  address     = {Washington DC},
}
\end{filecontents}

\usepackage[autostyle]{csquotes}

\usepackage[style=authoryear, giveninits=true,backend=biber, maxcitenames=3,%
            maxbibnames=9, sortcites, url=false, backref=false,]{biblatex}


\renewcommand{\labelnamepunct}{\addspace} % Replace dot with comma in reference after Author + Year

%\renewcommand*{\nameyeardelim}{\addcomma\space} %add comma between author and year in the intext-citation
\renewbibmacro{in:}{} % Suppress In: in the reference list

%use ":" after year in the intext citation
\renewcommand*{\postnotedelim}{\addcolon\space}
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}

%format page range of @article and @incollection follow this format: volume(number): page range.
\renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon\addspace}{\addcomma\addspace}}


\DeclareFieldFormat[article,incollection]{pages}{#1}

%format volume and number as follow: volume(number)

\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
%  \setunit*{\adddot}% DELETED
  \setunit*{\addnbspace}% NEW (optional); there's also \addnbthinspace
  \printfield{number}%
  \printunit{\addcomma\space}%
  \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}

% replace dot “.” by comma “,” after title in biblatex for @article
\xpatchbibdriver{article}
  {\usebibmacro{title}%
   \newunit}
  {\usebibmacro{title}%
   \printunit{\addcomma\space}}
  {}
  {}

  \addbibresource{test.bib}

  \begin{document}
  This is cited by @ariticle entry: \parencite{Vanschoenwinkel2016}. 
  This is cited by @inbook entry: (\cite{Adams1999}).
  This is cited by @book entry \cite{Cline2007}. 
  This is cited by @technicalreport: \parencite{Dasgupta2007}

  \printbibliography

  \end{document}

and the output is

enter image description here

Now, I want reformat for @inbook and @book with the format as following:

enter image description here

Any suggestion for me with above format?

Secondly, I would like to put the title of @Techreport between single quotes ' '

Best Answer

You can use biblatex-ext to move the editors around and simplify some of the code you have already.

\documentclass[12pt,a4paper, british]{article}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[autostyle]{csquotes}

\usepackage[style=ext-authoryear, giveninits=true, uniquename=init, backend=biber, maxcitenames=3,%
            maxbibnames=9, sortcites, url=false, isbn=false, backref=false,
            articlein=false, innamebeforetitle=true]{biblatex}

\usepackage{xpatch}

\usepackage{hyperref}
\hypersetup{unicode=true}

\DeclareDelimFormat[bib,biblist]{nametitledelim}{\addspace}

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

%\renewcommand*{\nameyeardelim}{\addcomma\space} %add comma between author and year in the intext-citation

\DeclareFieldFormat[report]{title}{\mkbibquote{#1}}
% replace dot “.” by comma “,” after title in biblatex for @article
\xpatchbibdriver{article}
  {\usebibmacro{title}%
   \newunit}
  {\usebibmacro{title}%
   \printunit{\addcomma\space}}
  {}
  {}

% remove chapter and pages
\xpatchbibdriver{incollection}
  {\usebibmacro{chapter+pages}}
  {}
  {}{}

% add them into the new position
\xpatchbibmacro{incollection:parent}
  {\usebibmacro{maintitle+booktitle}%
   \newunit\newblock}
  {\usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{chapter+pages}}
  {}{}


\renewcommand*{\intitlepunct}{\addspace}
\renewbibmacro*{in:}{%
  \setunit{\addcomma\space}%
  \printtext[emph]{%
    \bibstring{in}\intitlepunct}}

%format volume and number as follow: volume(number)
\renewcommand*{\volnumdelim}{\addnbspace}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}

%format page range of @article and @incollection follow this format: volume(number): page range.
\renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addcomma}\addspace}
\DeclareFieldFormat[article]{pages}{#1}

%use ":" after year in the intext citation
\renewcommand*{\postnotedelim}{\addcolon\space}
\DeclareFieldFormat{postnote}{\mknormrange{#1}}
\DeclareFieldFormat{multipostnote}{\mknormrange{#1}}

\usepackage{filecontents}
\begin{filecontents}{test.bib}
@Article{Vanschoenwinkel2016,
  author  = {Vanschoenwinkel, Janka and Mendelsohn, Robert and Van Passel,
             Steven},
  title   = {Do Western and Eastern Europe have the same agricultural climate
             response? Taking adaptive capacity into account},
  journal = {Global Environmental Change},
  year    = {2016},
  volume  = {41},
  number  = {7},
  pages   = {74-87}
}

@incollection{Adams1999,
  pages     = {1-18},
  title     = {Economic effects of climate change on US agriculture},
  publisher = {Cambridge University Press},
  year      = {1999},
  author    = {Adams, Ricahard M. and Mccarl, Bruce A. and Segerson, Kathleen and Rosenzweig, Cynthia and Bryant, Kelly J and Dixon, Bruce L and Conner, Richard and Evenson, Robert E and OJima, Dennis},
  editor    = {Mendelsohn, Robert and Neumann, James E.},
  type      = {Book Section},
  address   = {Cambridge, UK},
  isbn      = {0521607698},
  booktitle = {The Impact of Climate Change on the United States Economy},
}

@Book{Cline2007,
  title     = {Global Warming and Agriculture: Impacts Estimates by Contry},
  publisher = {Edward},
  year      = {2007},
  author    = {Cline, William R.},
  address   = {Washington DC},
  type      = {Book},
}

@TechReport{Dasgupta2007,
  author      = {Dasgupta, Susmita and Laplante, Benoit and Meisner, Craig and Wheeler, David and Yan, Jianping},
  title       = {The Impact of Sea Level Rise on Developing Countries: A Comparative Analysis},
  institution = {World Bank},
  year        = {2007},
  type        = {Report},
  number      = {World Bank Policy Research Working paper 4136},
  address     = {Washington DC},
}
\end{filecontents}
\addbibresource{test.bib}
\addbibresource{biblatex-examples.bib}
\nocite{westfahl:frontier,westfahl:space}
\begin{document}
  This is cited by @article entry: \parencite{Vanschoenwinkel2016}. 
  This is cited by @inbook entry: \parencite{Adams1999}.
  This is cited by @book entry \cite{Cline2007}. 
  This is cited by @technicalreport: \parencite{Dasgupta2007}

  \printbibliography
\end{document}

Should get you closer to what you want

enter image description here

  • biblatex-ext's innamebeforetitle option does the major work of moving the editors of @incollections.
  • xpatch is used to move the pages from after the publisher to after the book title.
  • @incollection instead of @inbook (as pointed out by Alan Munn); on the other hand a quick google search suggests that Mr Cline is the author of Cline2007 and so the "(ed.)" would not be appropriate. If he is indeed the editor and the thing turns out to be a collection, you should still the the correct results.
  • There were a few issues with punctuation that left me baffled and I could not figure out a way to algorithmically describe what I saw, so you may have to tweak that a bit.