I am trying to put a conditional statement within a bib file, namely in the author field. I tried with both the ifthenelse and the iftoggle commands, but to no avail. The condition is respected, but then the author names are not expanded correctly, it thinks it is a sole author and does not replace the "and" with comma, etc.
Do you know any workaround to solve this?
Below a minimal reproducer.
\documentclass{article}
\bibliographystyle{vancouver}
\usepackage{etoolbox}%iftoggle
\providetoggle{blinded}
\settoggle{blinded}{false}
\usepackage{ifthen}
\newcommand{\amode}{\string notblinded}
\begin{document}
iftoggle: \cite{test_article}
ifthenelse: \cite{test_article2}
correct: \cite{test_article3}
\bibliography{References}
\end{document}
The References.bib file:
@article{ test_article,
title = {a},
author = {\iftoggle{blinded}{b}{c c and d d and e e}},
journal = {j},
volume = {v},
number = {n},
pages = {ps},
doi = {doi},
year = {y}
}
@article{ test_article2,
title = {a},
author = {\ifthenelse{\equal{\amode}{\string blinded}}{b}{c c and d d and e e}},
journal = {j},
volume = {v},
number = {n},
pages = {ps},
doi = {doi},
year = {y}
}
@article{ test_article3,
title = {a},
author = {c c and d d and e e},
journal = {j},
volume = {v},
number = {n},
pages = {ps},
doi = {doi},
year = {y}
}
Result:
Thanks in advance!
Somehow related: Use toggles in biblatex `printbibliography`

biblatexit would be easy to define such a switch in the document itself and not in the .bib file. Isbibtexrequired? With plainbibtexI'm not sure, but might be possible as well. Unfortunatley, I'm not very experienced with the plain version. – lukeflo Sep 05 '23 at 10:14author = {\blind{}c c and d d and e e\endblind{}},and then define\blindas\def\blind#1\endblind{#1}or\def\blind#1\endblind{b}(add a\newcommand\blind{}before to get an error if you overwrite some existing command. – Ulrike Fischer Sep 05 '23 at 10:47\def\ablind#1\endablind{\iftoggle{blinded}{b}{#1}}– ferdymercury Sep 05 '23 at 12:54