# PSTricks and LaTeX vs. pdfLaTeX

I'm trying to convert my thesis to pdfLaTeX, as latex + dvips behaves ugly when it comes to break (really long) URLs... I'm using up-to-date TeXLive 2012 on Linux.

The only problem is (so far), that I heavily used pstricks and the related packages and I am not able to get them working nicely on pdfLaTeX (see my pictures) when interacting between different pspicture-environments (also using this sometime to have text directly related to pictures underneath):

latex + dvips + ps2pdf (gs)

pdflatex (arrow is missing)

Code for the example above:

\documentclass[12pt]{scrbook}
\PassOptionsToPackage{pdf}{pstricks} %used for pdflatex
\usepackage{pstricks,pst-plot,pst-node,pst-func}

\begin{document}

\begin{pspicture}(-1.5,0)(1.5,4)
\psTextFrame[ref=c,linestyle=none](-1.5,3)(1.5,4){First Plot}
\psplot[fillcolor=blue!30,fillstyle=solid,opacity=0.5]{-1.5}{1.5}{x 0 0.3 GAUSS}
\psaxes[labels=none,ticks=none]{->}(-1.5,0)(1.5,3)
\pnode(1.5,0.5){A}
\end{pspicture}
\vspace{5mm}
\begin{pspicture}(-1.5,0)(1.5,4)
\psTextFrame[ref=c,linestyle=none](-1.5,3)(1.5,4){Second Plot}
\psplot[fillcolor=blue!30,fillstyle=solid,opacity=0.5]{-1.5}{1.5}{x 0 0.6 GAUSS}
\psaxes[labels=none,ticks=none]{->}(-1.5,0)(1.5,3)
\pnode(1.5,0.5){B}
\nccurve{->}{A}{B}
\end{pspicture}

\end{document}

-
I didn't realize pstricks works at all with pdflatex. I haven't used it, but have you considered tikz? If you have a lot of pstricks stuff, this might be too much work, but maybe it is possible to combine them? Like, use your plots, but create the arrow with tikz? –  Anke Apr 10 '13 at 9:00
Have you thought about extracting the pstricks images to extra files, processing them with latex+dvips+ps2pdf an include them in your main document with \includegraphics (pdfLaTeX is able to handle PDF-images). With this you could reuse your pstricks work in other documents easily. With using e.g. Makefiles you could process everything automatically –  Stephan Lukasczyk Apr 10 '13 at 9:12
@Anke: pstricks used in latex creates a pdf-file containing all pictures (one on each side), therefore the arrow between two pictures is lost... I have really many graphics (optical physics related thesis) and there are some graphics that have more that 50 lines of code...tried tikz at first, but some things were not possible / too difficult, so I decided to go the pstricks-way. @Stephan Lukasczyk: There are also passages where standard-text and pictures are directly connected. Will think about the Makefile, but I'm afraid that it will look bad, when including whole pages to keep it ok –  DL6ER Apr 10 '13 at 9:26
@Stephan Lukasczyk: I agree. There might be no pdflatex-solution. Also xelatex is problematic, as it produces at least a hundred errors, which I began tracking... Maybe I will find myself working on a better solution for the dvips-driver. If I get it working, I will pass it to the corresponding package authors, so that the whole community might benefit from my work. Thanks for your thoughts! –  DL6ER Apr 10 '13 at 13:30
With latex you have to use package breakurl, then long urls are no problem –  Herbert Apr 11 '13 at 7:37

Several pspictureenvironments as paragraphs can be encapsulated by the postscript environment:

\documentclass[12pt]{scrbook}
\PassOptionsToPackage{pdf}{pstricks} %used for pdflatex
\usepackage{pstricks,pst-plot,pst-node,pst-func}

\begin{document}

\begin{postscript}%%%%%%%%%%%%%%
\begin{pspicture}(-1.5,0)(1.5,4)
\psTextFrame[ref=c,linestyle=none](-1.5,3)(1.5,4){First Plot}
\psplot[fillcolor=blue!30,fillstyle=solid,opacity=0.5]{-1.5}{1.5}{x 0 0.3 GAUSS}
\psaxes[labels=none,ticks=none]{->}(-1.5,0)(1.5,3)
\pnode(1.5,0.5){A}
\end{pspicture}

