# EPS output from PSTricks

I am trying to produce an EPS file from a PSTricks code. I am reproducing here the sample working code that I already have here:

PSTricks---plotstyle LSM (Least Square method)

Here is the modified code with \PStoEPS

\documentclass[12pt]{article}
\usepackage{filecontents}
\begin{filecontents*}{data.dat}
0.0     0.0
144.321  0.84
159.407     0.8925

\end{filecontents*}

\usepackage{pst-eps}

\begin{document}
\PSTtoEPS[bbllx=0,bblly=0,bburx=0,bbury=0]{test.eps}{%
\psset{xunit=0.6mm,yunit=30mm,xlabelFactor=$$,labelFontSize=\footnotesize,mathLabel=false} \begin{pspicture}(0,0)(150,3) \psaxes[axesstyle=frame,Dx=50,Dy=0.5, ticksize=0 4pt](150,3) \listplot [xStart=0, xEnd=150,xunit=1,plotstyle=values,rot=90] {\data} \listplot [xStart=0, xEnd=150,xunit=1,linewidth=1.5pt,linecolor=red,showpoints, dotstyle=square] {\data} \end{pspicture}} \end{document}  My understanding is that I need to enclose all PSTricks code in th last argument of \PStoEPS. On compilation, no DVI file is created and no other consequent output (eps) as well. I have three questions: 1. How to properly set the \PStoEPS options? 2. What compilation sequence is necessary to get the EPS output (LaTeX > DVI2ps?) 3. Are the bounding box coordinates necessary to be specified? Will \PStoEPS not produce an EPS with tight bounding box? Thanks a lot... Update: trying to use pst2pdf: \documentclass[12pt]{article} \usepackage{filecontents} \begin{filecontents*}{data.dat} 0.0 0.0 144.321 0.84 159.407 0.8925 \end{filecontents*} \usepackage{pst-plot,pstricks-add} \usepackage{pst-eps} %\usepackage{auto-pst-pdf} \begin{document} \pagestyle{empty} \parindent=0pt \readdata{\data}{data.dat} \psset{xunit=0.6mm,yunit=30mm,xlabelFactor=$$,labelFontSize=\footnotesize,mathLabel=false}
\begin{pspicture}(0,0)(150,3)
\psaxes[axesstyle=frame,Dx=50,Dy=0.5, ticksize=0 4pt](150,3)
\listplot [xStart=0, xEnd=150,xunit=1,plotstyle=values,rot=90] {\data}
\listplot [xStart=0, xEnd=150,xunit=1,linewidth=1.5pt,linecolor=red,showpoints, dotstyle=square] {\data}
\end{pspicture}

\end{document}


On a DOS prompt running the pst2pdf command on the above tex file gives:

! Undefined control sequence.
<argument> \data

l.23 ...0,xunit=1,plotstyle=values,rot=90] {\data}

?


The pst2pdf has difficulty to understand the \listplot arguments.

The goal in producing an EPS file is also to have one with a tight bounding box. But using the document class standalone seems to cut away the axes and no labels or tickmarks are shown.

-
why do you want to create an eps? – Herbert Nov 29 '11 at 8:55
Many academic journals are interested to have the pictures as separate (EPS) files and not embedded in the LaTeX codes. – yCalleecharan Nov 29 '11 at 9:02
ok, understood. Are you running Linux or Windows? However, with TeXLive comes a script pst2pdf <file> which creates from all pspicture environments single eps/pdf/png files in a subdirectory – Herbert Nov 29 '11 at 9:28
Win XP with the latest TexLive 2011. – yCalleecharan Nov 29 '11 at 9:29
I have no experience with windows, but the script should also works. If not, then use the package auto-pst-pdf instead. It creates a conatiner file <file>-pics.pdf which collects all pspicture environments as a single pdf page. See PSTricks.tug.org for more informations – Herbert Nov 29 '11 at 9:40

You can embedd the pstricks picture into a TeXtoEPS environment and then use dvips -E to get an EPS with tight bounding box. The following works for me:

% compile with latex --> dvips -E
\documentclass[12pt,dvips]{article}
\usepackage{filecontents}
\begin{filecontents*}{data.dat}
0.0     0.0
144.321  0.84
159.407     0.8925

\end{filecontents*}
\usepackage{pslatex}
\usepackage{graphicx}
\usepackage{xcolor}
%\usepackage{pst-eps}

\begin{document}
\begin{TeXtoEPS}
\psset{xunit=0.6mm,yunit=30mm,xlabelFactor=,labelFontSize=\footnotesize,mathLabel=false}
\begin{pspicture}(0,0)(150,3)
\psaxes[axesstyle=frame,Dx=50,Dy=0.5, ticksize=0 4pt](150,3)
\listplot [xStart=0, xEnd=150,xunit=1,plotstyle=values,rot=90] {\data}
\listplot [xStart=0, xEnd=150,xunit=1,linewidth=1.5pt,linecolor=red,showpoints, dotstyle=square] {\data}
\end{pspicture}
\end{TeXtoEPS}
\end{document}


Compile this with:

latex graph.tex
dvips -E graph.dvi


The resulting graph.ps file actually is an EPS file with tight bounding box, which in the following is visualized by rendering it inside an \fbox:

\documentclass{article}
\usepackage{graphicx}

\begin{document}
% \fbox to visualize the dimensions
\fbox{\includegraphics{graph.ps}}
\end{document}


-
dvips -E can also be used without using the environment TeXtoEPS – Herbert Nov 29 '11 at 14:21
@ Daniel Thanks. This is a PS file and not an EPS. I have tried converting the PS to an EPS file using ps2eps -f --fixps graph.ps. When inserting the resulting graph.eps file with the \includegraphics command I get the graph upside down and at the bottom left of the page. An PS takes the whole page while an EPS will only take the space it needs. I played with the bounding box of the EPS file but couldn't make it appear well. 1vote up. – yCalleecharan Nov 30 '11 at 6:13
@yCalleecharan: The result is an EPS with tight bounding box. See my updated answer, which also demonstrates using it with \includegraphics. Note the \fbox around it, which visualized the dimensions and the page number (1) in the very bottom. – Daniel Nov 30 '11 at 8:10
@ Daniel I guess here it is better to stick with the PS file rather than trying to convert it into an EPS. The issue for me is that I can add text above and below the image. Yes it works. Thanks for your efforts. – yCalleecharan Nov 30 '11 at 8:28

The way to change the name of the resulting graph.ps file to graph.eps,

dvips -E graph.dvi -o [filename].eps


"-o [filename].eps" is just to change the name of the produced file graph.ps by dvips -E graph.dvi to [filename].eps. And dvips graph.dvi -E -o [filename].eps is also OK. See more: http://solvcon.net/yyc/writing/2009/pstricks_eps.html http://www.tug.org/texinfohtml/dvips.html

-
Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button ({}`) or hit Ctrl+K. – Claudio Fiandrino May 27 '14 at 8:22
actually, the eps file produced by this method may have a blank which can be seen if you use the \fbox{}, and I don't know why. But i can use latex + divips + pspdf, [ use \usepackage[active,tightpage]{preview} \PreviewEnvironment{pspicture} \PreviewBorder=0pt to get the exact size you want ] then use acrobat professional to save it as eps file, choose RGB color when saving. – Killing knife May 27 '14 at 9:28