Possible Duplicate:
Wrapping code (listings, verbatim, or other method) inside a newcommand
I'm new to LaTeX and trying to write a command to plot files using the gnuplottex package (and gnuplot).
For now I am doing this (and it works):
\documentclass{article}
\usepackage{gnuplottex}
\begin{document}
\begin{gnuplot}[terminal=pdf,scale=1]
plot 'testfile' using 1:2
\end{gnuplot}
\end{document}
What I would like to do is:
\documentclass{article}
\usepackage{gnuplottex}
\newcommand{\plotdata}[1]
{
\begin{gnuplot}[terminal=pdf,scale=1]
plot '#1' using 1:2
\end{gnuplot}
}
\begin{document}
\plotdata{testfile} % this is the goal
\end{document}
But the build fails in the second case due to gnuplot errors (it fails to produce plots).
I'm using TeXLive/Ubuntu. Any ideas, why it does not work (or how I can see the code generated after \newcommand macros execution)?
#1mean? Where should it come from? – Bernhard Mar 25 '12 at 10:15\show\plotdata. – Caramdir Mar 26 '12 at 03:30gnuplotenvironment are scanned like averbatim. Putting verbatim-like environments into a command usually runs into problems. I don't know any workarounds, but maybe someone else can pick up from here. – Caramdir Mar 26 '12 at 03:35