Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Suppose I've just made the switch to biblatex. I have chosen one of the built-in styles (numeric, alphabetic, authoryear, authortitle, verbose) or of the custom styles available at CTAN, and I've figured out how to sort/compress citations. The bibliography and the in-text-citations look approximately like I want, but need to be tweaked. I've taken a look at the biblatex documentation for advice, but it is somewhat daunting. How do I get started? To add some focus, customization in the following areas would come in handy:

  • Suppressing of specific BibTeX fields (e.g., publisher);

  • Formatting of fields for specific entry types (e.g., titles of articles not inside quotation marks);

  • Formatting of citation postnotes (i.e., getting rid of "p."/"pp.");

  • Spacing and punctuation in the bibliography (e.g., commas instead of periods as unit separators);

  • Order of first names and last names of authors/editors in the bibliography;

  • Order of certain fields in the bibliography (e.g., swapping location and publisher);

  • Language-specific terms (e.g., replacing "References" with "Works Cited").

Finally, assuming that I'll want to use my style adjustments in a multitude of documents: Where do I put the relevant macro stuff?

share|improve this question

1 Answer 1

up vote 271 down vote accepted
+500

I'll start with a few words of caution. First, while most of the following tips should also be applicable for custom CTAN styles, my focus is on the standard styles that ship with biblatex. Second, these guidelines are about easy-to-medium modifications; for the trickier stuff look at some of the other questions at TeX.sx (or ask your own one).

Introduction

As newer versions of biblatex were released, customizations that formerly required redefining internal macros (or at least changing settings mid-document) have become package options settable in the preamble. Here's how to do some often-requested tweaks:

  • firstinits=true will render all first and middle names as initials. (Introduced in v0.8)

  • isbn=false will suppress any isbn fields included in your .bib file. (It works the same way for url, doi and eprint.) (Introduced in v0.9)

  • dashed=false (available for the authoryear, authortitle, and verbose bibliography styles) will print recurring author/editor names instead of replacing them by a dash. (Introduced in v0.9)

  • maxbibnames=99 will print complete name lists for multi-author/editor works in the bibliography while truncating those lists for in-text citations. (Introduced in v1.1)

Now, where to put actual customization macros? As you don't want to create a full-fledged custom style, I recommend to use the configuration file biblatex.cfg. This file, if available, is read by biblatex immediately after a style has been loaded. The (empty) original is located at /tex/latex/biblatex in your TeX distribution directory; put a copy in the analogous location of your local TEXMF tree (and update your file database) and fill it with the redefinitions I'm (finally!) going to talk about.

Addendum: You may also specify preamble options (but not bibliography/citation styles or compatibility modules) via the configuration file. Put the following into biblatex.cfg:

\ExecuteBibliographyOptions{<preamble options>}

Suppressing of specific BibTeX fields

For isbn & friends, see the introduction. Generally, biblatex differentiates between name lists, literal lists, and other fields, and different macros have to be applied to suppress those field categories. Should you, e.g., want to remove the translator, publisher, and pagetotal fields from the bibliography, add the following to your local copy of biblatex.cfg:

\AtEveryBibitem{%
  \clearname{translator}%
  \clearlist{publisher}%
  \clearfield{pagetotal}%
}

See sections 2.2.1 and 2.2.2 of the biblatex manual for a complete list of fields and the categories they belong to. To suppress specific fields for in-text-citations (e.g., when using the verbose style), use \AtEveryCitekey instead of \AtEveryBibitem.

Formatting of fields (and of citation postnotes)

As a general rule, inspect the "Field Formats" section of the file biblatex.def (location: see above). With regard to the example given in your question, look for the following:

