Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[biblatex-0.7+nameref-2.31] ifthen patching conflict (minimal example, potential workaround)

64 views
Skip to first unread message

Erik Quaeghebeur

unread,
Dec 11, 2007, 5:44:41 PM12/11/07
to
\listfiles
\documentclass{minimal}
% uncomment both to trigger:
% Package biblatex Error: Patching `ifthen' package failed.
%\usepackage{biblatex}
%\usepackage{nameref}
% invert order to avoid error (good workaround? harmless?)

\begin{document}
\end{document}
\endinput

*File List*
minimal.cls 2001/05/25 Standard LaTeX minimal class
nameref.sty 2007/05/29 v2.31 Cross-referencing by name of section
refcount.sty 2006/02/20 v3.0 Data extraction from references (HO)
biblatex.sty 2007/12/09 v0.7 Programmable bibliographies
etoolbox.sty 2007/10/08 v1.3 eTeX tools for LaTeX
etex.sty 1998/03/26 v2.0 eTeX basic definition package (PEB)
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
ifthen.sty 2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
url.sty 1999/03/02 ver 1.4 Verb mode for urls, email addresses, and file names
biblatex.def 2007/12/09 v0.7 biblatex generic definitions
standard.bbx 2007/12/09 v0.7 biblatex bibliography style
numeric.bbx 2007/12/09 v0.7 biblatex bibliography style
numeric.cbx 2007/12/09 v0.7 biblatex citation style
biblatex.cfg
english.lbx 2007/12/09 v0.7 biblatex localization
***********

Philipp Lehman

unread,
Dec 11, 2007, 6:20:30 PM12/11/07
to
Erik Quaeghebeur wrote:

> \documentclass{minimal}
> % uncomment both to trigger:
> %     Package biblatex Error: Patching `ifthen' package failed.

\begin{rant}

Oh well, yet another package forking \ifthenelse, using yet another
name. There's \ifthenelse, \org@ifthenelse, and \HyOrg@ifthenelse;
now this nameref version comes up with \NROrg@ifthenelse. Being
caught in the crossfire of babel and hyperref is such a pain in the
ass.

\end{rant}

> %\usepackage{biblatex}
> %\usepackage{nameref}
> % invert order to avoid error (good workaround? harmless?)

Erik, as a general rule of thumb: always try loading biblatex before
any conflicting packages. This is a perfectly sane solution because
the way biblatex does the patching is much less intrusive than the
common way of forking macros. Hyperref and nameref will happily pick
up biblatex's patched definitions.

--
Sender address blackholed; do not reply to From: address.
You can still reach me by email at: plehman gmx net.

Will Robertson

unread,
Dec 11, 2007, 8:05:53 PM12/11/07
to
On Dec 12, 9:20 am, Philipp Lehman <devnull.1.leh...@spamgourmet.com>
wrote:

> Erik Quaeghebeur wrote:
> > \documentclass{minimal}
> > % uncomment both to trigger:
> > % Package biblatex Error: Patching `ifthen' package failed.
>
> \begin{rant}
> Oh well, yet another package forking \ifthenelse

At least you have the good sense and politeness to provide a nice
error message in biblatex. Perhaps your advice could be incorporated
in there too: "Patching ifthen package failed. Try loading biblatex
before other packages."

Cheers,
Will

Heiko Oberdiek

unread,
Dec 12, 2007, 5:57:21 AM12/12/07
to
Philipp Lehman <devnull....@spamgourmet.com> wrote:

> Erik Quaeghebeur wrote:
>
> > \documentclass{minimal}
> > % uncomment both to trigger:
> > %     Package biblatex Error: Patching `ifthen' package failed.
>
> \begin{rant}
>
> Oh well, yet another package forking \ifthenelse, using yet another
> name. There's \ifthenelse, \org@ifthenelse, and \HyOrg@ifthenelse;
> now this nameref version comes up with \NROrg@ifthenelse. Being
> caught in the crossfire of babel and hyperref is such a pain in the
> ass.
>
> \end{rant}

* hyperref (\HyOrg@ifthenelse): \ifthenelse not changed anymore
* nameref (\NROrg@ifthenelse)
* redefines \ref and \pageref
* babel (\org@ifthenelse):
* redefines \pageref
* disables shorthands for the first argument

A hook in \ifthenelse that is called right before the first argument
is evaluated would solve most of the problems.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Morten Høgholm

