usepgfplotslibrary - 未定义的控制序列

usepgfplotslibrary - 未定义的控制序列

我对以下示例代码有疑问:

%& --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 不能在轴标签中使用单位。此文档中包含类似的代码:http://www.iro.umontreal.ca/~simardr/pgfplots.pdf在第227页。

错误:

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})

此外,命令 \usepgfplotslibrary 完全无法与任何其他 pgfplots 库一起使用。我不知道哪里出了问题,但我必须让它正常工作 :/ 提前感谢您的帮助。

我正在运行 Debian Sid。Texlive(2009-11),pgf(2.10-1)

答案1

当我使用 Debian/Ubuntu 软件包尝试你的代码时,我得到了

! Undefined control sequence.
<recently read> \usepgfplotslibrary 

l.7 \usepgfplotslibrary
                       {units}

(如果我忽略该错误,那么您的错误就会随之而来)。

我猜想 Debian 软件包中的 pgfplots 版本(即 TL 2009)没有任何附加库,并且您正在查看错误的手册。Ubuntu 11.04(使用 Debian 软件包,所以我猜 Debian Sid 是相同的)附带 pgfplots 1.2.2,而当前版本是 1.4.1。

与往常一样,我建议直接从拖船而不是使用 Debian 软件包。这样,您始终可以通过运行来获取当前软件包版本sudo tlmgr update --all。或者,您可以尝试直接从 CTAN 安装 pgfplots。

相关内容