早些时候我使用过 Gnuplot 并创建了一个 pdf
-file 然后我通过 includegraphics
实现在我的 Latex
-文档。
没有更好的方法可以直接从 Latex
绘图吗? -文档与 Gnuplot
?
最佳答案
基本上你可以跟着这个Youtube-Tutorial
所以这里是步骤:
第一步:设置环境变量
安装后MikTex , TexStudio和 Gnuplot点击 Start
-> 右键单击 Computer
-> Settings
-> Advanced Systemsettings
-> Environment variables
在这里,您必须创建 3 个新变量:
► PATH
C:\Program Files (x86)\MiKTeX 2.9\miktex\bin;C:\Program Files (x86)\gnuplot\bin
► gnuplot
C:\Program Files (x86)\gnuplot\bin
► GNUPLOT_LIB
C:\Program Files (x86)\gnuplot\demo
第 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}
关于latex - 如何使用 Gnuplot 在 Latex 中绘图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36386656/