4

sorry if I do something wrong, it is my first post. I generate usually pdfs with gnuplot by using the output terminal tkiz to generate first a .tex and afterwards a .pdf. I recently updated to TeXLive. Now the compilation from .tex to .pdf does not work anymore.

My example is a .tex that was generate by the "set term tkiz" output in gnuplot. I get the error

! Undefined control sequence.
l.22 \gpsetdashtype
                   {gp dt solid}

without being able to explain it. Does somebody know how to fix it? Thank you for looking into the problem.

Edit: Here is an example that runs now through in an empty folder. But I am not sure what this "createstyle" does. Usually I enter here "standalone header "\usepackage{MyGnuplotLaTeX}" that is a .sty file calling usepackages like siunitx for me.

#!/usr/bin/gnuplot 
basename='test_graph.plt'
end3='.tex'
f(x)=sin(x)
plot f(x) with lines #ls 1 
set term tikz size 342.435pt,228pt standalone create style font \\rmfamily,12pt"
set output basename.end3
replot
set output
system(sprintf('pdflatex %s%s', basename, end3)) 
%%%%%%%%%%%%%% Standalone example to be compiled via pdflatex for example. %%%%

\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}

\usepackage[utf8x]{inputenc}

\usepackage{gnuplot-lua-tikz}
\pagestyle{empty}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{\gpbboxborder}

\begin{document}

