I have a primary source and analyzed its references (on which pages are the references cited, like a manual backref
job). I created a new library for this (like the author would to if he had LaTeX a few centuries ago) and added a custom field citedonpages
with the manually discovered pages.
I would like to print this analyzed data (e.g. for displaying it in a table). Is it possible to use biblatex/biber
to process additional fields (in this case citedonpages
as described in citedonpages.dbx
) to
- print this list for each entry
- and count the comma separated entries?
I tried to follow https://tex.stackexchange.com/a/163396/4419 but the command \printfield{citedonpages}
did non work.
How can I access (print) the citedonpages
field and how can I count the entries of the comma-separated values? As the real library has many entries, an automated solution would be very helpful (and ideally completely within LaTeX).
MWE (as a follow-up question of Create table from references with custom fields as columns using biblatex/biber):
\documentclass{scrbook}
\begin{filecontents*}{citedonpages.dbx}
\ProvidesFile{citedonpages.dbx}[2021/07/27 add citedonpages field to biblatex data model]
\DeclareDatamodelFields[type=field,datatype=literal]{citedonpages} %comma seperated list of values
\DeclareDatamodelEntryfields{citedonpages}
\end{filecontents*}
\begin{filecontents*}{Analysis.bib}
@Book{Miller1832a,
author = {John Miller},
title = {Elementary book},
year = {1832},
citedonpages = {67,68,97},
}
@InBook{Smith1744a,
author = {Daniel Smith},
booktitle = {Collection of important articles},
location = {Amsterdam},
title = {Noteworthy Article},
year = {1744},
citedonpages = {5, 23, 37, 79, 248, 249, 254},
}
\end{filecontents*}
%\addbibresource{Analysis.bib}
\usepackage{longtable,array}
\usepackage{booktabs,lipsum,tabularx}
\usepackage[backend=biber,datamodel=citedonpages,style=authortitle]{biblatex}
\usepackage{biblatex-ext-tabular}
\DeclareFieldFormat{citedonpages}{\bibstring{citedonpages}\space #1}
\defbibtabular{bibtabular}
{\renewbibmacro*{bbx:dashcheck}[2]{##2}%
\begin{longtable}{@{}llccl@{}}
\toprule
\textbf{Author} & \textbf{Title} & \textbf{Year} & \textbf{\# Citations} & \dots\ on pages\\
\midrule}
{\bottomrule
\end{longtable}}
{\anchorlang{\usebibmacro{author/editor+others}}
& \plainlang{\usebibmacro{title}}
& \plainlang{\printdate}
& 0 % how to display counter
& \printfield{citedonpages}
\\}
\begin{document}
\begin{refsection}[Analysis.bib]
\nocite{*}
\printbibliography[heading=none]
\end{refsection}
\textbf{Ideally, it should output something like:}\\
Miller, John. \textit{Elementary book}. 1832. (cited 3 times on pages 67, 68, 97)\\
Smith, Daniel. “Noteworthy Article”. In: \textit{Collection of important articles}. Amsterdam,
1744. (cited 7 times on pages 5, 23, 37, 79, 248, 249, 254)
\vspace{1cm}\textbf{Version with table} (added manually):
\begin{tabularx}{0.95\textwidth}{llccX}
\toprule
{\bfseries Author} & {\bfseries Title} & {\bfseries Year} & {\bfseries \# Citations} & ... on pages \\\midrule%\otoprule
Miller, John & Elementary book & 1832 & 3 & 67, 68, 97\\
Smith, Daniel & "Noteworthy article" & 1744 & 7 & 5, 23, 37, 79, 248, 249, 254 \\
\bottomrule
\end{tabularx}
\vspace{1cm}\textbf{Version with table} (autogenerated, but entries are missing):
\begin{refsection}[Analysis.bib]
\nocite{*}
\printbibtabular[heading=none]
\end{refsection}
\end{document}