3

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? :-(

Stefan Kottwitz
  • 231,401
Anand
  • 3,696
  • 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
  • Thanks Kahen. Do you know a solution? Shall I install TeXlive 2011? – Anand Oct 26 '11 at 14:07
  • 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
  • Thanks Kahen, I am now installing TeXlive 2011 now. I will see whether it helps. :-) – Anand Oct 26 '11 at 14:21
  • I have installed TeXlive 2011. Do you know how to make the symbolic link? I find my pdftex under /usr/bin, instead of /usr/local/bin – Anand Oct 26 '11 at 14:36
  • 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
  • Thanks Kahen. I updated my /etc/profile by adding the following line PATH=/usr/local/texlive/2011/bin/x86_64-linux:$PATH, it seems not working... – Anand Oct 26 '11 at 14:55
  • /etc/profile is read on login (or when it's manually sourced, of course). Logout and back in again. Also, the line should probably be something like this instead: [ -d /usr/local/texlive/2011/bin/x86_64-linux ] && PATH=/usr/local/texlive/2011/bin/x86_64-linux:${PATH} – kahen Oct 26 '11 at 15:04
  • 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
  • @kahen I would not recommend making symbolic links in /usr/local/bin as they might be overwritten by an update of the Ubuntu TeX packages. It's better to change .profile or adding a file in /etc/profile.d as explained here – egreg Oct 26 '11 at 15:08
  • 1
    @egreg no, dpkg doesn't touch /usr/local. Ubuntu's TeX binaries are in /usr/bin. – kahen Oct 26 '11 at 15:11
  • It is sad that after updating the link and login again. Even my normal tex files have compiling problems. Some packages are missing. This is not a big deal I think. But the PGF file still couldn't be complied. The same problem remains. :-( I really regretted to have updated to Ubuntu 11.10. – Anand Oct 26 '11 at 15:18
  • @kahen Right; but I wouldn't recommend the symbolic links nontheless. The profile.d way is surely neater and easier. – egreg Oct 26 '11 at 15:19
  • 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
  • @egreg: It is really a matter of opinion, by I would say that making symlinks in /usr/local/bin is definitely the "unixy" way of doing it. The package manager will never touch anything under /usr/local, and the binaries will be accessible to everybody, no matter what shell they are using. – Jan Hlavacek Oct 26 '11 at 16:33
  • 1
    I didn't realize until now that you did have a working pgf before the Ubuntu upgrade. That's interesting, I wonder what changed TeXwise in the latest Ubuntu. – Jan Hlavacek Oct 26 '11 at 16:41
  • @Jan Hlavacek, yes, I worked with PGF for more than one year. I got this problem only after my updating my Ubuntu to 11.10 recently. – Anand Oct 26 '11 at 16:47
  • The problem is that I have tried to install TeXlive 2011 and update the path. But the problem still exists. :-( – Anand Oct 26 '11 at 16:57
  • 1
    The "already defined" makes me wonder if something is being loaded from the Ubuntu version. Check your log file for any files under /usr/share, those indicate that tex is loading some files from the Ubuntu version of TL which it shouldn't. (I run TL2011 on a Debian system with no troubles so I know that it is possible to mix them.) – Andrew Stacey Oct 26 '11 at 18:03
  • 1
    Posting the log file could help, we could see what files are being loaded. – Jan Hlavacek Oct 27 '11 at 00:15

2 Answers2

5

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.
cjorssen
  • 10,032
  • 4
  • 36
  • 126
Stefan Kottwitz
  • 231,401
  • 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
  • @Anand yes, also, however at this moment it's a 11.04 system. Btw. I suggest let's clean up and remove some comments afterwards. – Stefan Kottwitz Oct 26 '11 at 14:24
  • You could also try to install pgf 2.10.1 and remove the debian pgf packages. Debian (and, I suppose, Ubuntu) packages pgf separately from the rest of TeXLive, so you should be able to remove them using your favorite package manager. I used to run pgf 2.10.0 with Debian's TeXLive 2009 without any problems. Something may have changed in 2.10.1, though. – Jan Hlavacek Oct 26 '11 at 16:38
  • Thanks Jan Hlavacek. My version is PGF 2.10.1 indeed. :-) – Anand Oct 26 '11 at 16:46
0

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

\usepackage{pgfmath}

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!

Anand
  • 3,696
  • 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