epslatex doesn't generate correct output files .eps and .tex (missing include-graphics line)
You are supposed to use the name of the tex file for the output. That is:
set output 'sample1.tex'
Then the eps file will have the same name, but extension .eps
. Also, in some circumstances, one needs to close the output file by adding
set output
(with no filename) after the plot
command.
Related videos on Youtube
Jorgina
Updated on January 23, 2020Comments
-
Jorgina almost 4 years
I'm trying to generate a simple plot using the epslatex of gnuplot (version 4.6, recently installed). The script is the following:
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)$"
Unfortunately, the generated sample1.tex file is missing (if I'm not mistaken) the last lines of the code, where there should be an "include-graphics{}" declaration:
% 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)$}}% }%
Also, the generated *.eps file contains only the frame of the plot.
I know the example is very simple, but this happens even with scripts I had used before (one and a half month ago, no major changes in the laptop, Xubuntu 12.04) to successfully produce epslatex plots in the same machine.
It looks as if there is something preventing the generation of the .tex file from finishing, but I can't figure out what that is. I also don't know if gnuplot allows for some kind of debugging, but the problem is really weird.
Any idea where I should start looking? I already tried to reinstall gnuplot, without any success.
-
Dan almost 10 yearsyou are supposed to use the name of the tex file for the output. That is:
set output 'sample1.tex'
. Then the eps file will have the same name, but extension.eps
. Also, in some circumstances, one needs to close the output file by addingset output
(with no filename) after the plot command. -
Jorgina almost 10 yearsWow, adding "set output" at the end of the script worked perfectly, thank you very much! What I still don't understand is why suddenly I needed such a line, since I've used epslatex many times before (one month ago or so) without any problem... Anyway, thanks a lot again! :)
-
Andrew Swann almost 10 years@Dan You should make your comment in to answer.
-