Most of the the answer to this is contained in the following question:
However, depending on how your system is set up you may need to do some extra things.
First, compiling source code on a Mac requires you to install XCode from the App store (it's free). See the following link for a nice description:
Second, you also need to allow TeX to run external programs like GnuPlot. Typically the way to do this is to run programs with the --shell escape
option. However, recent version of TeX Live have created a system of so-called "restricted" shell escape, which allows you to add programs to a global list of external programs to minimize the security issues of using unrestricted shell escape.
There are a number of different ways to implement this on a Mac.
Create a TeXShop engine file for --shell-escape
The simplest way is probably to create a new TeXShop engine file which runs the appropriate LaTeX command with the --shell-escape
option enabled. See:
Create a config file in your texmf-local
folder
If you are using gnuplot
capabilities a lot, it might be easiest to add gnuplot
to your list of allowable programs. This can be done by creating a local texmf.cnf
file. Create the following file:
shell_escape_commands = bibtex,bibtex8, kpsewhich, makeindex, mpost, repstopdf, gnuplot,
The file must end with a blank line. Save or copy this file into the following directory:
(you will need administrator access to do this.)
/usr/local/texlive/texmf-local/web2c
Then run texhash
to update the TeX database.
Now you should be able to use gnuplot
from within your TeX documents.
I am definitely unfamiliar with both beamer
and tikz
(do not quite get what the \only
are supposed to do) but perhaps this could go in the direction you want:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{chains}
\newcounter{count}
% helper macro:
\long\def\GobToSemiColon #1;{}
\newcommand\myPicture{
\begin{tikzpicture}
\begin{scope}[start chain = going below]
\ifnum\value{count}<1 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>3 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only when counter is between
1 and 3};
\ifnum\value{count}>-1 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only when counter is
negative};
\ifnum\value{count}<100 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>200 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only if counter is between
100 and 200};
\ifnum\value{count}<3 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>20 \expandafter\GobToSemiColon\fi
\node[draw, circle, on chain] {only when counter is in the range 3 to 20};
\end{scope}
\end{tikzpicture}
}
\begin{document}
\begin{frame}
\only{\setcounter{count}{-3}\myPicture}
\only{\setcounter{count}{105}\myPicture}
\only{\setcounter{count}{39}\myPicture}
\only{\setcounter{count}{2}\myPicture}
\only{\setcounter{count}{5}\myPicture}
\end{frame}
\end{document}

Best Answer
The example provided works fine for me (TeXLive 2011) with
pdflatex --shell-escape
. Note that the--shell-escape
option is necessary. If you don't provide that option then output file will be blank.If that does not solve your problem, I would guess that there is a problem with you
gnuplot
installation. Perhaps you can try some of the test cases that come wtihgnuplot
and ensure that that works. Also, is your path properly set up to locategnuplot
?It would be helpful if you would provide more details as to what do you mean by "did not generate the graph". Were there any error messages in the logs? If you put text before the
tikzpicture
does that get output properly? Did you have a look at the files that get generated in the directory where you are running this? Is there are *.gnuplot file generated? Perhaps you should have a look at this gnuplot tutorial and ensure that gnuplot is working.