1#!/bin/sh
2
3# Generate an Encapsulated Postscript file (eps) from the
4# PLplot pstex driver generated files.
5
6if test $# = "0"; then
7	echo -e "\n\
8	Usage: pstex2eps <filename>\n\
9	\n\
10	Where <filename> is the name of the output file you specified\n\
11	with the -o option in PLplot.\n\
12	There must exist two files, the postscript file without text,\n\
13	<filename>, and the latex file with the text, <filename_t>.\n\
14	The output file will be named <filename.eps>.\n\
15	\n\
16	The Computer Modern Type 1 fonts will be included in the output\n\
17	eps file. If you intent to use the plot figure in LaTeX, just\n\
18	use a plain \include{<filename_t>} in your latex file.\n"
19	exit 1
20fi
21
22if test ! -e $1 -o ! -e $1_t; then
23	echo "$1 or $1_t don't exist. Exiting."
24	exit 1
25fi
26
27ifile=$1
28ofile=`mktemp pstex2eps.XXXXXX`
29
30cat > ${ofile}.tex <<EOF
31\documentclass{article}
32\usepackage{ae,aecompl}
33\usepackage{graphicx}
34\begin{document}
35\pagestyle{empty}
36This is a  preview demo of your plot, the 'pstex' driver is intended
37to be used with \LaTeX.
38Use \LaTeX math capabilities as strings in your plots,
39and they will appear as you would expect.
40\begin{figure}[!htb]
41{\centering{\rotatebox{-90}{\scalebox{0.5}{\input{${ifile}_t}}}}
42\caption{This is how your plot will look.}}
43\end{figure}
44\end{document}
45EOF
46
47latex ${ofile} > /dev/null \
48&& dvips -Pcmz -o ${ifile}.eps $ofile 2> /dev/null
49
50rm ${ofile}*
51