How to force biblatex to patch footnotes when \footnotetext was redefined by some other package?

biblatex issues the following warning when used with the linguex package.

Package biblatex Warning: Patching footnotes failed.
(biblatex) Footnote detection will not work.


This is because the linguex redefines \footnotetext in order to support numbered examples in footnotes and endnotes.

However, redefining \footnotetext makes it impossible (difficult?) for biblatex to patch footnotes in order to support ibid and ibidem citations.

According to an answer (here), this is a warning we can safely ignore as long as we're not using an ibid citation style.

But what if a user wants to use both linguex and some ibid citation style? Is there a way to make biblatex override whatever has been done to \footnotetext?

MWE:

\documentclass{article}

\usepackage{linguex}

\usepackage
[
backend = biber,
style   = authoryear-ibid,
]
{biblatex}

\begin{document}
\end{document}

• Without a working example, it is tough, but maybe load linguex thus: \let\svfootnotetext\footnotetext\usepackage{linguex}\let\footnotetext\svfootnotetext. This will restore the definition of \footnotetext to that which preexisted the loading of linguex. Sep 2, 2016 at 16:06
• This won't work. \let works with a pointer to \footnotetext, whereas those packages redefine whatever that pointer points to.
– n.r.
Sep 2, 2016 at 16:10
• \let does not work with a pointer, but makes an actual copy. Now the problem may be that what gets changed is not \footnotetext, but subsidiary routine(s). In that case, this procedure needs to be applied to the actual routine(s) that are changed by linguex. Sep 2, 2016 at 16:10
• You're right. It turns out that linguex redefines \@footnotetext. So, the following should go after loading it: \makeatletter \let\@footnotetext\predefinedfootnotetext \makeatother
– n.r.
Sep 2, 2016 at 16:22
• But then you destroy the redefinition of linguex. Sep 2, 2016 at 16:48

\documentclass{article}

\usepackage
[
backend = biber,
style   = authoryear-ibid,
]
{biblatex}
\usepackage{linguex}

\makeatletter
\let\linguex@footnotetext\@footnotetext
\let\@footnotetext\predefinedfootnotetext
\AtBeginDocument{%
\let\predefinedfootnotetext\@footnotetext
\let\@footnotetext\linguex@footnotetext
}
\makeatother

\setlength{\textheight}{5cm} % just to get a smaller image

\begin{document}

Lorem \cite{worman} ipsum\footcite{sigfridsson} dolor\footnote{\cite{sigfridsson}}

Text and text\footnote{A different example would be:
\ex. This is the first level of embedding
\a. This is the second level
\b. This is still the second level, but:
\a. This is the third level
\b. This is not the end.
\b. This is the end.\par}.

\end{document}


Explanation.

linguex lets \predefinedfootnotetext to be \@footnotetext; then it redefines \@footnotetext in terms of the original. However, when at begin document, biblatex tries to patch \@footnotetext and it fails. Thus we can provisionally restore the meaning of \@footnotetext for the patch and then reapply the redefinition by linguex when the patch has been done.

Make a feature request to the biblatex team so they also support linguex, which is quite easy as they just need to patch \predefinedfootnotetext in the case the package is loaded, just like they provide for some other case in which the command to patch is different.

• I'm not following. When at begin document we let \@footnotetext be \linguex@footnotetext, why doesn't this override the patch that biblatex has just applied?
– n.r.
Sep 2, 2016 at 18:00
• I'm trying to understand why this works. Does it make any difference whether biblatex is loaded earlier than linguex, as your example, rather than later, as in mine?
– n.r.
Sep 2, 2016 at 18:22
• @n.r. It shouldn't matter. Look at the redefinition of \@footnotetext performed by linguex and you'll understand why this works. Sep 2, 2016 at 19:21
• Now I see it. \@footnotetext will expand to, among other things, a \predefinedfootnotetext as modified by biblatex.
– n.r.
Sep 2, 2016 at 19:28
• @n.r. Right. And the modification happens \AtBeginDocument. Sep 2, 2016 at 19:58

You can restore the footnote detection capabilities with

\makeatletter
\long\def\@footnotetext#1{\@noftnotefalse\predefinedfootnotetext{\toggletrue{blx@footnote}#1}%
\@noftnotetrue}
\makeatother


That will not get rid of the warning, though, but it can now be safely ignored.

MWE

\documentclass{article}

\usepackage{linguex}

\usepackage[backend = biber, style = authoryear-ibid]{biblatex}

\makeatletter
\long\def\@footnotetext#1{\@noftnotefalse\predefinedfootnotetext{\toggletrue{blx@footnote}#1}%
\@noftnotetrue}
\makeatother

\begin{document}
Lorem \cite{worman} ipsum\footcite{sigfridsson} dolor\footnote{\cite{sigfridsson}}
\end{document}


gives

1 Sigfridsson and Ryde 1998.

2 ibid

in foonotes, while without the modification you'd get

1 Sigfridsson and Ryde 1998.

2 Sigfridsson and Ryde 1998.

• What exactly does blx@footnote flag to biblatex?
– n.r.
Sep 2, 2016 at 17:05
• @n.r. It is the toggle to check if we are in a footnote. If it is true biblatex knows that we are in a footnote. Some of the predefined commands already set the toggle accordingly (that's why \footcite works), but we need to set it to true within \footcitetext - here the patching comes in. Sep 2, 2016 at 17:42
• I wonder if this is the sole modification that biblatex makes on \@footnotetext. Because if it is, then there must be a more relaxed way to patch \@footnotetext, say, by merely prepending \toggletrue{blx@footnote} to whatever \@footnotetext would expand to, and thus avoid unnecessarily breaking the ibid feature.
– n.r.
Sep 2, 2016 at 17:46
• @n.r. As far as I can see biblatex only inserts \toggletrue{blx@footnote} after \color@begingroup in footnotetext-like commands. I suppose one needs to make sure the grouping is right and that is why biblatex patches commands like it does right now. Sep 2, 2016 at 17:53

This is how to get rid of biblatex warning:

\documentclass{article}
\usepackage{linguex}

\makeatletter
\let\@footnotetext\predefinedfootnotetext
\makeatother

\usepackage[backend=biber, style=authoryear-ibid]{biblatex}
\begin{document}
\end{document}


We revert \@footnotetext back to its standard definition using \predefinedfootnotetext, which is provided by linguex itself.

Notice, however, that in this way we'll no longer be able to use linguex in footnotes, and will need to resort to something like enumerate environments to get numbered examples in footnotes.