Biblatex 3.15a casechanger issue with \cite command and postnote
When you include a \cite command with a postnote field in a .bib field
whose format changes the case of that field's contents, the expl3
case-changing code breaks the citation. The latex2e case-changing code
works fine.
Here's a MWE:
\documentclass{article}
\usepackage[style=authoryear,backend=biber]{biblatex}
\DeclareFieldFormat{note}{\ifcapital{\MakeCapital{#1}}{#1}}
\addbibresource{\jobname.bib}
\begin{filecontents*}[overwrite]{\jobname.bib}
@misc{TaittirīyaUpaniṣad,
title = {Taittirīya Upaniṣad},
note = {See \cite[221--397]{Gambhirananda1986}.}
}
@book{Gambhirananda1986,
title = {Eight Upaniṣads with the Commentary of Śaṅkarācārya},
volume = {1},
editor = {S. Gambhirananda},
translator = {S. Gambhirananda},
location = {Calcutta},
publisher = {Advaita Ashrama},
year = {1986},
edition = {6}
}
\end{filecontents*}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
On my machine, it looks like this:

Using \tracingmacros I see that the expl3 code encloses the initial
square bracket in its own curly braces, so that what LaTeX sees is
something like \cite{[}, and it reports that it can't resolve that
citation. Using \Cite works fine, as does \parencite, and \cite
without the postnote field also works fine. Commenting out the field
format in the MWE above also makes everything work. (The bug and MWE
were originally sent to biblatex-chicago, which uses a lot of this sort of
field formatting in its styles.)
Many thanks.
Hmm, slightly tricky: at the moment, I've only covered 'basic' commands in the exceptions list for the expl3 case changer, with the idea that anything more complex would be \NoCaseChange-wrapped.
Mhhh, the following two workarounds are possible.
- Switch back to the LaTeX2e case changing code
\documentclass{article}
\usepackage[style=authoryear,backend=biber, casechanger=latex2e]{biblatex}
\DeclareFieldFormat{note}{\ifcapital{\MakeCapital{#1}}{#1}}
\begin{filecontents*}[overwrite]{\jobname.bib}
@misc{lorem,
title = {Lorem},
note = {See {\cite[221-97]{ipsum}}.}
}
@book{ipsum,
title = {Ipsum},
author = {Dolor},
year = {1986},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
- Use
\NoCaseChangeinstead of BibTeX case changing
\documentclass{article}
\usepackage[style=authoryear,backend=biber, casechanger=expl3, bibtexcaseprotection=false]{biblatex}
\DeclareFieldFormat{note}{\ifcapital{\MakeCapital{#1}}{#1}}
\begin{filecontents*}[overwrite]{\jobname.bib}
@misc{lorem,
title = {Lorem},
note = {See \NocCaseChange{\cite[221-97]{ipsum}}.}
}
@book{ipsum,
title = {Ipsum},
author = {Dolor},
year = {1986},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
Unfortunately, expl3 case changing + BibTeX brace protection
\documentclass{article}
\usepackage[style=authoryear,backend=biber, casechanger=expl3]{biblatex}
\DeclareFieldFormat{note}{\ifcapital{\MakeCapital{#1}}{#1}}
\begin{filecontents*}[overwrite]{\jobname.bib}
@misc{lorem,
title = {Lorem},
note = {See {\cite[221-97]{ipsum}}.}
}
@book{ipsum,
title = {Ipsum},
author = {Dolor},
year = {1986},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
doesn't help.
In any case I should warn that citations in bibliography entries can be problematic for other reasons as well, see https://github.com/plk/biblatex/issues/988.
@moewew I guess I've have to think of a way to handle complex document commands :( The idea was that case changing should apply to 'text' .... hard to get people to stick to that!
Just tested this again because of https://github.com/plk/biblatex/issues/1246. The initial MWE appears to work fine now. If you can confirm, we could close this.
@moewew Thanks for reminding me about this. I've tested here and it does indeed work fine now. I'll close the bug with this comment, if that's OK.