biblatex icon indicating copy to clipboard operation
biblatex copied to clipboard

Biblatex 3.15a casechanger issue with \cite command and postnote

Open dfussner opened this issue 5 years ago • 3 comments

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:

mwe10

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.

dfussner avatar Sep 09 '20 14:09 dfussner

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.

josephwright avatar Sep 09 '20 14:09 josephwright

Mhhh, the following two workarounds are possible.

  1. 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}
  1. Use \NoCaseChange instead 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 avatar Sep 09 '20 16:09 moewew

@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!

josephwright avatar Sep 09 '20 16:09 josephwright

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 avatar Sep 25 '22 12:09 moewew

@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.

dfussner avatar Sep 26 '22 11:09 dfussner