I would like to allow for an optional custom field in my .bib entries. I do not need these fields to be part of the bibliography, but would like to be able to access these via
\citefield{<entry-key>}{<custom-field-name>}
The answer is probably somewhere in the references listed below, but my initial attempts to adapt \DeclareSourcemap
and \DeclareFieldFormat
failed.
References:
- How can I create entirely new data types with BibLaTeX/Biber?
- How to magically add the file field to each entry in a bib file?
Code:
\begin{filecontents}{mybib.bib}
@book{knuth1984texbook,
title={The texbook},
author={Knuth, D.E. and Knuth, A.D. and Bibby, D. and American Mathematical Society and Addison-Wesley Publishing Company and Addison-Wesley},
isbn={9780201134483},
lccn={85030845},
series={Computers \& typesetting},
url={https://books.google.com/books?id=hEYuAQAAIAAJ},
year={1984},
publisher={Addison-Wesley},
myFieldA={Useful Book},
myFieldB={on Shelf 4},
}
@book{goossens1994latex,
title={The LaTeX Companion},
author={Goossens, M. and Mittelbach, F. and Samarin, A.},
isbn={9780201541991},
lccn={lc93023150},
series={Addison-Wesley series on tools and techniques for computer typesetting},
url={https://books.google.com/books?id=54A3MuBzIrEC},
year={1994},
publisher={Addison-Wesley},
myFieldA={Also Useful Book},
myFieldB={on Shelf 5},
}
\end{filecontents}
%% -----------------
\documentclass{article}
\usepackage{biblatex}
\addbibresource{mybib.bib}
\begin{document}
This should print ``Also Useful Book'':
\citefield{goossens1994latex}{myFieldA}
\end{document}
biblatex
already provides, e.g.user[a-f]
(see section 2.2.4 of the manual). If you can live with the default names, just use them, if you need your own names, it would be a matter of making a copy with a sourcemap.