CCL Home Page
Up Directory CCL gnuplot-latex
#!/bin/sh
# This is a shell archive (shar 3.20)
# made 11/27/1992 14:12 UTC by dfk@wildcat
# Source directory /a/quimby.dartmouth.edu/usr/wildcat/dfk/mycode/gnuplot/latex
#
# existing files WILL be overwritten
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   6636 -rw-r--r-- README
#   1917 -rw-r--r-- plotcommand.tex
#    436 -rwxr-xr-x plotskel
#    512 -r--r--r-- figs/Makefile.each
#    345 -rwxr-xr-x figs/makeall
#    281 -rw-r--r-- figs/pic.tex
#
if touch 2>&1 | fgrep '[-amc]' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
# ============= README ==============
echo "x - extracting README (Text)"
sed 's/^X//' << 'SHAR_EOF' > README &&
XGnuplot-LaTeX handy things v2.0  March 1991
X
XHere are some handy things for gnuplot users that use the latex driver.
X
XThese are some makefiles, shell scripts, and latex code that I use
Xwith gnuplot to make latex documents with plots. You may tailor to
Xsuit yourself. These are very short, really. I also do not plan to
Xreally support them. I just found them handy. 
X
XDuring revision of the document, when I am concentrating on the text,
XI often tire of waiting for latex (and the printer, or previewer) to
Xprocess plots that I am going to ignore anyway. Or, when latex
Xrequires multiple passes to get cross-references right, I hate
Xprocessing all those plots over and over. These macros (1) make it
Xeasier to include plots and (2) make the initial or draft passes of
Xlatex MUCH faster, by ignoring the plot contents.
X
XTo effectively use this software, you must lay out your files as
Xfollows: make a subdirectory called "figs" in the current directory.
XPut the file Makefile.each, and pic.tex, in figs. Make a subdirectory
Xin figs for each plot.  Make a link to Makefile.each called "Makefile"
Xin each of the plot subdirectories. In each plot subdirectory, there
Xshould be a file called "plot", which is the gnuplot input. There
Xshould also be any data files needed by that plot. (If these have
Xstandard names, you may want to add them to the dependency list for
Xplot.tex and skel.tex in the makefile).
X
XThus, you should have:
X top:
X    main.tex plotcommand.tex figs/ ...
X figs:
X   Makefile.each makeall pic.tex one/ two/ three/
X one:
X   Makefile plot one.datafile
X two:
X   Makefile plot two.datafile
X three:
X   Makefile plot three.datafile
XNote here that all three Makefiles are linked to Makefile.each.
X
X
Xplotskel:
X  I find this shell script handy when I work on a large document that
Xcontains many plots. This shell script takes a gnuplot (or gnutex, for
Xthose with old gnutex files around) output file (in latex) and
Xconverts it to a minimum skeleton that has the same-size box. This
Xtakes latex no time at all to process, but fills the same place in the
Xdocument. So use the skeleton until you are ready to include the
Xplots, then use the real plot. The Makefile I supply automatically
Xcreates the skeleton skel.tex for the plot plot.tex. When latex is
Xrun, plotcommand.tex asks the user whether to include skeletons or
Xplots. This should be installed somewhere on your path; it is used by
Xthe Makefiles.
X
Xplotcommand.tex:
X  This defines some macros for conveniently including plots in your
Xdocument in a standard way. The files must be organized as described
Xabove. Input this at the top of your document before the
X\begin{document}. To include a plot, use 
X    \plot{plotname}{lof-caption}{caption}
XThe plotname is the name of the subdirectory of "figs" that contains
Xthe plot. Thus, if there is a directory called figs/foobar, then
Xfoobar is the plotname. The lof-caption is used only to generate a
Xlist of figures. If you don't do this, leave this empty. (You may cut
Xdown the \plot macro to remove this option). The caption for the
Xfigure should be specified. This command creates a \label called
X"f:plotname". 
X  To refer to the figure that has a given plotname, use
X\plotref{plotname}. This will generate text, eg "Figure 10". So you
Xcan say things like this:
X   \plotref{foo} shows this effect in gorey detail (see also \plotref{bar}). 
X  If you don't like the way it asks for input at each run, change the
X\typein to a \newcommand to define \plotskel to be either "skel" or
X"plot". But then this defeats the purpose of choosing plot or skel on
Xeach run. 
X  See the advanced usage, and "Misc figures" below.
X
XMakefile.each:
X  This is a makefile to help you automate the process of updating your
Xgnuplot runs. This should be linked to "Makefile" in each plot
Xsubdirectory. Just 'make' will make plot.tex and skel.tex, for
Xinclusion into your document. 'make dvi' will make a dvi file with
Xjust that plot (see pic.tex). 'make clean' cleans up dvi-making mess.
X'make spotless' reduces the directory to minimal size; ie this removes
Xplot.tex as well. 'make view' will make a dvi file and view it (you
Xcan change to your previewer). 'make print' will make a dvi file and
Xprint it. Note that making a dvi file often removes skel.tex; so you
Xshould 'make clean; make' after playing with dvi files.
X
Xmakeall:
X This script should be in figs/. It will run make in all
Xsubdirectories, with the given arguments passed to each make. Thus,
Xyou can 'makeall clean' or just 'makeall'.
X
Xpic.tex:
X This is a small wrapper for generating a dvi file with just one plot.
XIt does not draw the box like the \plot command (above) does. The
Xmakefile will use this. It should be accessable as ../pic.tex to all
XMakefiles.
X
XMiscellaneous figures:
X  If you have plots, then why not other figures? I have a similar
Xmacro that I use for normal everyday figures (eg, from "Fig"). This
Xworks just like \plot, except it is called \fig. There are \figref and
X\figrange, like \plotref and \plotrange. The \fig macro loads a .tex
Xfile by the given fig name from the figs/misc directory, and puts a
Xbox around it, like for the plots. This creates a label like
X"f:misc/figname". 
X
XAdvanced usage:
X If the document is really big, then you can divide the "figs"
Xdirectory into subdirectories. Put all your plots into one of the
Xsubdirectories of figs. Now, you might have:
X top:
X    main.tex plotcommand.tex figs/ ...
X figs:
X    chapA/ chapB/ 
X figs/chapA:
X    Makefile.each makeall pic.tex one/ two/ misc/
X figs/chapB:
X    Makefile.each makeall pic.tex one/ two/ misc/
X figs/chapA/one:
X   Makefile plot one.datafile
X figs/chapA/two:
X   Makefile plot two.datafile
X figs/chapA/misc:
X   foo.fig foo.tex
X figs/chapB/one:
X   Makefile plot one.datafile
X figs/chapB/two:
X   Makefile plot two.datafile
X figs/chapC/misc:
X   bar.fig bar.tex junk.fig junk.tex
XThen, in your document, you can use them like this:
X    \newplotdir{chapA}
X    \plot{one}{}{This is plot chapA/one}
X    \plot{two}{}{This is plot chapA/two}
X    \plotref{one} refers to chapA/one.
X    \fig{foo}{}{This is figure chapA/misc/foo}
X
X    \newplotdir{chapB}
X    \plot{one}{}{This is plot chapB/one}
X    \plot{two}{}{This is plot chapB/two}
X    \plotref{one} refers to chapB/one, NOT chapA/one. We have two
X	pictures, \figrange{bar}{junk}.
X    \fig{bar}{}{This is plot chapB/misc/bar}
X    \fig{junk}{}{This is plot chapB/misc/junk}
XTypically, I have one plotdir for each chapter or other major
Xsectional unit. This is a convenient way to avoid name clashes in plot
Xnames. For everyday usage, no \newplotdir is needed, and all plotdirs
Xshould be directly in figs/.
X
X
XDavid Kotz
Xdfk@cs.duke.edu
XMarch 1991
X
X
SHAR_EOF
$TOUCH -am 0304140591 README &&
chmod 0644 README ||
echo "restore of README failed"
set `wc -c README`;Wc_c=$1
if test "$Wc_c" != "6636"; then
	echo original size 6636, current size $Wc_c
