0

I would like to integrate gnuplot directly into TexMaker. I have installed gnuplot and calling it from Terminal works perfectly.

student-net-nw-2811:~ aris$ gnuplot

G N U P L O T
Version 5.2 patchlevel 6    last modified 2019-01-01 

Copyright (C) 1986-1993, 1998, 2004, 2007-2018
Thomas Williams, Colin Kelley and many others

gnuplot home:     http://www.gnuplot.info
faq, bugs, etc:   type "help FAQ"
immediate help:   type "help"  (plot window: hit 'h')
Terminal type is now 'aqua'
gnuplot> 

In TexMaker I enabled --shell-escape and --enable-write18 as followed

pdftex --shell-escape --file-line-error --synctex=1 --enable-write18 

From the .log File it seems that TexMaker can't find the path to gnuplot. The path is:

student-net-nw-2811:~ aris$ which gnuplot
/opt/local/bin/gnuplot

How can i fix this problem so that i can compile directly in TexMaker and don't need to run the Terminal first with the code

latex --shell-escape test.tex

Thanks for your help.

Edit: Adding \usepackage{gnuplottex} occurs in following error

! LaTeX Error: File `gnuplottex.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Edit: A minimal code example is:

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}

% GNUPLOT required
\begin{document}
\pagestyle{empty}


\begin{tikzpicture}[domain=-1:1]
     \draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
     \draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
     \draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
     \draw[color=red] plot[id=x^3] function{x*x*x} 
         node[right ] {$f(x) =x^3$};
     \draw[color=blue] plot[id=sin] function{sin(x)} 
         node[below right] {$f(x) = \sin x$};
     \draw[color=orange] plot[id=cos] function{cos(x))} 
         node[below right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}


\end{document}
naphaneal
  • 2,614
  • you may need to add the $PATH in the config pane under "Add to Path". also, try: latex.exe"--shell-escape -synctex=1 -interaction=nonstopmode %.tex as --enable-write18 is a MiKTeX thing. – naphaneal Mar 14 '19 at 10:02
  • Where do I find the Add to Path? I'm pretty new to it and not so familiar with this. However, I'm running MikTex on my Mac. – Aris Martin Accola Mar 14 '19 at 10:07
  • Open "Configuration TeXmaker", it's under the checkbox "Launch the Clean tool". copy your PATH to guplot there. on MiKTeX edit your command to: latex --enable-write18 -synctex=1 -interaction=nonstopmode %.tex – naphaneal Mar 14 '19 at 10:09
  • Adding it to Path worked for me!! Many thanks to you. Maybe you can help me with a other short question if i write \draw[color=red] plot[id=x^3] function{x^3} it doesn't draw any function but if i write \draw[color=red] plot[id=x^3] function{xxx} than it compiles correctly. Do you know why this is so? – Aris Martin Accola Mar 14 '19 at 10:18
  • ^ has a special meaning in LaTeX. it is used for superscripting text. to use it in different context, you either have to escape or redefine it. – naphaneal Mar 14 '19 at 10:21

0 Answers0