在我尝试运行的代码下方。我收到多个错误,例如! Undefined control sequence. \input pictex\magnification
和! I can't find file `pictex=1200'.<to be read again>\relax \input pictex\magnification=\magstep1
。
我是否需要下载其他软件包,或者代码中是否有错误(我使用 c++ 和 python 编程,但不熟悉 Tex)?我想将数据输出到 PDF 文件。
\input pictex\magnification=\magstep1\nopagenumbers
\centerline {
\beginpicture
\setcoordinatesystem units <0.45 truein, 1.5 truein>
\setplotarea x from -5 to 5, y from 0 to 1.0
\axis bottom
ticks numbered from -5 to 5 by 1
/
\plot "Normal.txt"
\plot -5.2 0 -5.1 0 -5.1 1 -5.2 1 /
\put {0} [cr] at -5.3 0
\put {$\frac{1}{\sqrt{2\pi}}$} [cr] at -5.3 1
\put {\sl Standard Normal Histogram} at 0 1.2
\sethistograms
\plot "HistogramData.txt"
\endpicture}\vfill\end
答案1
您收到此错误:
! Undefined control sequence. <recently read> \frac <argument> $\frac
错误在于这\frac{}{}
不是 TeX 能够理解的控制序列。对于分数,请使用\over
TeX 原语。
因此更换线路
\put {$\frac{1}{\sqrt{2\pi}}$} [cr] at -5.3 1
经过
\put {$1\over\sqrt{2\pi}$} [cr] at -5.3 1
答案2
我不确定它是否有帮助,但这里有一个使用 TikZ 的相同代码的示例:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=0.45]
\draw[->] (-5.2,0) -- (5.2,0) node[right] {$x$};
\draw[->] (0,0) -- (0,1.0) node[above] {$y$};
\foreach \x in {-5,-4,...,5} {
\draw (\x,-0.1) -- (\x,0.1);
}
\node at (-5.3,0) {0};
\node at (-5.3,1) {$\frac{1}{\sqrt{2\pi}}$};
\node at (0,1.2) {\sl Standard Normal Histogram};
\end{tikzpicture}
\end{document}