Tuesday, 20 August 2013

Check if substring exists in bibliography field using \thefield and \IfSubStr

Check if substring exists in bibliography field using \thefield and \IfSubStr

I want a counter for each of the major conference proceedings I cite, with
the eventual aim of having a graph comparing the citations from foo, bar
and baz.
From here, I'm using \IfSubStr to check if the name of the proceedings is
in the Booktitle field of my bibliography (with this answer for the use of
\thefield, although it uses the year field as a number):
\IfSubStr{ \thefield{Booktitle} }{foo}{ \toggletrue{tog_foo} }{
\togglefalse{tog_foo} }
I think I might be missing a package, because this doesn't work:
Undefined control sequence. [\IfSubStr{ \thefield{Booktitle}}{foo}]
I've got the syntax for IfSubStr correct, because if I change
\thefield{Booktitle} to foo I get no errors:
\IfSubStr{ foo }{foo}{ \toggletrue{tog_foo} }{ \togglefalse{tog_foo} }
How can I use \thefield with \IsSubStr?
Here's my MWE:
\documentclass{article}
\usepackage{etoolbox}
\usepackage{xstring}
\usepackage{biblatex}
\newtoggle{tog_foo}
% Doesn't work
\IfSubStr{ \thefield{Booktitle} }{foo}{ \toggletrue{tog_foo} }{
\togglefalse{tog_foo} }
% Works
\IfSubStr{ foo }{foo}{ \toggletrue{tog_foo} }{ \togglefalse{tog_foo} }
\begin{document}
\end{document}

No comments:

Post a Comment