# Why am I getting the PGF Math Error: Unknown function getargs'?

I'm using TiKZ 2.10 to create a document that includes a tikzpicture with \pgfmathmin (yes, I also have \usetikzlibrary{calc}). Previously the document compiled fine but now I get an error like:

Package PGF Math Error: Unknown function getargs' (in 'getargs(3,4)')

I can eliminate this by replacing the occurrence of \pgfmathmin{3}{4} with \pgfmathparse{min(3,4)} but I'm not sure why the former no longer works.

Am I misusing the \pgfmathmin command?

EDIT: A minimal example to compile (with a version of TiKZ approximately 2.10, the version included in miktex 2.9)

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\pgfmathmin{1}{2} \pgfmathresult % This yields an error message about getargs
\end{document}

-
Please post a full minimal example. –  Joseph Wright Jan 26 '11 at 8:37
@Joseph, I don't like unnecessarily cluttering up my questions with the surrounding code. Is it a policy of the site that these minimal examples should be included?, because it seems to me that anyone who could potentially answer my question would know how to put in the surrounding code. –  bryn Jan 26 '11 at 10:23
@bryn. For a question where 'something doesn't work', a minimal example is usually a good idea as people have various ideas of 'standard' preambles. –  Joseph Wright Jan 26 '11 at 10:52
@bryn: a lot of times this errors occur because of additional loaded packages. Many times the error disappears when the existing document is minimised. Also, the chance that people answer your question is much higher if people can just copy&paste your example and run it on their machines instead of having to code it by themselves. –  Martin Scharrer Jan 26 '11 at 10:52
@bryn: The act of preparing a minimal example is an important step to pinpointing the error, and can often eliminate the need to ask a question. –  Matthew Leingang Jan 26 '11 at 13:46

## 2 Answers

It seems like something's wrong in the implementation of the \pgfmathmin and \pgfmathmax commands.

In pgfmathfunctions.misc.code.tex (in the folder texlive/2010/texmf-dist/tex/generic/pgf/math), you can change the two occurrences of the line

    \pgfmathparse{getargs(#1,#2)}%


to

    \pgfmathparse{#1,#2}%


Then the following code should work

\documentclass{minimal}
\usepackage{tikz}
\begin{document}

\pgfmathmin{1,-3,5}{0,2} \pgfmathresult % This doesn't work without the fix

\pgfmathparse{min(1,-3,5,0,2)} \pgfmathresult % This does

\end{document}

-
Which version of PGF did you use here? There's been a new release on texlive in the past few days. I wonder if this bug has already been fixed. If not, consider sending the patch to the pgf-users mailing list. –  Matthew Leingang Jan 26 '11 at 13:48
@Matthew Thanks for the pointer. The error is still present in the CVS version; I submitted the patch. –  Jake Jan 26 '11 at 15:29

The problem occurs with pgf 2.00 cvs and now with pgf 2.1. The problem occurs also with pgfmathmax. The first version of pgfmathmin works with only 2 arguments. The best way is to avoid pgfmathmin and pgfmathmax actually and to use the new function and to write pgfmathparse{min(1,-3,5,0,2)} With pgfmathmin you use pgfmathparse indirectly.

Alain Matthes

-
"With pgfmathmin you use pgfmathparse indirectly." -- this is interesting. I assumed that pgfmathmin was a (faster) primitive operation, and that pgfmathparse would be slower since it needs to call pgfmathmin. –  bryn Jan 26 '11 at 20:36
@bryn, someone might think so. But the code comments say that \pgfmathmin and \pgfmathmax are only defined for backwards compatibility. –  Martin Scharrer Jan 27 '11 at 9:59