\DeclareFieldFormat
  [article,inbook,incollection,inproceedings,patent,thesis,unpublished]
  {title}{\mkbibquote{#1\isdot}}

This means that for @article (and a bunch of other entry types), the title field is put inside quotation marks. (#1 stands for the value of the field, \isdot prevents double punctuation.) In your local biblatex.cfg, change the last part from {\mkbibquote{#1\isdot}} to {#1\isdot}, and you're set with regard to the bibliography. In case your "parent" style prints titles as part of in-text-citations, you'll have to modify the citetitle field in the same way.

For the formatting of citation postnotes, the same principles as above apply, so I'll just post the solution to your actual question. ;-)

\DeclareFieldFormat{postnote}{#1}% no postnote prefix in "normal" citation commands
\DeclareFieldFormat{multipostnote}{#1}% no postnote prefix in "multicite" commands
\DeclareFieldFormat{pages}{#1}% no prefix for the `pages` field in the bibliography

Bibliography – spacing and punctuation

Section 3.9.1 "Generic [Formatting] Commands and Hooks" of the manual provides the basics, the "Formatting Commands" section of biblatex.def contains the actual macros. With regard to your example question (How to replace unit-separator periods with commas?),

\newcommand*{\newunitpunct}{\addperiod\space}

needs to be redefined (using \renewcommand!) as

\renewcommand*{\newunitpunct}{\addcomma\space}

Bibliography – order of first names and last names

The standard styles shipped with biblatex use two different name formats for the bibliography: default (used by numeric and alphabetic) and sortname (used by authoryear, authortitle, and verbose). (In-text-citations are the domain of a third name format, labelname.) These name formats in turn utilize auxiliary macros such as

  • last-first/first-last: lead author of multi-author works is printed as "last name – first name", follow-up authors are printed as "first name – last name";

  • last-first: all authors are printed as "last name – first name";

  • first-last: you guessed it.

To change the name format for, say, the authortitle bibliography style (by default last-first/first-last) to, say, last-first, apply the following:

\DeclareNameAlias{sortname}{last-first}

Bibliography – order of certain fields

Let's delve into the files standard.bbx and <myparentstyle>.bbx, both of them located in the /bbx subdirectory of your biblatex folder. As per your question, you want to swap the location and publisher fields. Suppose you encounter the following code snippet in standard.bbx:

\DeclareBibliographyDriver{book}{%
  \printnames{author}%
  \newunit\newblock
  \printfield{title}%
  \newunit\newblock
  \printlist{publisher}%
  \newunit
  \printlist{location}%
  \newunit
  \printfield{year}%
  \finentry}

Copy-pasting this definition to your local copy of biblatex.cfg and swapping the respective code lines should be a piece of cake, right? Wrong! While the "bibliography driver" shown above is functional (the example is taken from section 4.2.3 of the manual), the actual drivers are much more complex. They regularly use macros to print specific name lists, literal lists, or fields, and the macro definitions of standard.bbx may be modified by <myparentstyle>.bbx. Assuming your parent style is authortitle, tracing the drivers and macros will bring forth the following definition:

\newbibmacro*{publisher+location+date}{%
  \printlist{location}%
  \iflistundef{publisher}
    {\setunit*{\addcomma\space}}
    {\setunit*{\addcolon\space}}%
  \printlist{publisher}%
  \setunit*{\addcomma\space}%
  \usebibmacro{date}%
  \newunit}

Note the \iflistundef macro which will print either a comma or a colon, depending on whether the publisher list is defined. (The \setunit* macro will only print its argument if the last printing command did actually print anything.) A possible redefinition – and the answer to your question – would be

\renewbibmacro*{publisher+location+date}{%
  \printlist{publisher}%
  \setunit*{\addcomma\space}%
  \printlist{location}%
  \setunit*{\addcomma\space}%
  \usebibmacro{date}%
  \newunit}

By the way, redefining publisher+location+date will (and for the sake of consistency should) affect other entry types besides @book.

Language-specific terms

To change these, you need to modify the "localization keys" listed in section 4.9.2 of the manual. With regard to your example question, the following code does the trick:

\DefineBibliographyStrings{english}{%
  references = {Works Cited},
}

(Actually, a long and a short form is assigned to every localization key. However, with biblatex.cfg it is not possible to separately override these two expressions.)

Afterword

TeX.sx features a lot of questions/answers about customizing biblatex, with the solutions spanning everything from cute and simple macro redefinitions to venturous hacking of biblatex internals. Some notable ones (no claim to be complete):

Finally, here's a real-world example of tinkering with bibliography drivers.

share|improve this answer
    
Interesting thing is that you can also type \DeclareNameAlias{default}{last-first} to apply corresponding sorting scheme to the numeric style. –  rook Jun 19 '13 at 8:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.