[pdftex] pdflatex and gnuplot and type-1 fonts

Allin Cottrell cottrell at wfu.edu
Sat Aug 11 23:38:52 CEST 2001

On Sat, 11 Aug 2001, Kevin E. Cahill wrote:

> My procedure involves these steps:
> I use gnuplot with the settings
> 	set terminal pslatex color
> 	set output 'temp1a1s.tex'
> I then use latex on a file, 1a1s.tex,
> which has the line
> 	\input{temp1a1s}
> to make a dvi file 1a1s.dvi.

The pslatex terminal option is a good choice, but stop right there!
There's no call to make a dvi file out of the gnuplot output, if
you're shooting for pdf.

I use the following perl script, gnuplot2pdftex:


# I suppose we are starting from a pair of files foo.tex and
# foo.ps, generated by Gnuplot with the terminal type set
# to "pslatex auxfile".  E.g., in gnuplot:
# > set term pslatex auxfile
# > set output 'foo.tex'
# This script requires one parameter, namely the base name of the
# two gnuplot output files ("foo", in the example).

# After running this script you should have foo.tex, foo.eps
# and foo.pdf in the current directory.  You should then be
# able to put something like:
#     \begin{figure}
#     \input foo
#     \end{figure}
# into your main LaTeX source file.  If you use
#     \usepackage[dvips]{graphicx}
# then foo.eps will get used.  If you substitute "[pdftex]" for
# "[dvips]" in the call to graphicx, then foo.pdf will get used
# instead.

if (@ARGV != 1) {
   print "Please supply one argument: " .
   "the basename of the gnuplot output files\n";
my $source = $ARGV[0];
my $ready;

# Rename foo.ps as foo.eps
rename "$source.ps", "$source.eps";

# Use ghostscript to convert the eps file to pdf
my $gscmd = "gs -q -sDEVICE=pdfwrite -dNOCACHE " .
  "-dUseFlateCompression=false -dNOPAUSE -dBATCH " .
  "-sOutputFile=$source.pdf $source.eps";

# Throw away the garbage from foo.tex
open (IN, "< $source.tex") || die "Can't open $source.tex";
open (OUT, "> $source.tmp") || die "Can't open $source.tmp";
$ready = 0;
while (<IN>) {
   if (/setlength{/) { $ready = 1; }
   if (/end{picture}/) { last; }
   if (/includegraphics/) { last; }
   if ($ready) { print OUT; }

print OUT "\\includegraphics{$source}\n";
print OUT "\\end{picture}\n";

close (IN);
close (OUT);

rename "$source.tmp", "$source.tex";

# end of perl script

Allin Cottrell.

More information about the pdftex mailing list