0

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:

Compiled result

Thanks in advance!

Somehow related: Use toggles in biblatex `printbibliography`

8
  • 2
    what is the use case? Sep 5, 2023 at 9:19
  • Some scientific journals require that you provide a blinded version of your manuscript that hides the author names of your references. I want to quickly switch between my own working version and the one I submit to the journal. Sep 5, 2023 at 10:07
  • Of you could use biblatex it would be easy to define such a switch in the document itself and not in the .bib file. Is bibtex required? With plain bibtex I'm not sure, but might be possible as well. Unfortunatley, I'm not very experienced with the plain version.
    – lukeflo
    Sep 5, 2023 at 10:14
  • The journal requires a strict Latex template to be followed, together with a bst bibtex style, see here: bibtex.com/s/bibliography-style-elsarticle-elsarticle-num I can modify though the .bst file in my folder if that would help in adding an extra expansion of the author field or something like that, for example the function format.names Sep 5, 2023 at 10:25
  • 1
    you could try with author = {\blind{}c c and d d and e e\endblind{}}, and then define \blind as \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. Sep 5, 2023 at 10:47

0

You must log in to answer this question.

Browse other questions tagged .