3

I am a begineer in LaTex and absoulte novice in gnuplot. I am using Texstudio and Windows 8.1. The problem is - I cannot make LaTex display a simple image. Probably some settings issue. In paricular, I took the simplest gnuplot code from the web (with slight adjustment):

This is the gnuplot code for my graph:

reset 
set key inside left top vertical Right noreverse enhanced autotitles box linetype -1 linewidth 1.000
set samples 50, 50
plot [-10:10] sin(x),atan(x),cos(atan(x))
set term pslatex auxfile
set output 'proba1.tex'     
replot 

This is a file (test1.tex) that I get (besides ps file):

% GNUPLOT: LaTeX picture with Postscript
\begingroup%
\makeatletter%
\newcommand{\GNUPLOTspecial}{%
\@sanitize\catcode`\%=14\relax\special}%
\setlength{\unitlength}{0.0500bp}%
\begin{picture}(7200,5040)(0,0)%
\special{psfile=proba1.ps llx=0 lly=0 urx=360 ury=252 rwi=3600}
\put(2340,4236){\makebox(0,0)[r]{\strut{}cos(atan(x))}}%
\put(2340,4436){\makebox(0,0)[r]{\strut{}atan(x)}}%
\put(2340,4636){\makebox(0,0)[r]{\strut{}sin(x)}}%
\put(6839,200){\makebox(0,0){\strut{} 10}}%
\put(5324,200){\makebox(0,0){\strut{} 5}}%
\put(3809,200){\makebox(0,0){\strut{} 0}}%
\put(2295,200){\makebox(0,0){\strut{}-5}}%
\put(780,200){\makebox(0,0){\strut{}-10}}%
\put(660,4799){\makebox(0,0)[r]{\strut{} 1.5}}%
\put(660,4066){\makebox(0,0)[r]{\strut{} 1}}%
\put(660,3333){\makebox(0,0)[r]{\strut{} 0.5}}%
\put(660,2599){\makebox(0,0)[r]{\strut{} 0}}%
\put(660,1866){\makebox(0,0)[r]{\strut{}-0.5}}%
\put(660,1133){\makebox(0,0)[r]{\strut{}-1}}%
\put(660,400){\makebox(0,0)[r]{\strut{}-1.5}}%
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               \end{picture}%
\endgroup
\endinput

This is LaTex text:

\documentclass[11pt,twoside,a4paper]{article}
\usepackage{graphicx}
\begin{document}
gnuplot test
\begin {figure}
\begin{center}
\input{test1.tex}
\end{center}
\end {figure}
\end{document}

It might seems silly, but I am looking for the solution for days now, but no luck. Many thanks. Marko

Marko
  • 41
  • 1
    Your file test1.tex is incomplete, i.e. missing lines from the end. Is that really what you get from gnuplot? – mvkorpel Jul 04 '14 at 14:42
  • 1
    With this setup you have to compile along latex+dvips+ps2pdf – egreg Jul 04 '14 at 14:46
  • Ok, I hate to answer questions with questions, but do you mind me asking why not set teminal latex? It saves you lots of headaches. – Pouya Jul 04 '14 at 15:16
  • I have a revolutionary (;-)) proposition: Why output gnuplot to LaTeX instead of eps or pdf directly? (Special cases, when special characters needed-> use latex terminal, otherwise postscript enhanced or pdf terminal) –  Jul 04 '14 at 16:36
  • Hi, thank you for your comments are prompt asnwers. Few lines were missing, I added those now. But there are some weird characters there, in notepad++ those empty spaces shows as NUL. About latex+dvips+ps2pdf compiling, LaTex gives me errors (text line contains invalid characters) so I cannot proceed with dvips and ps2pdf. I also tried output to eps, but again LaTex gives me errors. – Marko Jul 04 '14 at 18:17
  • OK, thanks to you guys I managed to find a solution: first, gnuplot did create incomplete tex file, as mvkorpel noticed. I had to write unset output in gnuplot and then I got a complete tex file. According to gnuplot FAW, some output formats must be explicitly closed like this. After that I used latex+dvips+ps2pdf as egreg suggested. This solved the problem. Many thanks once more. – Marko Jul 04 '14 at 20:08
  • @Marko Could you post that as an answer? – Stephan Lehmke Jul 05 '14 at 07:10

1 Answers1

1

OK, thanks to you guys I managed to find a solution: first, gnuplot did create incomplete tex file, as mvkorpel noticed. I had to write unset output in gnuplot and then I got a complete tex file. According to gnuplot FAW, some output formats must be explicitly closed like this. After that I used latex+dvips+ps2pdf as egreg suggested. This solved the problem. Many thanks once more.

Marko
  • 41