I updated my Ubuntu to the newest version 11.10 recently. Today when I use PGF again, i find many of my old examples cannot compile. It always give the error information as:

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

See the PGF Math package documentation for explanation.
Type  H <return>  for immediate help.

l.156 ...@\pgfmath@reciprocaltemp0000000\pgfmath@}

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

See the PGF Math package documentation for explanation.
Type  H <return>  for immediate help.

l.212 }

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

See the PGF Math package documentation for explanation.
Type  H <return>  for immediate help.

l.228 }

Does anyone have the same problem?

EDIT: I have followed the suggestions by many people here that I have installed TeXLive 2011 manually and updated the path, and logout and login again. The sad thing is that the problem still exists. I am wondering whether the problem really comes from the TeXlive 2009? :-(

  • 4
    As most people find out the hard way, Ubuntu ships with the ancient TeXlive 2009 (because that's what Debian does) – kahen Oct 26 '11 at 14:04
  • 4
    If you have the hard drive space for it, installing TeXlive 2011 manually to /usr/local/texlive/ isn't a terrible idea. But in order to not confuse dpkg, you can't uninstall Ubuntu's TeXlive 2009 (not without a lot of manual intervention at least). When it's installed there, make symlinks (ln -s) to the TeXlive 2011 binaries in /usr/local/bin and you'll be good to go (I think... I haven't done this myself) – kahen Oct 26 '11 at 14:19
  • 2
    The binaries should be in /usr/local/texlive/2011/⟨OSNAME⟩/bin or something like that, where ⟨OSNAME⟩ is the name of the system (e.g. win32 on Windows). So you'd do something like this (as root): cd /usr/local/texlive/2011/⟨OSNAME⟩/bin/; for $BINARY in *; do if [ -x $BINARY ]; then; ln -s $BINARY /usr/local/bin/$BINARY; fi; done. The alternative is to edit /etc/profile to add TeXlive 2011's binary directory to the beginning of your $PATH. – kahen Oct 26 '11 at 14:45
  • 1
    @kahen: TUG has pretty concise instructions on replacing the Debian-provided TeX Live with the upstream one. You just make a dummy package that "Provides" all the TeX-related things other Debian packages might depend on. – Mike Renfro Oct 26 '11 at 15:07
  • 2
    See also How to install “vanilla” TeXLive on Debian or Ubuntu? for help with the installation of the normal TeXLive. – Martin Scharrer Oct 26 '11 at 15:28

You could update your PGF version, either

  • get it from CTAN if this stable one is newer than yours from the Ubuntu repositories,
  • get PGF from CVS,
  • or get a build (TDS archive) from Paul's webpage.

If the problem persists, check which related packages you are using, such as pgfplots, which could cause the problem. Identify (by commenting out) and update, if necessary, to get a version which is compatible to your PGF version.

Note that the tlcontrib texlive repository has an up to date version of pgf-cvs but you cannot use it for two reasons:

  • the tlmgr is disabled with debian/ubuntu packaged texlive;
  • the tlcontrib repository works only with texlive 2010 and texlive 2011.
| improve this answer | |
  • I reinstalled PGF version 2.10.1. The problem still exists. – Anand Oct 26 '11 at 14:06
  • 2
    You can see it in your .log file, if necessary add the \listfiles command to your document. – Stefan Kottwitz Oct 26 '11 at 14:07
  • Thanks Stefan. Here it is: This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=pdflatex 2011.4.30) 19 JUL 2011 13:29 – Anand Oct 26 '11 at 14:08
  • @Anand I extended my answer. – Stefan Kottwitz Oct 26 '11 at 14:09
  • @Anand Yes, 2009 packages mixed with more current packages could cause it. I fully support Kahens suggestion to install TL 2011. I'm using 2011 on Ubuntu as well. – Stefan Kottwitz Oct 26 '11 at 14:22

Finally, I tried on another computer with Ubuntu 11.10 and everything the same as my computer. I downloaded one example from PGF site and it works well!!! So I come back to check my PGF files. After removing the line


It works again in my system!

Thank you a lot for your patient answers and warm-hearted helps! Special thanks go to Kahen and Stefan Kottwitz. Thank you very much!

| improve this answer | |
  • 2
    So the problem was that you were loading pgfmath twice! Hence all the already defined error messages. (Strange that pgfmath doesn't test to see if it's already been loaded or not.) – Andrew Stacey Oct 26 '11 at 18:53
  • How can I prevent it being loaded twice? – Anand Oct 26 '11 at 19:30
  • Err ... don't load it twice? Seriously, if you are loading any pgf packages, they almost certainly load pgfmath themselves so you don't need to load it explicitly. Thus simply omitting the \usepackage{pgfmath} will do. – Andrew Stacey Oct 26 '11 at 19:54
  • 3
    @AndrewStacey: this is most likely a bug in the pgf package, which should use \RequirePackage instead of \input when used with LaTeX. However, I don't blame the author, since the business of being compatible both with Plain and LaTeX is always a mess. – Bruno Le Floch Oct 26 '11 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.