英文:
gnuplot to display an equation title nicely with Latex, but I would like to avoid producing a tex output for that, that I don't know how to handle
问题
我正在执行以下操作:
gnuplot testGNUPlot.dat -p
其中testGNUPlot.dat
的内容如下:
plot [-4:4] [-30:5] -x**2+2*x-3 title '$ -x^2-2x-3 $'
我收到了以下结果,这不是预期的结果:
$ -x^2-2x-3 $
没有转换成其期望的 -x²-2x-3 形式,特别是在曲线图例附近。如果我尝试将标题显示为 $\sqrt{-x^2-2x-3}$
,则平方根符号永远不会转化为其图形对应物。
我该如何实现这一目标?
我希望避免使用tex输出,因为目前这会导致像epslatex终端无法写入标准输出
这样的消息,我不知道如何处理。
(我只需要在我的Windows系统上正确显示公式,靠近其紫色符号)。
如果确实需要一些tex指令,它们是否可以以确保脚本仍然能够从命令行执行并生成显示曲线的窗口的方式进行管理?
英文:
I'm executing a:
gnuplot testGNUPlot.dat -p
with testGNUPlot.dat
having this content:
plot [-4:4] [-30:5] -x**2+2*x-3 title '$ -x^2-2x-3 $'
I'm receiving this result, which isn't the expected one:
$ -x^2-2x-3 $
isn't transformed, through Latex near the curve legend to its expected -x²-2x-3 form.
(it's more obvious if I try to display for title: $\sqrt{-x^2-2x-3}$
: the square root symbol will never be translated to its graphical counterpart).
How shall I achieve this?
I would like to avoid a tex output, that is currently leading me to messages like epslatex terminal cannot write to standard output
, that I don't know how to manage.
(I only need my windows to display the formula correctly near its violet symbol).
If some tex directives are really needed, can they be managed a way they ensure that the script can still, however :
- execute from a command line
- produce a windows with the curve displayed?
答案1
得分: 2
以下是代码部分的翻译:
The following works for me with Windows 10 and a MiKTeX installation.
Ingredients:
cairolatex
终端- 带有
pdflatex
的 LaTeX 安装 - PDF 阅读器(例如,Windows 上的 SumatraPDF 会自动显示更新后的 PDF,而Acrobat Reader 会阻止 gnuplot 写入 PDF 文件)
pdflatex
可执行文件的路径已经在您的系统路径中,或者您可以在 gnuplot 命令中提供绝对路径。
gnuplot 脚本将创建文件 SO75712292.tex
和 SO75712292-inc.pdf
pdflatex
将创建最终的SO75712292.pdf
.
脚本:
### 创建 LaTeX 格式的输出
reset session
set term cairolatex standalone size 10cm,7cm
OUTPUT = "SO75712292.tex"
set output OUTPUT
plot [-4:4] [-30:5] -x**2+2*x-3 title '$ -x^2-2x-3 $'
set output
system(sprintf('pdflatex.exe %s', OUTPUT))
### 脚本结束
结果: (SumatraPDF 中的 SO75712292.pdf
屏幕截图)
英文:
The following works for me with Windows 10 and a MiKTeX installation.
Ingredients:
cairolatex
terminal- LaTeX installation with
pdflatex
- PDF viewer (e.g. SumatraPDF for Windows will automatically show the updated PDF, whereas Acrobat Reader will block gnuplot from (over)writing the PDF file)
Either the path of the pdflatex
executable is already in your system path or alternatively you can give the absolute path in the gnuplot command.
- the gnuplot script will create the files
SO75712292.tex
andSO75712292-inc.pdf
pdflatex
will create the finalSO75712292.pdf
.
Script:
### create LaTeX formatted output
reset session
set term cairolatex standalone size 10cm,7cm
OUTPUT = "SO75712292.tex"
set output OUTPUT
plot [-4:4] [-30:5] -x**2+2*x-3 title '$ -x^2-2x-3 $'
set output
system(sprintf('pdflatex.exe %s', OUTPUT))
### end of script
Result: (screenshot of SO75712292.pdf
from SumatraPDF)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论