epslatex 无法生成正确的输出文件 .eps 和 .tex(缺少 include-graphics 行)

epslatex 无法生成正确的输出文件 .eps 和 .tex(缺少 include-graphics 行)

我正在尝试使用 gnuplot (版本 4.6,最近安装) 的 epslatex 生成一个简单的图。脚本如下:

set terminal epslatex 8
set output 'sample1.eps'
set size 0.75,0.75
set xrange [-pi:pi]
set yrange [0:1.2]
set xlabel "$x$"
set ylabel "$y$"
plot sin(x)*sin(x) title "$\\sin^2(x)$"

不幸的是,生成的 sample1.tex 文件缺少(如果我没记错的话)代码的最后几行,其中应该有一个“include-graphics{}”声明:

% GNUPLOT: LaTeX picture with Postscript
\begingroup
  \makeatletter
  \providecommand\color[2][]{%
    \GenericError{(gnuplot) \space\space\space\@spaces}{%
      Package color not loaded in conjunction with
      terminal option `colourtext'%
    }{See the gnuplot documentation for explanation.%
    }{Either use 'blacktext' in gnuplot or load the package
      color.sty in LaTeX.}%
    \renewcommand\color[2][]{}%
  }%
  \providecommand\includegraphics[2][]{%
    \GenericError{(gnuplot) \space\space\space\@spaces}{%
      Package graphicx or graphics not loaded%
    }{See the gnuplot documentation for explanation.%
    }{The gnuplot epslatex terminal needs graphicx.sty or graphics.sty.}%
    \renewcommand\includegraphics[2][]{}%
  }%
  \providecommand\rotatebox[2]{#2}%
  \@ifundefined{ifGPcolor}{%
    \newif\ifGPcolor
    \GPcolorfalse
  }{}%
  \@ifundefined{ifGPblacktext}{%
    \newif\ifGPblacktext
    \GPblacktexttrue
  }{}%
  % define a \g@addto@macro without @ in the name:
  \let\gplgaddtomacro\g@addto@macro
  % define empty templates for all commands taking text:
  \gdef\gplbacktext{}%
  \gdef\gplfronttext{}%
  \makeatother
  \ifGPblacktext
    % no textcolor at all
    \def\colorrgb#1{}%
    \def\colorgray#1{}%
  \else
    % gray or color?
    \ifGPcolor
      \def\colorrgb#1{\color[rgb]{#1}}%
      \def\colorgray#1{\color[gray]{#1}}%
      \expandafter\def\csname LTw\endcsname{\color{white}}%
      \expandafter\def\csname LTb\endcsname{\color{black}}%
      \expandafter\def\csname LTa\endcsname{\color{black}}%
      \expandafter\def\csname LT0\endcsname{\color[rgb]{1,0,0}}%
      \expandafter\def\csname LT1\endcsname{\color[rgb]{0,1,0}}%
      \expandafter\def\csname LT2\endcsname{\color[rgb]{0,0,1}}%
      \expandafter\def\csname LT3\endcsname{\color[rgb]{1,0,1}}%
      \expandafter\def\csname LT4\endcsname{\color[rgb]{0,1,1}}%
      \expandafter\def\csname LT5\endcsname{\color[rgb]{1,1,0}}%
      \expandafter\def\csname LT6\endcsname{\color[rgb]{0,0,0}}%
      \expandafter\def\csname LT7\endcsname{\color[rgb]{1,0.3,0}}%
      \expandafter\def\csname LT8\endcsname{\color[rgb]{0.5,0.5,0.5}}%
    \else
      % gray
      \def\colorrgb#1{\color{black}}%
      \def\colorgray#1{\color[gray]{#1}}%
      \expandafter\def\csname LTw\endcsname{\color{white}}%
      \expandafter\def\csname LTb\endcsname{\color{black}}%
      \expandafter\def\csname LTa\endcsname{\color{black}}%
      \expandafter\def\csname LT0\endcsname{\color{black}}%
      \expandafter\def\csname LT1\endcsname{\color{black}}%
      \expandafter\def\csname LT2\endcsname{\color{black}}%
      \expandafter\def\csname LT3\endcsname{\color{black}}%
      \expandafter\def\csname LT4\endcsname{\color{black}}%
      \expandafter\def\csname LT5\endcsname{\color{black}}%
      \expandafter\def\csname LT6\endcsname{\color{black}}%
      \expandafter\def\csname LT7\endcsname{\color{black}}%
      \expandafter\def\csname LT8\endcsname{\color{black}}%
    \fi
  \fi
  \setlength{\unitlength}{0.0500bp}%
  \begin{picture}(5400.00,3780.00)%
    \gplgaddtomacro\gplbacktext{%
      \csname LTb\endcsname%
      \put(688,512){\makebox(0,0)[r]{\strut{} 0}}%
      \put(688,1025){\makebox(0,0)[r]{\strut{} 0.2}}%
      \put(688,1537){\makebox(0,0)[r]{\strut{} 0.4}}%
      \put(688,2050){\makebox(0,0)[r]{\strut{} 0.6}}%
      \put(688,2562){\makebox(0,0)[r]{\strut{} 0.8}}%
      \put(688,3075){\makebox(0,0)[r]{\strut{} 1}}%
      \put(688,3587){\makebox(0,0)[r]{\strut{} 1.2}}%
      \put(882,352){\makebox(0,0){\strut{}-3}}%
      \put(1570,352){\makebox(0,0){\strut{}-2}}%
      \put(2259,352){\makebox(0,0){\strut{}-1}}%
      \put(2948,352){\makebox(0,0){\strut{} 0}}%
      \put(3636,352){\makebox(0,0){\strut{} 1}}%
      \put(4325,352){\makebox(0,0){\strut{} 2}}%
      \put(5013,352){\makebox(0,0){\strut{} 3}}%
      \put(128,2049){\rotatebox{-270}{\makebox(0,0){\strut{}$y$}}}%
      \put(2947,112){\makebox(0,0){\strut{}$x$}}%
    }%
    \gplgaddtomacro\gplfronttext{%
      \csname LTb\endcsname%
      \put(4376,3444){\makebox(0,0)[r]{\strut{}$\sin^2(x)$}}%
    }%

此外,生成的 *.eps 文件仅包含图表的框架。

我知道这个例子非常简单,但即使使用我以前使用过的脚本(一个半月前,笔记本电脑没有重大变化,Xubuntu 12.04)在同一台机器上成功生成 epslatex 图,也会发生这种情况。

看起来好像有什么东西阻止了 .tex 文件的生成完成,但我不知道那是什么。我也不知道 gnuplot 是否允许某种调试,但这个问题确实很奇怪。

知道我应该从哪里开始寻找吗?我已经尝试重新安装 gnuplot,但没有成功。

答案1

您应该使用 tex 文件的名称作为输出。即:

set output 'sample1.tex' 

然后 eps 文件将具有相同的名称,但扩展名为.eps。此外,在某些情况下,需要通过添加来关闭输出文件

set output 

(命令后没有文件名)plot

相关内容