1

I borrowed the following code from here.

\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}

It gives the following output:

enter image description here

Whereas I need it to be:

Lennon, John (1965). This is my article in this book. p. 65-87. In Paul McCartney, John Lennon, George Harrison & Richard Starkey (Eds.), A book with articles. Liverpool: Cavern Club.

Any help will be highly appreciated. Thanks

  • Your MWE ends quite abruptly. Is there anything missing? Is it any different from the code in the answer you linked to? – moewe Apr 9 '16 at 15:45
  • My bad @moewe, please see edits. – MYaseen208 Apr 9 '16 at 15:48
1

Since you are already using xpatch you can just go on to patch the drivers even further

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

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

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

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

\xpatchbibdriver{inproceedings}
  {\usebibmacro{chapter+pages}}
  {}
  {}{}

\xpatchbibdriver{inproceedings}
  {\usebibmacro{byauthor}}
  {\usebibmacro{byauthor}\newunit\newblock\usebibmacro{chapter+pages}}
  {}{}

you also need

\DeclareFieldFormat[article, unpublished]{pages}{#1}
\renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace\midsentence}}

for the page format instead of

\DeclareFieldFormat[article, incollection, unpublished]{pages}{#1}
\renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace}}
  • Thanks @moewe for your answer. Your answer needs some changes for required style. I need p. 65-87 rather than Pp. 65-87 and require (Eds.) rather than Ed. by. Any thoughts. Thanks – MYaseen208 Apr 9 '16 at 16:04
  • @MYaseen208 I already get "Eds." if I combine the code with what you have in your question already. You can use \renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace\midsentence}} to not capitalise the "pp." after the full stop. – moewe Apr 9 '16 at 16:07

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.