2

A paper I'm writing requires me to use a custom citation style. The style's similar to the standard Harvard style, so I've decided to tweak the biblatex-bath style to my needs.

Among other things, when citing books, the publisher and location must be given as

Publisher; Location; Year.

I've found the standard publisher+location+date bibmacro, defined by biblatex in bbx/standard.bbx and decided to overwrite this, as follows:

\renewbibmacro*{publisher+location+date}{%
  \printlist{publisher}%
  \setunit*{\addsemicolon\space}%
  \printlist{location}%
  \setunit*{\addsemicolon\space}%
  \printfield{year}%
  \newunit%
}

Publisher and location come out fine with this, but the year is missing. Here is a complete MWE:

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8
\begin{filecontents*}{biblatextest2.bib}
@Book{Gali2015,
  author    = {Gal{\'\i}, Jordi},
  title     = {Monetary policy, inflation, and the business cycle: an introduction to the new Keynesian framework and its applications},
  year      = {2015},
  edition   = {2},
  publisher = {Princeton University Press},
  location  = {Princeton and Oxford},
}
\end{filecontents*}
\documentclass{article}
\usepackage[style=bath,sorting=ynt]{biblatex}
\assignrefcontextentries[]{*}
\renewbibmacro*{publisher+location+date}{%
  \printlist{publisher}%
  \setunit*{\addsemicolon\space}%
  \printlist{location}%
  \setunit*{\addsemicolon\space}%
  \printfield{year}%
  \newunit%
}
\addbibresource{biblatextest2.bib}
\begin{document}
    \noindent Here is a citation. Compare \cite[p.~123]{Gali2015}.
    \appendix
    \newrefcontext[sorting=nyt]%
    \printbibliography
\end{document}

This yields:

Example of missing year

As you can see, the year after the publisher and location is missing. Printing another field there, e.g. \printfield{title} rather than \printfield{year}, works; the issue is specific to \printfield{year}. (Actually, this isn't entirely true: \printfield{name} doesn't work either.)

As usual I'd appreciate any help. (Feel free to suggest a completely different solution as well; I'm not hung up on modifying this particular biblatex style, or modifying any specific style at all. If there is a better way of cooking up a custom biblatex style, I'm all ears.)

3
  • With biblatex one should never have to use \cite[p.~123]{Gali2015}, it is always preferred to write just \cite[123]{Gali2015} and let biblatex handle the "p."/"pp." business. In case of biblatex-bath you lose the space after "p."/"pp.", but you can get it back with \renewcommand*{\ppspace}{\addnbspace}
    – moewe
    Aug 23, 2019 at 6:01
  • 1
    \printfield{year} doesn't work since the mergedate settings of biblatex-bath issue \clearfield{year} near the beginning of the entry, if you try to print the field after that, you don't get to see anything. \printfield{name} does not work because name is not a known field in the data model, but if you wanted to print a name field like author you would have to use \printnames{author} for list fields like publisher you need \printlist{publisher} (as in the redefinition). ...
    – moewe
    Aug 23, 2019 at 6:05
  • ... For biblatex the date does not consist of only year, so \usebibmacro{date} as in David's answer or \printdate are strongly preferred over a simple \printfield{year} (indeed I would say that \printfield{year} should be deprecated).
    – moewe
    Aug 23, 2019 at 6:06

1 Answer 1

2

You can add the option mergedate=false to your biblatex options.

I'd probably be inclined to use \usebibmacro{date} instead of \printfield{year} to be more consistent with the default macro and allow for more flexibility.

\RequirePackage{filecontents}
\begin{filecontents*}{biblatextest2.bib}
@Book{Gali2015,
  author    = {Galí, Jordi},
  title     = {Monetary policy, inflation, and the business cycle: an introduction to the new Keynesian framework and its applications},
  year      = {2015},
  edition   = {2},
  publisher = {Princeton University Press},
  location  = {Princeton and Oxford},
}
\end{filecontents*}
\documentclass{article}
\usepackage[style=bath,mergedate=false,sorting=ynt]{biblatex}
\assignrefcontextentries[]{*}
\renewbibmacro*{publisher+location+date}{%
  \printlist{publisher}%
  \setunit*{\addsemicolon\space}%
  \printlist{location}%
  \setunit*{\addsemicolon\space}%
  \usebibmacro{date}%
  \newunit%
}
\addbibresource{biblatextest2.bib}
\begin{document}
    \noindent Here is a citation. Compare \cite[p.~123]{Gali2015}.
    \appendix
    \newrefcontext[sorting=nyt]%
    \printbibliography
\end{document}

MWE output

3
  • Excellent. Thanks!
    – chsk
    Aug 22, 2019 at 13:15
  • @David Purton: what would be the option, if I wanted to modify the same bibmacro, but for the APA style? I used this solution but mergedate is not defined..............
    – Euclides
    Nov 14, 2021 at 8:34
  • @Euclides, you should ask a new question with an appropriate minimal worked example. You could link to this question. However, APA style is tightly tied to official SPA style and not always easy to modify. Nov 14, 2021 at 10:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .