【发布时间】:2015-01-02 17:07:01
【问题描述】:
gnuplot 可以将数据绘制到像pdf 这样的文件中。然后,例如可以使用pdflatex 生成使用生成图的论文。
一个问题是gnuplot 和pdflatex 都为文件添加了一些边距。因此,最终论文的页边距相当大。
可以使用pdfcrop 删除空白空间,使纸张结构更紧凑。
我想知道是否有办法自动裁剪gnuplot 的输出,例如通过激活gnuplot 中的设置。
到目前为止,make 脚本的工作方式如下:
plotter.gnuplot
set terminal pdf
set output 'temp.pdf'
plot "data.dat" u 1 t "f(x)" w lines
makefile
all : plotter.gnuplot data.dat
gnuplot < plotter.gnuplot
pdfcrop "temp.pdf" "somefile.pdf"
rm "temp.pdf"
pdflatex book.tex
其中book.tex 包括somefile.pdf。
【问题讨论】:
-
我真的不明白这一点。对于
pdflatex,你可以调整你想要的一切(\includegraphics的图形大小和geometry包的边距)。对于gnuplot,您可以调整边距,请参阅help set margin)。还有什么可以做的?而且我认为\includegraphics也有一个“裁剪”选项... -
我认为这个问题是相关的。需要在不查看边界框值的情况下进行裁剪并在
\includegraphics中使用它们(使用 trim=l b r t),既不使用像pdfcrop这样的附加命令,也不需要在 OS/X 上使用像skim这样的外部工具进行裁剪.裁剪命令适用于 gif 终端:set ter gif crop,但不适用于 pdfcairo。 -
为了缩短您的脚本,您可以使用相同的文件名:
pdfcrop "somefile.pdf" "somefile.pdf",因为 pdfcrop 将其临时 pdf 文件重命名为输出文件名。此外,您可以在第一个字符上使用感叹号将此命令插入到 gnuplot 脚本文件中:!pdfcrop "somefile.pdf" "somefile.pdf"。如果您没有正确的外壳,它可能无法在 Windows 上运行。