I have several references in a document. I'd like to display some statistics regarding the references - for example,
- citations with author
Smith
, - citations between year
xxxx
andyyyy
, - citations published in Journal
foo
, - citations not published in a journal (I think that I only have
@inproceedings
and@book
types).
I'm using biblatex
.
There are several questions about counting the total number of citations used: for example, this, and this. These are similar to what I want to do, but the answers aren't extensible to my use-case.
From here, I can count the citations published between two years using:
\usepackage{etoolbox}
\AtDataInput{
\ifboolexpr{ test { \ifnumless {\thefield{year}+0}{2005}} and
test {\ifnumgreater{\thefield{year}+0}{2000}}}
{ \stepcounter{c_years} }{}
{}
}
I'm trying to do something similar to count the authors with name Smith
and publications in journal foo
:
\usepackage{xstring}
\newcounter{c_foo}
\AtDataInput{
\IfSubStr{\strfield{booktitle}}{foo}{ \stepcounter{c_foo} }{}
{}
}
I step a counter if foo
is a substring of \strfield{booktitle}
. However, this doesn't work (the counter remains at 0). I've tried with \thefield
, which also doesn't work.
I thought perhaps foo
wasn't surrounded by whitespace, and that xstrings \IfSubStr
wasn't picking it up, but these both work:
\IfSubStr{The foo bear}{foo}{ \stepcounter{c_foo} }{}
\IfSubStr{Thefoobear}{foo}{ \stepcounter{c_foo_two} }{}
I'm taking this approach because when it works, I should be able to check for substrings of any of the fields, which is an extensible solution.