4

With the hook \labelnamepunct I managed to change a period to a colon after the first set of authors and the following title. But, as in the example below, if this is an inbook, for instance, there is a period used as delimiter between the second author-title combination.

Whats the hook for that punctuation point?

\documentclass[12pt,a4paper]{article}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,russian,german]{babel}  % last language in order will be active

\usepackage[backend=biber,
        bibstyle=authortitle,
        citestyle=authoryear-icomp,
        sorting=nyvt,   % n-umber, y-ear, v-olume, t-itle
        block=space,        % spacing between blocks: values: none (default), space, par, nbpar, ragged
        isbn=false,     % whether the fields isbn/issn/isrn
        url=false,      % affects entry types whose url information is optional
        doi=false,      % digital object identifier
        hyperref=false, % links between cites and bibliography
        ]{biblatex}

\renewcommand*{\labelnamepunct}{\addcolon\space}

\usepackage{filecontents}
\begin{filecontents}{onebook.bib}
@inbook{woodward82,
author={Woodward, James B.},
title={The Nose},
subtitle={},
bookauthor={Woodward, Andrea},
booktitle={The Symbolic Art of Gogol},
booksubtitle={Essays on His Short Fiction},
publisher={Slavica},
address={Columbus, Ohio},
year={1982},
pages={63--87},
}
\end{filecontents}
\addbibresource{onebook.bib}

\nocite{*}

\begin{document}

\printbibliography

\end{document}

The result looks like this (with a period between "... Andrea" AND "The Symbolic ...", where I want a colon to be):

result of code above

1
  • A quick fix is \renewbibmacro*{bybookauthor}{\ifnamesequal{author}{bookauthor}{}{\printnames{bookauthor}}\printunit{\labelnamepunct}} (looks especially messy here because line breaks were removed): this will look weird however, if there is no booktitle (which probably should not happen anyway).
    – moewe
    Apr 14 '14 at 16:46
2

There are at least to ways you can fix this.

The first is a re-definition of the bybookauthor macro that is used to print the bookauthor.

\renewbibmacro*{bybookauthor}{%
  \ifnamesequal{author}{bookauthor}
    {}
    {\printnames{bookauthor}}%
  \printunit{\labelnamepunct}}

This will insert \labelnamepunct into the punctuation buffer, where it will remain until needed. Because of that, this solution might have unwanted side-effects, for example if no author is present and if the in: bibmacro is redefined to not print anything.


So we better look for something else.

As it does so often, En­rico Gre­go­rio's xpatch package comes in very handy here.

Load it with \usepackage{xpatch}

We then patch the bibliography driver for @inbooks to use \labelnamepunct after the bookauthor field if it is present (unfortunately we need this test to prevent this solution to have the short come mentioned above).

\xpatchbibdriver{inbook}
  {\usebibmacro{bybookauthor}%
   \newunit\newblock}
  {\usebibmacro{bybookauthor}%
   \ifnameundef{bookauthor}
     {\newunit\newblock}
     {\setunit{\labelnamepunct}\newblock}}
  {}
  {\typeout{failed to patch bibdriver inbook to use \labelnamepunct}}

MWE

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xpatch}
\usepackage{babel} 

\usepackage[backend=biber,
        bibstyle=authortitle,
        citestyle=authoryear-icomp,
        ]{biblatex}

\renewcommand*{\labelnamepunct}{\addcolon\space}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inbook{woodward82,
author={Woodward, James B.},
title={The Nose},
bookauthor={Woodward, Andrea},
booktitle={The Symbolic Art of Gogol},
booksubtitle={Essays on His Short Fiction},
publisher={Slavica},
address={Columbus, Ohio},
year={1982},
pages={63--87},
}
\end{filecontents}
\addbibresource{\jobname.bib}


\xpatchbibdriver{inbook}
  {\usebibmacro{bybookauthor}%
   \newunit\newblock}
  {\usebibmacro{bybookauthor}%
   \ifnameundef{bookauthor}
     {\newunit\newblock}
     {\setunit{\labelnamepunct}\newblock}}
  {}
  {\typeout{failed to patch bibdriver inbook to use \labelnamepunct}}
\nocite{*}

\begin{document}

\printbibliography

\end{document}

enter image description here

2
  • Works like a charm! Thank You very much. Strikes me though, that there is no simple hook to that punctuation. Seems a little complicated, to simply alter some comma or period ...
    – fourreux
    Apr 15 '14 at 8:14
  • @fourreux Well, biblatex does specify some special delimiters. Most punctuation marks are however the standard \newunitpunct (as is the case here), those can at times be quite hard to modify because they are inserted at a very high level (the bibliography driver). Defining a dedicated command for every single punctuation goes a bit too far.
    – moewe
    Apr 15 '14 at 13:21

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.