How to prepare eps files with beautiful LaTeX letters?

Motivation

Scientific figures frequently require LaTeX letters for mathematical symbols as the axis label, for instance.

Solution

One solution is to use the "epslatex" option of gnuplot (v4).

Necessary softwares

Details

Let test.gp be the test script file of gnuplot(v4) to create a beautiful eps file. The file name (test.gp) is arbitrary. You have
  1. Prepare a gnuplot script file (named test.gp)
  2. Create tex and eps files (test.tex, test.eps)
  3. Include test.tex in a tex file (named include.tex)
  4. Compile the include.tex
  5. Get out the figure part

Step1: Prepare a gnuplot script file (test.gp)

test.gp
set term epslatex color
set output "test.eps"
set xlabel '{\Large $x$}'
set ylabel '{\Large $e^{\alpha x}$}'
set label 1 '{\Large $\alpha=0.1$}' at 1,1
plot exp(0.1*x)
unset label
quit

Step2: Create tex and eps files (test.tex, test.eps)

prompt> gnuplot test.gp
prompt> ls test*
test.eps test.gp test.tex
The created test.eps has the graph part only as:
test.eps

Step3: Include test.tex in a tex file (include.tex : name is arbitrary)

include.tex
\documentclass{article}
\usepackage{graphicx,color}
\pagestyle{empty}
\begin{document}
\begin{figure}[h]
\input{./test.tex}
\end{figure}
\end{document}

Step4: Compile the include.tex

prompt> latex include.tex
The created include.dvi has unnecessary space. In the next step, we get out the figure part only.

Step5: Get out the figure part

prompt> dvips -E include.dvi
prompt> epstopdf --outfile=include.pdf include.ps
prompt> pdftops -eps include.pdf test.eps
prompt> rm include.{aux,dvi,log,ps,pdf}
The 2nd and 3rd lines are for nice preview by xdvi with the package:
\usepackage[dvipdfmx]{graphicx}

The created eps file is:
test.eps (final form)

Further

It is convenient to use a shell script file to automatically execute the above commands.

test.sh
#!/bin/csh -f
set includefile="include"
foreach gpfile ( "test" ) (You may add the script files as ( "test" "test2" "test3" ) )
ech ${gpfile}.gp
gnuplot ${gpfile}.gp
latex ${includefile}
dvips -E ${includefile}.dvi
epstopdf --outfile=${includefile}.pdf ${includefile}.ps
pdftops -eps ${includefile}.pdf ${gpfile}.eps
rm ${includefile}.{aux,dvi,log,ps,pdf} ${gpfile}.{tex,log} (cleaning up unnecessary files)

Then,
prompt> chmod u+x test.sh
prompt> ./test.sh

Last modified: Fri Aug 25 09:54:01 JST 2017