之前我使用了Gnuplot并创建了一个pdf
-文件,然后通过Latex
-文档中的includegraphics
实现了该文件。
有没有更好的方法可以直接从Latex
-文档中使用Gnuplot
进行绘图?
基本上你可以按照这个Youtube教程
以下是步骤:
步骤1:设置环境变量
安装MikTex后,TexStudio和Gnuplot点击Start
->Computer
->Settings
->Advanced Systemsettings
->Environment variables
在这里你必须创建3个新的变量:
► PATH
C:Program Files (x86)MiKTeX 2.9miktexbin;C:Program Files (x86)gnuplotbin
► gnuplot
C:Program Files (x86)gnuplotbin
► GNUPLOT_LIB
C:Program Files (x86)gnuplotdemo
步骤2:编辑TexStudio转到TexStudio并单击Options
->Configure TexStudio
->Commands
这里你需要更新上面的两个命令
► LaTeX
"C:/Program Files (x86)/MiKTeX 2.9/miktex/bin/latex.exe" -src -interaction=nonstopmode %.tex
► PdfLaTeX
pdflatex.exe -synctex=1 -shell-escape -enable-write18 -interaction=nonstopmode %.tex
步骤3:在Latex中使用Gnuplot进行编码
documentclass[a4paper]{scrartcl}
usepackage[miktex]{gnuplottex}
begin{document}
begin{figure}[H]
centering
begin{gnuplot}[terminal=pdf]
set terminal pdf enhanced size 14.5cm, 4cm
set key top left
set xlabel 'x [1]'
set ylabel 'y [1]'
f1(x)=sin(x**2)
plot f1(x) title 'y_1 = sin(x^2)'
end{gnuplot}
caption{Plot}
end{figure}
end{document}