Latex gnuplot与osx中的texshop

Latex gnuplot与osx中的texshop,latex,gnuplot,Latex,Gnuplot,我已经通过macports安装了gnuplot,但当我在texshop中编译latex文档时,它没有显示绘图,我在日志文件中得到以下错误: Package pgf Warning: Plot data file `tutorial.x.table' not found. on input line 17. Package pgf Warning: Plot data file `tutorial.sin.table' not found. on input li ne 19. Pack

我已经通过macports安装了gnuplot,但当我在texshop中编译latex文档时,它没有显示绘图,我在日志文件中得到以下错误:

Package pgf Warning: Plot data file `tutorial.x.table' not found. on input line
 17.


Package pgf Warning: Plot data file `tutorial.sin.table' not found. on input li
ne 19.


Package pgf Warning: Plot data file `tutorial.exp.table' not found. on input li
ne 21.
我只是想编译这个基本示例:

% Author: Till Tantau
% Source: The PGF/TikZ manual
\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}

% GNUPLOT required
\begin{document}
\pagestyle{empty}


\begin{tikzpicture}[domain=0:4]
    \draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
    \draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
    \draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
    \draw[color=red] plot[id=x] function{x} 
        node[right] {$f(x) =x$};
    \draw[color=blue] plot[id=sin] function{sin(x)} 
        node[right] {$f(x) = \sin x$};
    \draw[color=orange] plot[id=exp] function{0.05*exp(x)} 
        node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}


\end{document}

是的,您需要将tikz创建的.gnuplot文件转换为表文件。对此,您有两种选择:

  • 您可以使用额外的命令行开关--shell escape(有时也称为--enable-write-18)运行(pdf)latex,然后自动为您运行gnuplot。(不过,允许从pdflatex中启动任意程序可能会让您感到不舒服。)

  • 您可以自己在test.exp.gnuplot、test.sin.gnuplot、test.x.gnuplot等文件上运行gnuplot。只需
    gnuplot test.exp.gnuplot
    即可。(此处无法验证,因为我的gnuplot版本太旧。)

  • 它起作用了!因此“-shell escape”位于“preferences->Engine”下,并将“pdfTeX”作为“pdfTeX”和“pdflatex”之后的第一个参数。你真厉害