8

How can I add one pair of parentheses around multiple fields in a bibliography?

The standard authoryear format looks like this:

Leo Frobenius (1935). Paideuma. Umrisse einer Kultur- und Seelenlehre. Vol. 3. Some Series. Düsseldorf: Diederichs

My goal is:

Leo Frobenius (1935): Paideuma. Umrisse einer Kultur- und Seelenlehre (Some Series, Vol. 3). Düsseldorf: Diederichs

Replacing the dot with a colon is no problem.

\documentclass{scrartcl}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{Frobenius1935,
  title = {Paideuma. Umrisse einer Kultur- und Seelenlehre},
  publisher = {Diederichs},
  year = {1935},
  author = {Leo Frobenius},
  series = {Some Series},
  volume = {3},
  address = {Düsseldorf},
}
\end{filecontents}
\usepackage[backend=bibtex,style=authoryear]{biblatex}
\addbibresource{\jobname.bib}
\renewcommand*{\labelnamepunct}{\addcolon\addspace}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
  • 1
    Hello Downvoter, please explain why as the OP is a new user ?. We are TeX.SX. I derive Patience from TeX. Don't scare new users. – texenthusiast Mar 1 '13 at 23:50
  • 1
    Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. may be the Downvoters would be expecting you to do present your contribution of work on the biblatex example. – texenthusiast Mar 1 '13 at 23:51
  • Small point: don't use volume = 3 but number = 3 for the third volume of a series. 'Volume' is used in relation to the (main) title. – jon Mar 2 '13 at 2:33
6

The order of the bibliography fields are declared for every bibliography driver by the command DeclareBibliographyDriver{<eg. book>}. For the example book I want to show a part of the code where volume + number + series are used:

\DeclareBibliographyDriver{book}{%
  ....
  \iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}%
  ....
}

To setup parens around multiple fields you have to options:

  1. redefinition of every bibliography driver
  2. using the package regexpatch to patch the bibliography driver

Both options using the method that the input strings are executed inside the command \printtext[parens]{...} to get parens. In the MWE below I am using the second method:

% arara: pdflatex
% arara: biber
% arara: pdflatex
% arara: pdflatex
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{Frobenius1935,
  title = {Paideuma. Umrisse einer Kultur- und Seelenlehre},
  publisher = {Diederichs},
  year = {1935},
  author = {Leo Frobenius},
  address = {Düsseldorf},
}
  series = {Some Series},
  volume = {3},
\end{filecontents}
\usepackage[style=authoryear]{biblatex}
\addbibresource{\jobname.bib}
\renewcommand*{\labelnamepunct}{\addcolon\addspace}


\usepackage{regexpatch}
% Print ISSN
\xpatchbibdriver{book}
  {\iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}%
  }%
  {%
  \ifboolexpr{%
      test {\iffieldundef{volume}} and 
      test {\iffieldundef{part}} and 
      test {\iffieldundef{series}} and
      test {\iffieldundef{number}} 
  }{}{%
   \printtext[parens]{%
     \iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}%
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}}%
 }%
 }
  {\typeout{******WORKS******}}{\typeout{*******FAILS********}}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

enter image description here

BTW: Why are you using bibtex instead of the advantages of biber?

  • Is it possible to omit the set of empty parentheses if there is a book without series and volume? – Oliver Mar 2 '13 at 18:07
  • Sure? ;) I my opinion the boolean expr should be evaluated to true if all fields are undef – Oliver Mar 2 '13 at 19:41
  • if one of the four fields is undef the true part will be executed cause of the or catenations. or am I wrong? – Oliver Mar 2 '13 at 20:01
  • @user1494845: I am wrong ;-) -- I need ands -- To avoid extended comments I removed my. – Marco Daniel Mar 2 '13 at 20:02

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.