![pgf 奇怪的错误“缺失数字被视为零”](https://linux22.com/image/448336/pgf%20%E5%A5%87%E6%80%AA%E7%9A%84%E9%94%99%E8%AF%AF%E2%80%9C%E7%BC%BA%E5%A4%B1%E6%95%B0%E5%AD%97%E8%A2%AB%E8%A7%86%E4%B8%BA%E9%9B%B6%E2%80%9D%20.png)
我正在准备一篇论文。我正在使用 Visual Studio Code 和 Miktex。在阅读了这里关于“缺失数字,视为零”的许多相关问题后,我仍然不明白为什么以下示例会导致这样的错误消息。我使用 Geobra Classic 生成此代码。
\documentclass[10pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{ccqqqq}{rgb}{0.8,0,0}
\definecolor{qqwuqq}{rgb}{0,0.39215686274509803,0}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\begin{axis}[
x=1cm,y=1cm,
axis lines=middle,
xmin=-5.912600483813963,
xmax=10.112505461619168,
ymin=-5.0000004190058975,
ymax=5.000000419005901,
xtick={-5,-4,...,10},
ytick={-5,-4,...,5},]
\clip(-5.912600483813963,-5.0000004190058975) rectangle (10.112505461619168,5.000000419005901);
\draw[line width=2pt,color=qqwuqq,smooth,samples=100,domain=-2.791287717641796:0.9999998864501113] plot(\x,{sqrt((\x)^(3)-6*(\x)+5)});
\draw[line width=2pt,color=qqwuqq,smooth,samples=100,domain=1.791293439719924:10.112505461619168] plot(\x,{sqrt((\x)^(3)-6*(\x)+5)});
\draw[line width=2pt,color=ccqqqq,smooth,samples=100,domain=-2.791287717641796:0.9999998864501113] plot(\x,{0-sqrt((\x)^(3)-6*(\x)+5)});
\draw[line width=2pt,color=ccqqqq,smooth,samples=100,domain=1.791293439719924:10.112505461619168] plot(\x,{0-sqrt((\x)^(3)-6*(\x)+5)});
\begin{scriptsize}
\draw[color=qqwuqq] (-2.753604403186806,0.22489541633604176) node {$f$};
\draw[color=ccqqqq] (-2.753604403186806,0.026150629806518583) node {$g$};
\end{scriptsize}
\end{axis}
\end{tikzpicture}
\end{document}
错误信息说:
<to be read again>
n
l.26 \end{axis}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
为什么我会得到缺失的数字,并将其视为零错误?
谢谢3000!
答案1
感谢大家,Ulrike Fischer 找到了我问题的答案。我只需要将我的函数更改为plot(\x,{sqrt(abs((\x)^(3)-6*(\x)+5))});