\begin{tikzpicture}[gnuplot]
%% generated with GNUPLOT 5.0p1 (Lua 5.2; terminal rev. 99, script rev. 100)
%% Fri Sep 11 09:10:43 2015
\tikzset{every node/.append style={font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}}}
\path (0.000,0.000) rectangle (12.035,8.013);
\gpcolor{color=gp lt color border}
\gpsetlinetype{gp lt border}
\gpsetdashtype{gp dt solid}
\gpsetlinewidth{1.00}
\draw[gp path] (1.430,0.740)--(1.610,0.740);
\draw[gp path] (11.372,0.740)--(11.192,0.740);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,0.740) {$-1$};
\draw[gp path] (1.430,1.423)--(1.610,1.423);
\draw[gp path] (11.372,1.423)--(11.192,1.423);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,1.423) {$-0.8$};
\draw[gp path] (1.430,2.106)--(1.610,2.106);
\draw[gp path] (11.372,2.106)--(11.192,2.106);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,2.106) {$-0.6$};
\draw[gp path] (1.430,2.789)--(1.610,2.789);
\draw[gp path] (11.372,2.789)--(11.192,2.789);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,2.789) {$-0.4$};
\draw[gp path] (1.430,3.472)--(1.610,3.472);
\draw[gp path] (11.372,3.472)--(11.192,3.472);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,3.472) {$-0.2$};
\draw[gp path] (1.430,4.155)--(1.610,4.155);
\draw[gp path] (11.372,4.155)--(11.192,4.155);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,4.155) {$0$};
\draw[gp path] (1.430,4.838)--(1.610,4.838);
\draw[gp path] (11.372,4.838)--(11.192,4.838);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,4.838) {$0.2$};
\draw[gp path] (1.430,5.521)--(1.610,5.521);
\draw[gp path] (11.372,5.521)--(11.192,5.521);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,5.521) {$0.4$};
\draw[gp path] (1.430,6.204)--(1.610,6.204);
\draw[gp path] (11.372,6.204)--(11.192,6.204);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,6.204) {$0.6$};
\draw[gp path] (1.430,6.887)--(1.610,6.887);
\draw[gp path] (11.372,6.887)--(11.192,6.887);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,6.887) {$0.8$};
\draw[gp path] (1.430,7.570)--(1.610,7.570);
\draw[gp path] (11.372,7.570)--(11.192,7.570);
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.210,7.570) {$1$};
\draw[gp path] (1.430,0.740)--(1.430,0.920);
\draw[gp path] (1.430,7.570)--(1.430,7.390);
\node[gp node center,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (1.430,0.371) {$-10$};
\draw[gp path] (3.916,0.740)--(3.916,0.920);
\draw[gp path] (3.916,7.570)--(3.916,7.390);
\node[gp node center,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (3.916,0.371) {$-5$};
\draw[gp path] (6.401,0.740)--(6.401,0.920);
\draw[gp path] (6.401,7.570)--(6.401,7.390);
\node[gp node center,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (6.401,0.371) {$0$};
\draw[gp path] (8.887,0.740)--(8.887,0.920);
\draw[gp path] (8.887,7.570)--(8.887,7.390);
\node[gp node center,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (8.887,0.371) {$5$};
\draw[gp path] (11.372,0.740)--(11.372,0.920);
\draw[gp path] (11.372,7.570)--(11.372,7.390);
\node[gp node center,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (11.372,0.371) {$10$};
\draw[gp path] (1.430,7.570)--(1.430,0.740)--(11.372,0.740)--(11.372,7.570)--cycle;
\node[gp node right,font={\rmfamily\fontsize{12pt}{14.4pt}\selectfont}] at (9.652,7.205) {f(x)};
\gpcolor{rgb color={0.690,0.188,0.376}}
\gpsetlinewidth{2.00}
\draw[gp path] (9.872,7.205)--(10.932,7.205);
\draw[gp path] (1.430,6.013)--(1.530,5.400)--(1.631,4.737)--(1.731,4.050)--(1.832,3.367)%
  --(1.932,2.716)--(2.033,2.124)--(2.133,1.615)--(2.233,1.208)--(2.334,0.922)--(2.434,0.767)%
  --(2.535,0.750)--(2.635,0.871)--(2.736,1.126)--(2.836,1.504)--(2.936,1.990)--(3.037,2.564)%
  --(3.137,3.203)--(3.238,3.881)--(3.338,4.569)--(3.438,5.241)--(3.539,5.868)--(3.639,6.426)%
  --(3.740,6.892)--(3.840,7.246)--(3.941,7.474)--(4.041,7.568)--(4.141,7.523)--(4.242,7.340)%
  --(4.342,7.028)--(4.443,6.600)--(4.543,6.071)--(4.644,5.465)--(4.744,4.806)--(4.844,4.120)%
  --(4.945,3.435)--(5.045,2.780)--(5.146,2.181)--(5.246,1.662)--(5.347,1.244)--(5.447,0.945)%
  --(5.547,0.777)--(5.648,0.745)--(5.748,0.853)--(5.849,1.095)--(5.949,1.461)--(6.050,1.937)%
  --(6.150,2.503)--(6.250,3.136)--(6.351,3.811)--(6.451,4.499)--(6.552,5.174)--(6.652,5.807)%
  --(6.752,6.373)--(6.853,6.849)--(6.953,7.215)--(7.054,7.457)--(7.154,7.565)--(7.255,7.533)%
  --(7.355,7.365)--(7.455,7.066)--(7.556,6.648)--(7.656,6.129)--(7.757,5.530)--(7.857,4.875)%
  --(7.958,4.190)--(8.058,3.504)--(8.158,2.845)--(8.259,2.239)--(8.359,1.710)--(8.460,1.282)%
  --(8.560,0.970)--(8.661,0.787)--(8.761,0.742)--(8.861,0.836)--(8.962,1.064)--(9.062,1.418)%
  --(9.163,1.884)--(9.263,2.442)--(9.364,3.069)--(9.464,3.741)--(9.564,4.429)--(9.665,5.107)%
  --(9.765,5.746)--(9.866,6.320)--(9.966,6.806)--(10.066,7.184)--(10.167,7.439)--(10.267,7.560)%
  --(10.368,7.543)--(10.468,7.388)--(10.569,7.102)--(10.669,6.695)--(10.769,6.186)--(10.870,5.594)%
  --(10.970,4.943)--(11.071,4.260)--(11.171,3.573)--(11.272,2.910)--(11.372,2.297);
\gpcolor{color=gp lt color border}
\gpsetlinewidth{1.00}
\draw[gp path] (1.430,7.570)--(1.430,0.740)--(11.372,0.740)--(11.372,7.570)--cycle;
%% coordinates of the plot area
\gpdefrectangularnode{gp plot 1}{\pgfpoint{1.430cm}{0.740cm}}{\pgfpoint{11.372cm}{7.570cm}}
\end{tikzpicture}
%% gnuplot variables
\end{document}
18
  • 1
    Welcome! You write two times "tkiz" but you mean TikZ, right? Could you please try to reduce your example as much as possible? E.g. I do not have gnuplot-lua-tikz on my machine. If it is not needed here, we should know. This package sound quite as if you should compile your file with LuaLaTeX. Just a guess.
    – LaRiFaRi
    Sep 11 '15 at 7:45
  • 1
    @Gudrun did you remember to update MacTeX after you installed it? MacTeX is a yearly snapshot.
    – daleif
    Sep 11 '15 at 7:54
  • 1
    @LaRiFaRi apparently gnuplot-lua-tikz.sty is automatically generated by gnuplot.lua (I found it somewhere on my machine)
    – daleif
    Sep 11 '15 at 7:57
  • 1
    But I agree, without more information about the proper manner in which to get gnuplot-lua-tikz.sty and where exactly \gpbboxborder comes from, it is impossible to help. Not all of us are fluent in GNUPlot.
    – daleif
    Sep 11 '15 at 8:01
  • 1
    BTW: since the plot is generated by GNUPlot and its lua terminal, can we have the GNUPlot code and exact instructions on how to compile it with GNUPlot. Then I think we have a better chance of solving this.
    – daleif
    Sep 11 '15 at 8:02
2

The file gnuplot-lua-tikz.sty is automatically created in the directory where you run gnuplot <file> from, each time gnuplot is run. Its contents is fixed:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gnuplot-lua-tikz}%
          [2014/11/09 (rev. 100) GNUPLOT Lua terminal style]

\RequirePackage{tikz}

\usetikzlibrary{arrows,patterns,plotmarks,backgrounds,fit}
\input gnuplot-lua-tikz-common.tex

\endinput

and its accompanying file gnuplot-lua-tikz-common.tex is created each time as well (too long for being displayed here).

As far as I can see these files reside nowhere on the system, but are generated by a Lua script that I have in

/usr/local/Cellar/gnuplot/5.0.1/share/gnuplot/5.0/lua/gnuplot-tikz.lua

(corresponding on other systems to /usr/local/share/gnuplot/... or /usr/share/gnuplot/...).

If you want to make the generated test_graph.plt.tex file compilable, you need to have those generated files along with it.

It's possible that older versions of gnuplot provided “fixed” gnuplot-lua-tikz.sty and gnuplot-lua-tikz-common.tex, but the most recent one doesn't. I don't think it's good practice to save these files in some directory searchable by TeX (such as $TEXMFHOME), since the fact that they are generated every time seems to mean that the developers of gnuplot want to be free to update them without the need of interacting with TeX distributions.

7
  • Thank you. I don't think "The file gnuplot-lua-tikz.sty is automatically created in the directory where you run gnuplot <file> from, each time gnuplot is run." is for me the case. How could I check please?
    – Gudrun
    Sep 11 '15 at 10:38
  • I get the error ! LaTeX Error: File `gnuplot-lua-tikz.sty' not found.
    – Gudrun
    Sep 11 '15 at 11:43
  • 1
    @Gudrun Do you have the file gnuplot-tikz.lua somewhere? And do you have Lua installed? By the way, I abandoned MacPorts years ago.
    – egreg
    Sep 11 '15 at 12:07
  • 4
    In order to create style files in the working directory automatically, the option createstyle is necessary: set out "test.tex" set term lua tikz latex createstyle plot sin(x) Alternatively one can install style files as tex/generic/gnuplot-lua-tikz/gnuplot-lua-tikz-common.tex tex/latex/gnuplot-lua-tikz/gnuplot-lua-tikz.sty tex/plain/gnuplot-lua-tikz/gnuplot-lua-tikz.tex tex/context/third/gnuplot-lua-tikz/t-gnuplot-lua-tikz.tex where styles are obtained by a command: lua gnuplot-tikz.lua style Sep 11 '15 at 14:36
  • 2
    You can simply generate the style files (like gnuplot-lua-tikz.sty) with one command in the commandline: gnuplot -e 'set terminal tikz createstyle'
    – gospes
    Sep 5 '17 at 13:55
2

The error ocours because your pdflatex version doesn't know what to do with \gpsetdashtype. To avoid this you can edit gnuplot-tikz.lua, this file probably is in /usr/share/gnuplot/gnuplot/5.0/lua/ or something like that. Change the line gp.write("\\gpsetdashtype{"..dashtype.."}\n") to gp.write("$\\gpsetdashtype{"..dashtype.."}\n"); this should do the trick. For safety make a copy before you any change. You can do something like

cd /usr/share/gnuplot/gnuplot/5.0/lua/
sudo cp gnuplot-tikz.lua gnuplot-tikz.lua.old

then

sudo sed -i "s/\\\\\\\\gpsetdashtype/%\\\\\\\\gpsetdashtype/" gnuplot-tikz.lua

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.