fi
# ============= plotcommand.tex ==============
echo "x - extracting plotcommand.tex (Text)"
sed 's/^X//' << 'SHAR_EOF' > plotcommand.tex &&
X% Some LaTeX macros for handling gnuplot plots
X% David Kotz dfk@cs.duke.edu
X
X% Find out whether user wants full plot or skeleton plots
X% User types either ``plot'' or ``skel'' (no quotes)
X\typein[\plotskel]{Do you wish full plots [plot] or skeleton plots [skel]?}
X
X% Define the current plot directory
X\newcommand{\plotdir}{}
X% Redefine the current plot directory
X\newcommand{\newplotdir}[1]{\renewcommand{\plotdir}{#1/}}
X
X\newlength{\plotwidth}
X\setlength{\plotwidth}{\textwidth}
X\addtolength{\plotwidth}{-0.1in}
X
X%%%%%%%%%%%% Plots %%%%%%%%%%%%%
X
X% Define \plot
X% Include a plot in the standard way
X%  Parm 1 is the plot name
X%  Parm 2 is the caption for the lof
X%  Parm 3 is the real caption
X\newcommand{\plot}[3]{
X \begin{figure}[htbp]
X  \framebox[\textwidth]{
X    \begin{minipage}{\plotwidth}
X      \begin{center}
X       \input{figs/\plotdir#1/\plotskel.tex}
X      \end{center}
X      \caption[#2]{#3}
X      \label{f:\plotdir#1}
X    \end{minipage}
X  }
X \end{figure}  
X}
X
X% Reference one of the above plots (before or after it is input)
X\newcommand{\plotref}[1]{Figure~\ref{f:\plotdir#1}}
X
X% Reference a range of plots
X\newcommand{\plotrange}[2]{Figures~\ref{f:\plotdir#1}--\ref{f:\plotdir#2}}
X
X%%%%%%%%%%%% Misc figures %%%%%%%%%%%%%
X
X% Define \fig
X% Include a miscellaneous figure in the standard way
X%  Parm 1 is the fig name
X%  Parm 2 is the caption for the lof
X%  Parm 3 is the real caption
X\newcommand{\fig}[3]{
X \begin{figure}[htbp]
X  \framebox[\textwidth]{
X    \begin{minipage}{\plotwidth}
X      \begin{center}
X       \input{figs/\plotdir misc/#1.tex}
X      \end{center}
X      \caption[#2]{#3}
X      \label{f:\plotdir misc/#1}
X    \end{minipage}
X  }
X \end{figure}  
X}
X
X% Reference one of the above figs (before or after it is input)
X\newcommand{\figref}[1]{Figure~\ref{f:\plotdir misc/#1}}
X
X% Reference a range of figs
X\newcommand{\figrange}[2]{%
XFigures~\ref{f:\plotdir misc/#1}--\ref{f:\plotdir misc/#2}}
SHAR_EOF
$TOUCH -am 0815165191 plotcommand.tex &&
chmod 0644 plotcommand.tex ||
echo "restore of plotcommand.tex failed"
set `wc -c plotcommand.tex`;Wc_c=$1
if test "$Wc_c" != "1917"; then
	echo original size 1917, current size $Wc_c
fi
# ============= plotskel ==============
echo "x - extracting plotskel (Text)"
sed 's/^X//' << 'SHAR_EOF' > plotskel &&
X#!/bin/csh -f 
X#
X# Make a skeleton version of a gnuplot or gnutex plot.tex file
X# This can be used in the same way, and takes up the same amount of
X# space on the page, but will run through latex MUCH faster. Good
X# for quick drafts.
X#
X# Usage:
X#   plotskel plot.tex 
X# Standard output is skeleton file
X
Xif ($#argv != 1) then
X	   echo usage: plotskel plot.tex
X	   exit 1
Xendif
X
Xsed -n -e '1,/begin{picture}/p' -e '/end{picture}/,$p' $1
SHAR_EOF
$TOUCH -am 0404210090 plotskel &&
chmod 0755 plotskel ||
echo "restore of plotskel failed"
set `wc -c plotskel`;Wc_c=$1
if test "$Wc_c" != "436"; then
	echo original size 436, current size $Wc_c
fi
# ============= figs/Makefile.each ==============
if test ! -d 'figs'; then
    echo "x - creating directory figs"
    mkdir 'figs'
fi
echo "x - extracting figs/Makefile.each (Text)"
sed 's/^X//' << 'SHAR_EOF' > figs/Makefile.each &&
X# This is linked into each plot directory as 'Makefile'
X
Xtex: plot.tex skel.tex
X
X# make a new tex plot file
Xplot.tex: plot
X	gnuplot plot
X	rm -f skel.tex
X
X# make a skeleton file for quicker draft latexing
Xskel.tex: plot.tex
X	plotskel plot.tex > skel.tex
X
X# or you view it
Xv view: pic.dvi
X	xtex pic
X
X# or you print it
Xp print: pic.dvi
X	texprint pic
X
Xremake:
X	rm -f plot.tex skel.tex
X
Xdvi: pic.dvi
X
Xpic.dvi: plot.tex
X	latex ../pic
X
Xclean:
X	rm -f *~ pic.dvi pic.aux pic.log
X
Xspotless: clean
X	rm -f plot.tex skel.tex
SHAR_EOF
$TOUCH -am 0304132091 figs/Makefile.each &&
chmod 0444 figs/Makefile.each ||
echo "restore of figs/Makefile.each failed"
set `wc -c figs/Makefile.each`;Wc_c=$1
if test "$Wc_c" != "512"; then
	echo original size 512, current size $Wc_c
fi
# ============= figs/makeall ==============
echo "x - extracting figs/makeall (Text)"
sed 's/^X//' << 'SHAR_EOF' > figs/makeall &&
X#!/bin/csh -f
X# Make all figures
X# arguments are passed on to each make
X
Xif ($1 == clean || $1 == spotless) then
X	   foreach i (*/Makefile)
X	   	   if ($i:h == misc) continue
X	   	   echo $i:h
X	   	   (cd $i:h; make $*)
X	   end
X	   (cd misc; make clean)
Xelse
X	   foreach i (*/Makefile)
X	   	   echo $i:h
X	   	   (cd $i:h; make $*)
X	   end
Xendif
SHAR_EOF
$TOUCH -am 0304140291 figs/makeall &&
chmod 0755 figs/makeall ||
echo "restore of figs/makeall failed"
set `wc -c figs/makeall`;Wc_c=$1
if test "$Wc_c" != "345"; then
	echo original size 345, current size $Wc_c
fi
# ============= figs/pic.tex ==============
echo "x - extracting figs/pic.tex (Text)"
sed 's/^X//' << 'SHAR_EOF' > figs/pic.tex &&
X\documentstyle{article}
X\pagestyle{empty}
X\begin{document}
X\sloppy
X\setlength{\textwidth}{8in}
X\setlength{\textheight}{9in}
X\setlength{\topmargin}{-0.5in}
X\setlength{\oddsidemargin}{0pt}
X\setlength{\evensidemargin}{0pt}
X\begin{center}
X\input {plot.tex}
X\end{center}
X\end{document}
SHAR_EOF
$TOUCH -am 0815164691 figs/pic.tex &&
chmod 0644 figs/pic.tex ||
echo "restore of figs/pic.tex failed"
set `wc -c figs/pic.tex`;Wc_c=$1
if test "$Wc_c" != "281"; then
	echo original size 281, current size $Wc_c
fi
exit 0
Modified: Mon Nov 13 17:00:00 1995 GMT
Page accessed 22390 times since Sat Apr 17 21:32:38 1999 GMT