12

I need to add a new field in the @book or @InProceedings entries: this field is "tome", for I have for instance the following title:

Francesco Bertolini, Società di trasmissione orale: mito e folclore, in Lo spazio letterario della Grecia antica, a cura di G. Cambiano, L. Canfora e D. Lanza, vol. I, tomo I, Salerno, Roma 1992, pp. 47--75.

So the following code is not enough:

@InProceedings{ bertolini:1992,
  author                   = "Francesco Bertolini",
  title                    = "Società di trasmissione orale: mito e folclore",
  booktitle                = "Lo spazio letterario della Grecia antica",
  editor                   = "G. Cambiano and L. Canfora and D. Lanza",
  publisher                = "Salerno",
  location                 = "Roma",
  year                     = "1992",
  volume                   = "1,
  pages                    = "47--75",
}

Using othes codes, I was able only to produce the "tome" field, but with a general trouble about the other fields:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=tome,fieldtarget=usera]
    }
  }
}
\DeclareFieldFormat{usera}{tomo\space{#1}}


\DeclareBibliographyDriver{book}{%
  \usebibmacro{author/editor}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit\newblock
  \usebibmacro{journal+issuetitle}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit\newblock
  \printfield{usera}%
  \usebibmacro{finentry}}
\renewcommand*{\finentrypunct}{}

(useful for articles, but not for my case). By real, I'm not able to understand which bibmascros I have to invocate...

I tried to write a biblatex-tome.dbx:

\ProvidesFile{biblatex-tome.dbx} 

\DeclareDatamodelFields[type=field,datatype=literal,skipout=false]{tome} 

\DeclareDatamodelEntryfields{tome}

Inside the main .tex file I put just this code:

\DeclareFieldFormat{tome}{\mkbibacro{tome}\addcolon\space #1}
\newcommand*{\patchmoretome}[1]{
  \xpatchbibdriver{#1}%
    {\printfield{tome}}
    {\printfield{tome}%
          \newunit\newblock
     \printfield{tome}}%
    {\typeout{patching #1 to include more tome succeded}}%
    {\typeout{patching #1 to include more tome failed}}%
}
% patch all drivers
\patchmoretome{article}
\patchmoretome{book}
\patchmoretome{collection}
\patchmoretome{inbook}
\patchmoretome{incollection}
\patchmoretome{inproceedings}
\patchmoretome{manual}
\patchmoretome{periodical}
\patchmoretome{proceedings}
\patchmoretome{report}
\patchmoretome{thesis}

but it doesn't print the field in bibliographic entry. So I'm very confused about a (re)writing of driver

  • 1
    The entire default data model for biblatex is defined using the macros in 4.5.3 and can be found in the file blx-dm.def which comes with biblatex. – PLK Mar 3 '14 at 7:46
  • 1
    The comment about "only in a data model configuration file" has been removed from the dev docs. It's not quite true - you can use the datamodel macros in the preamble to add to a loaded data model. You just shouldn't try to define an entire data model in the preamble as biblatex will already have loaded one at that point. The docs say this now. – PLK Mar 3 '14 at 7:55
  • 2
    The code you put in your main .tex file will not do what you want: Currently it replaces all occurrences of \printfield{tome} by two calls to that same macro separated by a \newunit\newblock. But since there is no \printfield{tome} in any of the drivers this replacement does not do anything. You could try \xpatchbibdriver{#1}{\printfield{volume}}{\printfield{volume}\newunit\newblock\printfield{tome}}{}{}, though. But then you will have to alter bibmacros as well. – moewe Mar 3 '14 at 8:09
  • 1
    The trouble with your first attempt was: you basically copied a slimmed-down version of the @article driver and modified that to print tome information, but declared it to be the driver for @books. Rewriting the entire driver just to include one field seems an unreasonable option - it's a lot of work. – moewe Mar 3 '14 at 8:10
13

Use an existing field (part)

If you use the part field for tome information1, there is not a lot to be done in the standard styles. If you have a non-standard/custom style that moves around the part information though, you would need to tell us more about it.

These four lines should do what you want. They redefine the string part to be "tomo" and print ", tomo #" after the volume.

\DefineBibliographyStrings{italian}{%
  part = {tomo},
}
\DeclareFieldFormat{part}{\addcomma\space\bibstring{part}\space #1}

All the standard styles use the sequence

\printfield{volume}%
\printfield{part}%

to print part information, so we should be fine.

(Normally, putting \addcomma and the like in \DeclareFieldFormat is frowned upon, but the part field seems to be special insofar that the default format is {.#1} and that there is no other punctuation inserted between volume and part by any of the standard styles.)

Your bib entry would be

@InProceedings{bertolini:1992,
  author         = "Francesco Bertolini",
  title          = "Società di trasmissione orale: mito e folclore",
  booktitle      = "Lo spazio letterario della Grecia antica",
  editor         = "G. Cambiano and L. Canfora and D. Lanza",
  publisher      = "Salerno",
  location       = "Roma",
  year           = "1992",
  volume         = "1",
  part           = "2",
  pages          = "47--75",
}

Full MWE

\documentclass[italian]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[]{biblatex}
\usepackage{filecontents}

%\DeclareFieldFormat{part}{.#1}% physical part of a logical volume
\DefineBibliographyStrings{italian}{%
  part = {tomo},
}
\DeclareFieldFormat{part}{\addcomma\space\bibstring{part}\space #1}

\begin{filecontents*}{\jobname.bib}
@InProceedings{bertolini:1992,
  author         = "Francesco Bertolini",
  title          = "Società di trasmissione orale: mito e folclore",
  booktitle      = "Lo spazio letterario della Grecia antica",
  editor         = "G. Cambiano and L. Canfora and D. Lanza",
  publisher      = "Salerno",
  location       = "Roma",
  year           = "1992",
  volume         = "1",
  part           = "2",
  pages          = "47--75",
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\cite{bertolini:1992}
\printbibliography
\end{document}

enter image description here


1 The biblatex documentation states on page 21, §2.2.2 Data Fields,

part (field (literal)) The number of a partial volume. This field applies to books only, not to journals. It may be used when a logical volume consists of two or more physical ones. In this case the number of the logical volume goes in the volume field and the number of the part of that volume in the part field.


Map the field to an existing field (part)

You could also map the field tome to part thus creating an alias for input purposes

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=tome]
      \step[fieldset=part, origfieldval]
    }
  }
}

The sample entry might look like this then

@InProceedings{bertolini:1992,
  author         = "Francesco Bertolini",
  title          = "Società di trasmissione orale: mito e folclore",
  booktitle      = "Lo spazio letterario della Grecia antica",
  editor         = "G. Cambiano and L. Canfora and D. Lanza",
  publisher      = "Salerno",
  location       = "Roma",
  year           = "1992",
  volume         = "1",
  tome           = "3",
  pages          = "47--75",
}

For more general purposes, biblatex defines the five generic fields usera to userf (as well as lista to listf for lists fields and namea to namec for names). While it might be awkward to use these fields in the input .bib file, where more useful names are expected, they are useful for internal remapping.


Declare a new field

If you absolutely insist on creating a new data field tome, create a new datamodel file, tome.dbx, with the following content and put it somewhere LaTeX can find it (this is necessary since version 2.9, before that it was possible to use datamodel commands directly in the document, but this is not guaranteed to work and therefore strongly discouraged, see Data model macro cannot be used in preamble; LaTeX will be able to find the .dbx file if you place it in the same folder as your main .tex document, other options to make the file globally available are discussed in https://texfaq.org/FAQ-inst-wlcf).

\ProvidesFile{tome.dbx}[2019/20/02 add tome field to biblatex data model]

\DeclareDatamodelFields[type=field,datatype=literal]{tome}
\DeclareDatamodelEntryfields{tome}

(In the MWE below this file is created automatically using the filecontents package.)

We then have to load biblatex with the option datamodel=tome in order to get load the correct datamodel where tome is defined. Alternatively, you can put the above lines into biblatex-dm.cfg (see How to include price in bibliography?).

Again we use localisation strings

\NewBibliographyString{tome}
\DefineBibliographyStrings{italian}{%
  tome = {tomo},
}

\DeclareFieldFormat{tome}{\bibstring{tome}\space #1}

We will then have to patch all the drivers/macros to include tome information, that is quite a task...

We renew some macros

\renewbibmacro*{maintitle+title}{%
  \iffieldsequal{maintitle}{title}
    {\clearfield{maintitle}%
     \clearfield{mainsubtitle}%
     \clearfield{maintitleaddon}}
    {\iffieldundef{maintitle}
       {}
       {\usebibmacro{maintitle}%
    \newunit\newblock
    \iffieldundef{volume}
      {}
      {\printfield{volume}%
     \setunit{addcomma\space}%
     \printfield{tome}
           \printfield{part}%
           \setunit{\addcolon\space}}}}%
  \usebibmacro{title}%
  \newunit}

\renewbibmacro*{maintitle+booktitle}{%
  \iffieldundef{maintitle}
    {}
    {\usebibmacro{maintitle}%
     \newunit\newblock
     \iffieldundef{volume}
       {}
       {\printfield{volume}%
     \setunit{addcomma\space}%
     \printfield{tome}
        \printfield{part}%
        \setunit{\addcolon\space}}}%
  \usebibmacro{booktitle}%
  \newunit}

And add tome to the drivers

\newcommand*{\addtometo}[1]{%
  \xpatchbibdriver{#1}
    {\printfield{volume}}
    {\printfield{volume}%
     \setunit{\addcomma\space}%
     \printfield{tome}}
    {}
    {\typeout{failed to add tome to #1 driver}}
}
\addtometo{inproceedings}
\addtometo{book}

MWE

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


\usepackage{filecontents}
\begin{filecontents*}{tome.dbx}
\ProvidesFile{tome.dbx}[2019/20/02 add tome field to biblatex data model]

\DeclareDatamodelFields[type=field,datatype=literal]{tome}
\DeclareDatamodelEntryfields{tome}
\end{filecontents*}

\usepackage[backend=biber,datamodel=tome]{biblatex}


%\DeclareFieldFormat{part}{.#1}% physical part of a logical volume
\NewBibliographyString{tome}
\DefineBibliographyStrings{italian}{%
  tome = {tomo},
}


\DeclareFieldFormat{tome}{\bibstring{tome}\space #1}

\usepackage{xpatch}

\newcommand*{\addtometo}[1]{%
  \xpatchbibdriver{#1}
    {\printfield{volume}}
    {\printfield{volume}%
     \setunit{\addcomma\space}%
     \printfield{tome}}
    {}
    {\typeout{failed to add tome to #1 driver}}
}
\addtometo{proceedings}
\addtometo{inproceedings}
\addtometo{book}
\addtometo{inbook}

\renewbibmacro*{maintitle+title}{%
  \iffieldsequal{maintitle}{title}
    {\clearfield{maintitle}%
     \clearfield{mainsubtitle}%
     \clearfield{maintitleaddon}}
    {\iffieldundef{maintitle}
       {}
       {\usebibmacro{maintitle}%
    \newunit\newblock
    \iffieldundef{volume}
      {}
      {\printfield{volume}%
     \setunit{addcomma\space}%
     \printfield{tome}
           \printfield{part}%
           \setunit{\addcolon\space}}}}%
  \usebibmacro{title}%
  \newunit}

\renewbibmacro*{maintitle+booktitle}{%
  \iffieldundef{maintitle}
    {}
    {\usebibmacro{maintitle}%
     \newunit\newblock
     \iffieldundef{volume}
       {}
       {\printfield{volume}%
     \setunit{addcomma\space}%
     \printfield{tome}
        \printfield{part}%
        \setunit{\addcolon\space}}}%
  \usebibmacro{booktitle}%
  \newunit}

\begin{filecontents*}{\jobname.bib}
@InProceedings{bertolini:1992,
  author         = "Francesco Bertolini",
  title          = "Società di trasmissione orale: mito e folclore",
  booktitle      = "Lo spazio letterario della Grecia antica",
  editor         = "G. Cambiano and L. Canfora and D. Lanza",
  publisher      = "Salerno",
  location       = "Roma",
  year           = "1992",
  volume         = "1",
  tome           = "3",
  pages          = "47--75",
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\cite{bertolini:1992}
\printbibliography
\end{document}

That much hassle probably is not worth it as we have part that seems to do what you want rather well.

| improve this answer | |

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.