[Tex/LaTex] usepgfplotslibrary – undefined control sequence

errorspgfplotsunits

I have problem with following example code:

%& --shell-escape --enable-write-18
\documentclass[a4paper,10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{polski}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{units}

\begin{document} 
    \begin{tikzpicture}
        \begin{axis}[
            use units,
            x unit=m,x unit prefix=k,
            y unit=N,y unit prefix=m,
            xlabel=Distance,ylabel=Force]

            \addplot coordinates {
                (1,2.3)
                (2,2.7)
                (3,2.1)
                (4,1.8)
                (5,1.5)
                (6,1.1)
            };
        \end{axis}
    \end{tikzpicture}
\end{document}

A cannot use units in axis labels.
A similar code was included in this documentation: http://www.iro.umontreal.ca/~simardr/pgfplots.pdf on page 227.

Errors:

Missing \begin{document}. \usepgfplotslibrary{u (followed by: nits})
Package pgfkeys Error: I do not know the key '/pgfplots/use units' and I am going to ignore it. Perhaps you misspelled it.
Package pgfkeys Error: I do not know the key '/pgfplots/x unit' and I am going to ignore it. Perhaps you misspelled it.
Package pgfkeys Error: I do not know the key '/pgfplots/x unit prefix' and I am going to ignore it. Perhaps you misspelled it.
Package pgfkeys Error: I do not know the key '/pgfplots/y unit' and I am going to ignore it. Perhaps you misspelled it.
Package pgfkeys Error: I do not know the key '/pgfplots/y unit prefix' and I am going to ignore it. Perhaps you misspelled it.
Undefined control sequence:  \usepgfplotslibrary (followed by: {units})

What's more, the command \usepgfplotslibrary completely does not work with any other pgfplots library.
I don't know what is wrong, but i have to get this working :/
Thank you in advance for your help.

I'm running Debian Sid. Texlive (2009-11), pgf (2.10-1)

Best Answer

When I try your code with the Debian/Ubuntu packages, I get

! Undefined control sequence.
<recently read> \usepgfplotslibrary 

l.7 \usepgfplotslibrary
                       {units}

(and if I ignore that error, then your errors follow).

I'd guess that the version of pgfplots in the Debian packages (i.e. in TL 2009) doesn't have any additional libraries and you are looking at the wrong manual. Ubuntu 11.04 (which uses the Debian packages, so I guess Debian Sid is the same) comes with pgfplots 1.2.2, while the current version is 1.4.1.

As always I recommend to install TeX Live directly from TUG instead of using the Debian packages. That way you can always get current package versions by running sudo tlmgr update --all. Alternatively, you can try installing pgfplots directly from CTAN.

Related Question