ConTEXt User Module subtitle : Executing Gnuplot on ... - Peter Münster

Sep 12, 2006 - ConTEXt title. : ConTEXt User Module subtitle : Executing Gnuplot on the fly author : Peter Münster date. : September 12, 2006 ...
153KB taille 8 téléchargements 50 vues
ConTEXt

title subtitle author date

: : : :

ConTEXt User Module Executing Gnuplot on the fly Peter Münster September 12, 2006

Executing Gnuplot on the fly

1

09 12 License, or (at your option) any later version.

2

\writestatus{loading}{Executing Gnuplot on the fly}

3

\unprotect The shell-script is in a buffer, just to keep this module in only one file.

4

\startbuffer[gnuplot-script] (echo set terminal postscript eps; echo set output "\"$1.eps\"" cat "$1.tmp") | gnuplot epstopdf "$1.eps" \stopbuffer Unique name for each file:

5

\startGnup.. \stopGnuplot 6

\newcount\GnuplotNum \def\GnuplotFilePrefix{\jobname-Gnuplot\the\GnuplotNum} Put your gnuplot-code between this start-stop-pair. \def\startGnuplot{\dosingleempty\dostartGnuplot} \def\dostartGnuplot[#1]{% \def\stopGnuplot{\immediate\write18{bash ./\jobname-gnuplot-script.tmp \GnuplotFilePrefix}% \doifemptyelse{#1}% {\externalfigure[\GnuplotFilePrefix]}% {\externalfigure[\GnuplotFilePrefix][#1]}% \advance \GnuplotNum by 1}% \dostartbuffer[Gnuplot\the\GnuplotNum][startGnuplot][stopGnuplot]}

7

\protect

8

\doifnotmode{demo}{\endinput} Usage example:

9

10

t-gnuplot-pm

\usemodule[gnuplot-pm] \starttext bla \startGnuplot plot sin(x) \stopGnuplot bla bla \startGnuplot[width=0.1\textwidth] plot cos(x) \stopGnuplot bla \stoptext

CONTEXT

CONTEXT

User Module

1