Biblatex: 2 custom fields, only one is working

Following this question BibLaTeX/BibTeX custom field to show file link and Notes after bibliography entry with Biber and biblatex I get it to work (well, more or less). In the code below I defined a field file and mynote. It is working for file but not for mynote. I don't understand why!

\documentclass[%
a4paper,
english,
11pt,
]{article}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
title={The integrative future of taxonomy},
author={José M.~Padial and Aurélien Miralles and Ignacio De la Riva and Miguel Vences},
journal={Frontiers in Zoology},
year=2010,
month=may,
volume=7,
number=16,
pages={1--14},
doi={10.1186/1742-9994-7-16},
issn={1742-9994},
mynote={Very good book!},
file={./article/2010_Wang.pdf},
keywords={biology, taxonomy},
}
\end{filecontents*}

\usepackage{fixltx2e}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{type1ec}
%\usepackage{lmodern}
\usepackage{microtype}

\usepackage[%
left=5cm,
right=2cm,
%showframe,
]{geometry}

\usepackage[color,notref,notcite]{showkeys}

\usepackage[strict,autostyle]{csquotes}

\usepackage[%
backend=biber,
style=ieee,
]{biblatex}
\DeclareRangeChars{~,;-+/{}} % add '{}' as page range delimiter

\DeclareFieldFormat{mynote}{\textbf{#1}}
\DeclareFieldFormat{file}{\href{file:#1}{\textbf{Open file}}}
\AtEveryBibitem{%
\csappto{blx@bbx@\thefield{entrytype}}{% put at end of entry
\iffieldundef{file}{\space \textbf{No file!}}{%
\space \printfield{file}}
\iffieldundef{mynote}{\space \textbf{No annotation!}}{\space\printfield{mynote}}
}
}

\usepackage[%
unicode,
]{hyperref}

\begin{document}

\nocite{*} % list all entries

\printbibliography
%\printbibliography[keyword=taxonomy]

\end{document}


This is because file is already a field to biblatex, although one not used by the standard styles, while mynote isn't. You must remap (via DeclareSourcemap) the mynote field to one of the user[a-f] fields before you can use them.

\documentclass{article}

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
title={The integrative future of taxonomy},
author={José M.~Padial and Aurélien Miralles and Ignacio De la Riva and Miguel Vences},
journal={Frontiers in Zoology},
year=2010,
month=may,
volume=7,
number=16,
pages={1--14},
doi={10.1186/1742-9994-7-16},
issn={1742-9994},
mynote={Very good book!},
file={./article/2010_Wang.pdf},
keywords={biology, taxonomy},
}
\end{filecontents*}

\usepackage[utf8]{inputenc}
\usepackage[color,notref,notcite]{showkeys}

\usepackage[%
backend=biber,
style=ieee,
]{biblatex}

\DeclareRangeChars{~,;-+/{}} % add '{}' as page range delimiter

\DeclareFieldFormat{file}{\href{file:#1}{\textbf{Open file}}}

\AtEveryBibitem{%
\csappto{blx@bbx@\thefield{entrytype}}{% put at end of entry
\iffieldundef{file}{\space \textbf{No file!}}{%
\space \printfield{file}
}
}
}

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

\DeclareFieldFormat{usera}{\textbf{#1}}

\AtEveryBibitem{%
\csappto{blx@bbx@\thefield{entrytype}}{% put at end of entry
\iffieldundef{usera}{%
\space \textbf{No annotation!}}{%
\space\printfield{usera}
}
}
}

\usepackage[%
unicode,
]{hyperref}

\begin{document}

\nocite{*} % list all entries

\printbibliography

\end{document}


• Very good answer. In the end I used the field annotation (as it is already defined in BibLaTeX) and did as I had done for file. – cacamailg May 2 '13 at 14:53
• If so, you should consider changing your database to reflect this (specially since your use of mynote seems to fall into the purpose of annotation). I must say that IMHO, while this answer works fine and is a good approach to single files, Guido's answer seems to me to be the "right" one to choose, since it approaches the subject in a more generalized way. – henrique May 2 '13 at 19:46
• This is the only answer I could get to work. It's perhaps good to emphasize that the field can only be mapped to user[a-f], and not another name of your choosing. – Stefan van der Walt Nov 24 '14 at 0:36
• @StefanvanderWalt, Actually you do can create new, custom fields by playing with the data models (see §4.5.3 of the manual) instead of remapping it to the official custom ones (user[a-f] etc.). There were a typo in Guido's answer (filed instead of field). Perhaps if you try now? I just ran it with my MWE, only changing where I used usera to the new mynote field with no apparent problem. I insist that his is the correct answer because it addresses more general usage and makes use of the full power of biblatex+biber. – henrique Nov 25 '14 at 19:13

Biblatex offers builtin support for the file field (even if it is not a standard one). Users can extend the data model by creating new fields, but they have to be declared in configuration files According to the manual (page 175) they are ordered as follows:

blx-dm.def→
‘datamodel option’.dbx →
‘style option’.dbx →
‘citestyle option’.dbx and ‘bibstyle option’.dbx →
biblatex-dm.cfg


Thus, you can create a biblatex-dm.cfg file in the working directory and use

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


The creation of file can be done within your file using filecontents package and

\begin{filecontents}{biblatex-dm.cfg}
\DeclareDatamodelFields[type=field, datatype=literal, skipout=false]{mynote}
\end{filecontents}

• Just a couple of comments - you can omit skipout=false as this is the default. Also, you need \DeclareDatamodelEntryfields{mynote} too. This declares "mynote" as valid for all entrytypes and the macro you mentioned defines its type. – PLK May 2 '13 at 7:09
• Indeed skipout=false can be omitted. For \DeclareDatamodelEntryfields apparently it is not needed. – Guido May 2 '13 at 7:35