[Tex/LaTex] hyperref conflicts with todonotes and chemfig packages

hyperrefincompatibilitypgfmathtikz-pgf

I'm using TexLive 2012 from the openSUSE buildservice publishing repository, and a document that would compile with TeXLive 2011 now effects error messages such as:

Package PGF Math Error: The function `add' already exists.

Package PGF Math Error: The function `subtract' already exists.

and so on.

This is caused by todonotes and chemfig, since both load tikz. Is there a way to resolve this conflict?

An example, as requested:

\documentclass[a4paper]{scrbook}
\usepackage{hyperref}
\usepackage{todonotes}
\begin{document}
test
\end{document}

The relevant excerpt of the log from texlive 2011:

(/usr/share/texmf/tex/latex/pgf/compatibility/pgfcomp-version-1-18.sty
Package: pgfcomp-version-1-18 2007/07/23 v2.10 (rcs-revision 1.1)
))
(/usr/share/texmf/tex/latex/pgf/utilities/pgffor.sty
(/usr/share/texmf/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/share/texmf/tex/generic/pgf/utilities/pgfkeys.code.tex))
(/usr/share/texmf/tex/generic/pgf/utilities/pgffor.code.tex
Package: pgffor 2010/03/23 v2.10 (rcs-revision 1.18)

and that of the log from texlive 2012:

(/usr/share/texmf/tex/latex/pgf/compatibility/pgfcomp-version-1-18.sty
Package: pgfcomp-version-1-18 2007/07/23 v2.10 (rcs-revision 1.1)
))
(/usr/share/texmf/tex/latex/pgf/utilities/pgffor.sty
(/usr/share/texmf/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/share/texmf/tex/generic/pgf/utilities/pgfkeys.code.tex))
(/usr/share/texmf/tex/latex/pgf/math/pgfmath.sty
(/usr/share/texmf/tex/generic/pgf/math/pgfmath.code.tex
(/usr/share/texmf/tex/generic/pgf/math/pgfmathcalc.code.tex
(/usr/share/texmf/tex/generic/pgf/math/pgfmathutil.code.tex)
(/usr/share/texmf/tex/generic/pgf/math/pgfmathparser.code.tex
\pgfmath@dimen=\dimen142
\pgfmath@count=\count113
\pgfmath@box=\box35
\pgfmath@toks=\toks24
\pgfmath@stack@operand=\toks25
\pgfmath@stack@operation=\toks26
)
(/usr/share/texmf/tex/generic/pgf/math/pgfmathfunctions.code.tex
(/usr/share/texmf/tex/generic/pgf/math/pgfmathfunctions.basic.code.tex 

Best Answer

The cause is that the latest version of pgf has the line

\RequirePackage{pgfmath}

in tex/latex/pgf/utilities/pgffor.sty. If I comment it out, then everything works fine. Here is the bug report for this.

Related Question