\begin{pspicture}(-1.5,0)(1.5,4)
\psTextFrame[ref=c,linestyle=none](-1.5,3)(1.5,4){Second Plot}
\psplot[fillcolor=blue!30,fillstyle=solid,opacity=0.5]{-1.5}{1.5}{x 0 0.6 GAUSS}
\psaxes[labels=none,ticks=none]{->}(-1.5,0)(1.5,3)
\pnode(1.5,0.5){B}
\nccurve{->}{A}{B}
\end{pspicture}
\end{postscript}%%%%%%%%%%%%%%

\end{document}


that will be handled as a single image. My pdflatex output:

Inside the postscript environment can be anything, except a pagebreak. It will always be handled as a graphic which is saved in <file>-pics.pdf, one page per image (if you have more environments).

-
This seems pretty interesting, thanks for your answer. As I solved my latex-related problem elsewhere, there is no need for this anymore. But maybe I will have to come back to your solution if I encounter a new problem later on. –  DL6ER Apr 11 '13 at 8:20
@DL6ER: If you need microtype then you have to use pdflatex again I think because microtype will not work in latex-dvips-ps2pdf. –  kiss my armpit Apr 11 '13 at 9:13
I think it will work well using: \usepackage[DVIoutput=true]{microtype}\microtypesetup{protrusion=true,expansion‌​=true} –  DL6ER Apr 11 '13 at 9:37

## Method 1 (if you insist on using pdflatex)

When we use pdflatex to compile PSTricks code, the nodes must be in the same physical page of the auxiliary PDF file produced behind the scene.

Your original code makes the first figure and the second one get separated in different physical pages. Namely, the first one is on page x and the other one is on page y where x=/=y.

To make them on the same physical page, we can put both in another pspicture as the container. See my code below for the details.

\documentclass[12pt]{scrbook}
\PassOptionsToPackage{pdf}{pstricks} %used for pdflatex
\usepackage{pstricks,pst-plot,pst-node,pst-func}

\begin{document}

\begin{pspicture}(-1.5,-4.25)(1.5,4.25)
\rput[b](0,0.25){%
\begin{pspicture}(-1.5,0)(1.5,4)
\psTextFrame[ref=c,linestyle=none](-1.5,3)(1.5,4){First Plot}
\psplot[fillcolor=blue!30,fillstyle=solid,opacity=0.5]{-1.5}{1.5}{x 0 0.3 GAUSS}
\psaxes[labels=none,ticks=none]{->}(-1.5,0)(1.5,3)
\pnode(1.5,0.5){A}
\end{pspicture}}
%
\rput[t](0,-0.25){%
\begin{pspicture}(-1.5,0)(1.5,4)
\psTextFrame[ref=c,linestyle=none](-1.5,3)(1.5,4){Second Plot}
\psplot[fillcolor=blue!30,fillstyle=solid,opacity=0.5]{-1.5}{1.5}{x 0 0.6 GAUSS}
\psaxes[labels=none,ticks=none]{->}(-1.5,0)(1.5,3)
\pnode(1.5,0.5){B}
\nccurve{->}{A}{B}
\end{pspicture}}
\end{pspicture}
\end{document}


## Method 2 (if you are happy to use xelatex)

Without modification in your original code, just compile it with xelatex. Done!

-
Thanks, this looks good and seems to be a considerable alternative to Herberts solution (as I can actually control where the two pictures will go). Using xelatex won't make me happy as I have the feeling that xelatex is running much longer than pdflatex oder even latex + dvips + ps2pdf. –  DL6ER Apr 11 '13 at 8:24
It will not break my solution if you use the postscript environment in a correct way! –  Herbert Apr 11 '13 at 8:56
@Karl'sstudents: me too! –  Herbert Apr 11 '13 at 8:58
Thanks for your warning. This might really happen, so I will again think about xelatex, that will just be a match of timing. Just measured: latex + dvips + ps2pdf = 15sec, xelatex just over 1min, also xelatex doesn't know the command \pdffilemoddate I am using to judge whether I need to run auxilary programms like gnuplot etc. again, or if I can save this time as the old pictures are still up-to-date. –  DL6ER Apr 11 '13 at 9:00
Ok, in my opinion his solution is the better (more straight forward) one, so I accepted his answer right-away. –  DL6ER Apr 11 '13 at 9:03