unread,
Dec 12, 2007, 9:10:09 AM12/12/07
to
On Wed, 12 Dec 2007 11:57:21 +0100, Heiko Oberdiek wrote:

> A hook in \ifthenelse that is called right before the first argument
> is evaluated would solve most of the problems.

So you want

\long\def\ifthenelse#1{%
\toks@{#1}%
\@ifthen@else@hook
\TE@repl\or\TE@or
\TE@repl\and\TE@and
...
}
?


--
Morten

Heiko Oberdiek

unread,
Dec 12, 2007, 11:33:17 AM12/12/07
to
Morten Høgholm <morten....@gmail.com> wrote:

After \begingroup, e.g.:

\long\def\ifthenelse#1{%
\toks@{#1}%

\TE@repl\or\TE@or
...
\begingroup
\let\protect\@unexpandable@protect
\def\@setref##1##2##3{...}%
\def\value##1{...}%
\@ifthen@else@hook
\let\equal\TE@equal
...
}

The domain of the hook is the evaluation of #1:
\xdef\@gtemp{\expandafter\TE@eval\the\toks@\TE@endeval}%
#2 and #3 must not be affected.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Philipp Lehman

unread,
Dec 12, 2007, 12:19:33 PM12/12/07
to
Morten Høgholm wrote:

As Heiko wrote, the interesting spot is inside the first group. I
don't know what hyperref and nameref need to do in detail, but the
point of biblatex's patch is adding new atomic tests to \ifthenelse.
Since these tests are not functional in any other context, it's
natural to restrict them to the scope in which \ifthenelse evaluates
its first argument, i.e., the actual test.

Philipp Lehman

unread,
Dec 12, 2007, 12:32:27 PM12/12/07
to
Heiko Oberdiek wrote:

> * hyperref (\HyOrg@ifthenelse): \ifthenelse not changed anymore
> * nameref (\NROrg@ifthenelse)
> * redefines \ref and \pageref
> * babel (\org@ifthenelse):
> * redefines \pageref
> * disables shorthands for the first argument
>
> A hook in \ifthenelse that is called right before the first argument
> is evaluated would solve most of the problems.

That would certainly help a great deal. What I mean, however, is a
more general thing. Biblatex patches the original core definition of
\ifthenelse. This can't be done by way of a wrapper, the package
really needs to get its hands on the core macro. So the question the
package is confronted with is: what's the name of the macro which
holds the original definition of \ifthenelse? The more forks you add
to the mix, the more tedious the answer gets.

It's probably too late to do it now, and it would also require
cooperation on the part of babel, but what I'd prefer is this: the
first package which forks the original definition of \ifthenelse (or
any other macro, for that matter) should save the definition in
\org@ifthenelse. It's still possible to add more wrappers by forking
\ifthenelse a second or a third time, but the initial fork should use
a known (as a matter of convention) macro name. So, instead of:

\let\NROrg@ifthenelse\ifthenelse
\def\ifthenelse{%
...
\NROrg@ifthenelse}

you'd do the following:

\@ifundefined{org@ifthenelse}
{\let\org@ifthenelse\ifthenelse
\def\ifthenelse{%
...
\org@ifthenelse}}
{\let\NROrg@ifthenelse\ifthenelse
\def\ifthenelse{%
...
\NROrg@ifthenelse}}

Philipp Lehman

unread,
Dec 12, 2007, 12:48:12 PM12/12/07
to
Will Robertson wrote:

>> > %     Package biblatex Error: Patching `ifthen' package failed.
>

> At least you have the good sense and politeness to provide a nice
> error message in biblatex. Perhaps your advice could be incorporated
> in there too: "Patching ifthen package failed. Try loading biblatex
> before other packages."

The above is only the first part of the error message. In full, it
reads:

Patching `ifthen' package failed

This is an internal error typically caused by a conflict
between biblatex and some other package. Changing the package
loading order may fix the problem.

Maverick Woo

unread,
Dec 21, 2007, 4:28:43 PM12/21/07
to
On Dec 11, 6:20 pm, Philipp Lehman <devnull.1.leh...@spamgourmet.com>
wrote:

> Erik, as a general rule of thumb: always try loadingbiblatexbefore
> any conflicting packages. This is a perfectly sane solution because

> the waybiblatexdoes the patching is much less intrusive than the


> common way of forking macros. Hyperref and nameref will happily pick
> upbiblatex'spatched definitions.

I want to note that xifthen.sty triggers the "failed patching" error
too... Would you please also consider supporting it in the future?

Thanks!

--
Maverick

0 new messages