2

As per the answer to another question I have removed the punctuation at the end of book titles like this:

\DeclareFieldFormat[article]{title}{#1\addcomma}
\DeclareFieldFormat[book]{title}{\textit{#1}\nopunct}

This also removes the comma between book titles and the edition, but I need the comma between the book title and the edition. Is there a way to reinstate the comma in that specific case?

MWE:

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@book{crut1997,
    Address = {Cambridge},
    Author = {Alan Cruttenden},
    Edition = {2},
    Publisher = {Cambridge University Press},
    Title = {Intonation},
    Year = 1997}
\end{filecontents}
\DeclareFieldFormat[article]{title}{#1\addcomma}
\DeclareFieldFormat[book]{title}{\textit{#1}\nopunct}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
  • Mhhh, since you seem to implement a fully fledged style you may want to think about modifying the drivers directly. On this site you will often get clever answers that try not to modify the drivers because that often means lots of code for a fairly minute change. But if you need to do many changes they mount up and at some point changing the driver might be the cleverer idea. – moewe Jul 22 '16 at 14:17
  • More to the point: Where exactly do you need the space instead of point? Before the publisher, the note, the series and number? After the edition? – moewe Jul 22 '16 at 14:18
1

To me it seems you just need to suppress punctuation before the pair of brackets around publisher, location and date. That can be done with

\renewbibmacro*{publisher+location+date}{%
  \setunit{\addspace}%
  \printtext[parens]{%
    \printlist{location}%
    \iflistundef{publisher}
      {\setunit*{\addcomma\space}}
      {\setunit*{\addcolon\space}}%
    \printlist{publisher}%
    \setunit*{\addcomma\space}%
    \usebibmacro{date}}%
    \newunit}

Where \setunit{\addspace} and \printtext[parens]{ are the additions to the standard version of the macro.

Because of the way biblatex's punctuation tracker works the \setunit{\addspace} overrides any other punctuation before it and we are left with a nice single spaces before the brackets.

  • Yes, that seems to do it. In response to one of your other comments, after spending some time (including on here) trying to tweak things to get the style I need, I am starting to think that coming up with a proper, full-fledged style will be better than a patchwork approach. Your code will be useful in that. – Gareth Walker Jul 23 '16 at 10:17
1

I moved the bibliography info to a separate file. I edited my answer. Basically added a test to see if edition field is defined. Based on that we use either a period or a comma. Now it works with and without edition field.

PS. Of course it might fail if you add some other fields between title and edition. And this change affects book, collecton and proceedings types. It is possible to restrict only to books.

\documentclass{article}
\usepackage[style=authoryear,backend=biber]{biblatex}
\addbibresource{input.bib}
\DeclareFieldFormat[article]{title}{#1\addcomma}

\renewbibmacro*{maintitle+title}{%
  \iffieldsequal{maintitle}{title}
    {\clearfield{maintitle}%
     \clearfield{mainsubtitle}%
     \clearfield{maintitleaddon}}
    {\iffieldundef{maintitle}
       {}
       {\usebibmacro{maintitle}%
    \newunit\newblock
    \iffieldundef{volume}
      {}
      {\printfield{volume}%
           \printfield{part}%
           \setunit{\addcolon\space}}}}%
  \usebibmacro{title}%
  \iffieldundef{edition}% <----- Added this test and next 2 lines
    {\nopunct}%
    {\addcomma}%
  \newunit}


\begin{document}
\cite{crut1997}
\printbibliography
\end{document}
  • That would add a comma to the end of all book titles, though: I only need the comma if the title is followed by an edition number. – Gareth Walker Jul 22 '16 at 9:12
  • I edited my original answer. Can you test if it works now properly? – Paapaa Jul 22 '16 at 9:42
  • Great. That very nearly works - it puts a period after the title if there is no edition, but there shouldn't be one. Changing \addperiod to \nopunct seems to fix that. – Gareth Walker Jul 22 '16 at 9:56
  • Getting closer :) Now there is no punctuation if edition is not defined. And there is a comma if edition is defined. (But there is a dot after: "2nd ed." Maybe that is ok? – Paapaa Jul 22 '16 at 10:03
  • 1
    No, that needs to go as well. I seem to be able to get that effect with \DefineBibliographyStrings{english}{edition={edn\nopunct}} so all is good now – Gareth Walker Jul 22 '16 at 10:15

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.