# Add a custom .bib entry to bibliography

I would like to add the total number of bookpages e.g. ", 543 S." to every bibliography entry (if that field is filled). I have named the .bib-field "nop"

For example: "PAIL, R. (2017) [...] Springer Spektrum, 217–257, 543 S."

instead of "PAIL, R. (2017) [...] Springer Spektrum, 217–257.".

I have excluded many lines of the actual bibliography design as I don't think it is necessary here. The code is:

\documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usepackage{csquotes}
\usepackage[style=ext-authoryear-ibid, giveninits=true, uniquelist=false,
backend=biber, natbib=true]{biblatex}

\begin{document}
\parencite[220]{Pail.2017}
\printbibliography
\end{document}


and

@book{Pail.2017,
author = {Pail, Roland},
title = {Globale Schwerefeldmodellierung am Beispiel von GOCE},
pages = {217--257},
booktitle = {Erdmessung und Satellitengeod{\"a}sie},
year = {2017},
nop = {543}
}

• There is no field nop, but there is pagetotal for a similar purpose. pagetotal is however only available for the types @book, @collection, @manual, @report since it holds the total number of pages of a single work. The total number of pages of a @incollection, @inbook or @article can be calculated from the pages field. In your example the pagetotal would refer to the enclosing @collection work while pages would refer to the @incollection. I don't think pagetotal makes a lot of sense here. – moewe Jun 24 '18 at 19:41
• I have added "nop={543}" by myself (using Citavi) as it did not show up in the .bib file until then. I just used this incollection as an example - does not make much sense, you're right. In the case of a book - how could I add that field to the bibliography? – Vivi Jun 24 '18 at 19:49
• Use pagetotal – moewe Jun 24 '18 at 19:51
• For people coming here looking to find out how to add a new field that isn't yet known to the data model, have a look at tex.stackexchange.com/q/163303/35864 – moewe Jun 24 '18 at 20:03

The field you are looking for is pagetotal. pagetotal holds the total number of pages of a work. The standard styles only print pagetotal for @book-like stand-alone works (@book, @collection, @manual, @thesis, ...).

For example from biblatex-examples.bib

@book{companion,
author       = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander},
title        = {The {LaTeX} Companion},
date         = 1994,
edition      = 1,
pagetotal    = 528,
}


If you insist on a comma before the pagetotal, you will need to patch the bibdrivers.

\documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usepackage{csquotes}
\usepackage[style=ext-authoryear-ibid, giveninits=true, uniquelist=false,
backend=biber, natbib=true]{biblatex}

\usepackage{xpatch}
\newcommand*{\commapagetotal}[1]{%
\xpatchbibdriver{#1}
{\newunit\printfield{pagetotal}}
{}{}}
\forcsvlist{\commapagetotal}{book,booklet,collection,manual,proceedings,report,thesis}

\begin{document}
\parencite{companion}
\printbibliography
\end{document}


The original question had an @incolletion entry as example. There things are a bit more tricky...

For works like @inbook, @incollection and @article the field is not used because the total number of pages can be easily calculated from the pages field.

There is a slight semantic quirk of filling the pagetotal field of a @in... type work with the total number of pages of the enclosing work, but a similar thing happens to editor or isbn, so...

You need to patch the driver of @incollection to include pagetotal. This can be done with xpatch's \xpatchbibdriver.

\documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usepackage{csquotes}
\usepackage[style=ext-authoryear-ibid, giveninits=true, uniquelist=false,
backend=biber, natbib=true]{biblatex}

\usepackage{xpatch}
\xpatchbibdriver{#1}
{\usebibmacro{chapter+pages}}
{\usebibmacro{chapter+pages}\newunit\printfield{pagetotal}}
{}{}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@incollection{Pail.2017,
author    = {Pail, Roland},
title     = {Globale Schwerefeldmodellierung am Beispiel von GOCE},
pages     = {217--257},
publisher = {Springer Spektrum},
editor    = {Rummel, Reinhard and Freeden, Willi},
booktitle = {Erdmessung und Satellitengeodäsie},
year      = {2017},
pagetotal = 543,
}
\end{filecontents}

\begin{document}
\parencite[220]{Pail.2017}
\printbibliography
\end{document}


I personally think the information is superfluous, but if you like it...

• I get what you mean and have renamed the Citavi entry now and changed it from nop to pagetotal. How can I get (in this case) "217-257, 543 S." instead of "217-257. 543 S."? – Vivi Jun 24 '18 at 19:58
• @Vivi In a @book entry you will usually not have a pages field (after all a @book is the entire book), so there is no '217-257'. – moewe Jun 24 '18 at 20:01
• I am sorry, my bib-example was not too clever. Let's just assume this is a book. Then it would be "...Springer Spektrum. 543 S." But I need to have it this way: "...Springer Spektrum, 543 S." – Vivi Jun 24 '18 at 20:05
• @Vivi That depends. The punctuation before pagetotal is the standard unit punctuation which normally is a full stop/period. That could be changed to a comma everywhere with \renewcommand*{\newunitpunct}{\addcomma\space}, but that is probably not what you want since it affects many more places. If you only want to change the punctuation before pagetotal you need to patch the drivers. ... – moewe Jun 24 '18 at 20:11
• Alright, I'll have to leave it this way then. Patching the drivers sounds far too complicated as I am only a beginner and due date is tomorrow – Vivi Jun 24 '18 at 20:15