Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to use pstricks with auto-pst-pdf. However, running the example code on http://tug.org/PSTricks/main.cgi?file=pdf/pdfoutput#autopstpdf gives me the following error:

Package auto-pst-pdf Warning:
    Could not create document-pics.pdf. Auxiliary files not deleted.
This warning occured on input line 124.

This is the input

\documentclass[12pt]{article}

\usepackage{pstricks}
\usepackage{auto-pst-pdf}

\pagestyle{empty}

\begin{document}

\begin{pspicture}(-5.25,-5.25)(5.25,5.25)%
  \pscircle*[linecolor=cyan]{5}
  \psgrid[subgriddiv=0,gridcolor=lightgray,gridlabels=0pt]
  \Huge\sffamily\bfseries
  \rput(-4.5,4.5){A} \rput(4.5,4.5){B}
  \rput(-4.5,-4.5){C}\rput(4.5,-4.5){D}
  \rput(0,0){auto-pst-pdf}
  \rmfamily
  \rput(0,-3.8){PSTricks}
  \rput(0,3.8){\LaTeX}
\end{pspicture}

% \includegraphics{foo}% can be foo.jpg or foo.png

\end{document}

This is the output:

Z:\>pdflatex -shell-escape C:\Daten-Privat\mjira\workspace\test\document.tex
This is pdfTeX, Version 3.1415926-1.40.11 (MiKTeX 2.9)
entering extended mode
(C:/Daten-Privat/mjira/workspace/test/document.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, afrikaans, ancientgreek, ar
abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic,
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga
lician, german, german-x-2009-06-19, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, lao, latin, lat
vian, lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerm
an, ngerman-x-2009-06-19, nynorsk, oriya, panjabi, pinyin, polish, portuguese,
romanian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swis
sgerman, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, u
senglishmax, welsh, loaded.
("C:\Programme\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
("C:\Programme\MiKTeX 2.9\tex\latex\base\size12.clo"))
("C:\Programme\MiKTeX 2.9\tex\latex\pstricks\pstricks.sty"
>>> Loading package auto-pst-pdf <<<
("C:\Programme\MiKTeX 2.9\tex\generic\pstricks\pstricks.tex"
("C:\Programme\MiKTeX 2.9\tex\generic\xkeyval\pst-xkey.tex"
("C:\Programme\MiKTeX 2.9\tex\latex\xkeyval\xkeyval.sty"
("C:\Programme\MiKTeX 2.9\tex\generic\xkeyval\xkeyval.tex"
("C:\Programme\MiKTeX 2.9\tex\generic\xkeyval\keyval.tex"))))
("C:\Programme\MiKTeX 2.9\tex\generic\pstricks\pst-fp.tex"
`pst-fp' v0.05, 2010/01/17 (hv))
`PSTricks' v2.13  <2010/11/01> (tvz)
("C:\Programme\MiKTeX 2.9\tex\generic\pstricks\pstricks.con"))
("C:\Programme\MiKTeX 2.9\tex\generic\pstricks\pst-fp.tex")
("C:\Dokumente und Einstellungen\mjira\anwendungsdaten\MiKTeX\2.9\tex\latex\xco
lor\xcolor.sty" ("C:\Programme\MiKTeX 2.9\tex\latex\00miktex\color.cfg")
("C:\Programme\MiKTeX 2.9\tex\latex\pdftex-def\pdftex.def"))) (Z:\document.aux)

("C:\Dokumente und Einstellungen\mjira\anwendungsdaten\MiKTeX\2.9\tex\latex\aut
o-pst-pdf\auto-pst-pdf.sty"
("C:\Programme\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty")
("C:\Dokumente und Einstellungen\mjira\anwendungsdaten\MiKTeX\2.9\tex\latex\ifp
latform\ifplatform.sty"
("C:\Programme\MiKTeX 2.9\tex\generic\oberdiek\pdftexcmds.sty"
("C:\Programme\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty")
("C:\Programme\MiKTeX 2.9\tex\generic\oberdiek\ifluatex.sty")
("C:\Programme\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"))
("C:\Programme\MiKTeX 2.9\tex\generic\oberdiek\catchfile.sty"
("C:\Programme\MiKTeX 2.9\tex\generic\oberdiek\etexcmds.sty")))" "
"-------------------------------------------------"
"auto-pst-pdf: Auxiliary LaTeX compilation"
"-------------------------------------------------"


Package auto-pst-pdf Warning:
    Could not create document-pics.pdf. Auxiliary files not deleted.
This warning occured on input line 124.

"-------------------------------------------------"
"auto-pst-pdf: End auxiliary LaTeX compilation"
"-------------------------------------------------"

("C:\Dokumente und Einstellungen\mjira\anwendungsdaten\MiKTeX\2.9\tex\latex\pst
-pdf\pst-pdf.sty" ("C:\Programme\MiKTeX 2.9\tex\latex\graphics\graphicx.sty"
("C:\Programme\MiKTeX 2.9\tex\latex\graphics\graphics.sty"
("C:\Programme\MiKTeX 2.9\tex\latex\graphics\trig.sty")
("C:\Programme\MiKTeX 2.9\tex\latex\00miktex\graphics.cfg")))
("C:\Dokumente und Einstellungen\mjira\anwendungsdaten\MiKTeX\2.9\tex\latex\pre
view\preview.sty"
Preview: Fontsize 12pt
Preview: PDFoutput 1
) ("C:\Programme\MiKTeX 2.9\tex\latex\graphics\dvips.def")
("C:\Dokumente und Einstellungen\mjira\anwendungsdaten\MiKTeX\2.9\tex\latex\env
iron\environ.sty")))
("C:\Dokumente und Einstellungen\mjira\anwendungsdaten\MiKTeX\2.9\tex\context\b
ase\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
)

Package pst-pdf Warning: pspicture No. 1 undefined.


Package pst-pdf Warning: File `document-pics.pdf' not found.
(pst-pdf)                Use the following commands to create it:
(pst-pdf)                ----------------------------------------------------
(pst-pdf)                latex document.tex
(pst-pdf)                dvips -o document-pics.ps document.dvi
(pst-pdf)                ps2pdf document-pics.ps
(pst-pdf)                ---------------------------------------------------- .


(Z:\document.aux) )
No pages of output.
Transcript written on document.log.

(Strawberry-)Perl is installed:

Z:\>perl -v

This is perl 5, version 12, subversion 3 (v5.12.3) built for MSWin32-x86-multi-t
hread

Copyright 1987-2010, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Have you got an idea what to check?

share|improve this question
1  
do you have the program pdfcrop? You can try to run it with usepackage[crop=off]{auto-pst-pdf. However, you can run xelatex instead and then you do not nueed auto-pst-pdf –  Herbert Aug 17 '11 at 10:04
    
works with usepackage[crop=off]{auto-pst-pdf}! Strange, pdfcrop is installed referring to MikTeX... Thank you for your help! Great you are present on every LaTeX-Forum on the internet! –  Marcel Aug 17 '11 at 10:13

1 Answer 1

up vote 4 down vote accepted

If you want all PSTricks code to be imported from within the TeX main input file, then it will be better using xelatex than using pdflatex +auto-pst-pdf. There are many limitations of using pdflatex + auto-pst-pdf. I will list the details in the next edit.

If you want some PSTricks code to be imported in the TeX main input file and the remaining PSTricks code to be converted to PDF images, then use xelatex + preview package.


If your PSTricks code

  • makes use of \label as in the following example:

    \begin{equation}\label{eq:Einstein}
    \rnode{A}{E}=mc^\rnode{B}{2}
    \ncbar[angle=90]{A}{B}
    \end{equation}
    
  • or imports an image of type PNG, PDF, JPG as in the following example:

    \newsavebox\IBox
    \savebox\IBox{\includegraphics{image.jpg}}
    \pspicture(\wd\IBox,\ht\IBox)
    \rput[bl](0,0){\usebox\IBox}
    \endpspicture
    
  • or works together with animate package as in the following example:

    \animateinline[palindrome,autoplay]{10}
    \multiframe{11}{r=1+-0.1}{%
    \pspicture(2,2)
    \pscircle*[linecolor=red,opacity=0.5](1,1){\r}
    \endpspicture}
    \endanimateinline
    

then pdflatex -enable-write18 + auto-pst-pdf cannot be used to produce the correct result.

The solution: use xelatex instead but it runs very very slowly if you compile the whole input files. To speed up the compilation, you should divide the your input file into several sub-files. Put each of "independent" PSTricks fragment into a separate input file and compile it to produce a single PDF output.

Note: An independent PSTricks fragment is a PSTricks code that does not belong to the 3 cases mentioned above.

An example of an "independent" PSTricks fragment:

% frame.tex
\documentclass{article}
\usepackage{pstricks}

% preview must come after any pstricks package!
\usepackage[active,tightpage]{preview}
\PreviewBorder=0pt\relax

% Either
\PreviewEnvironment{pspicture}
% or
%\PreviewEnvironment{pspicture*}

\begin{document}
\begin{pspicture}(1,1)
\psframe(1,1)
\end{pspicture}
\end{document}

Compile it with xelatex (slower than the snail) or latex-dvips-ps2pdf (faster than the light) and you will get frame.pdf.

Later, you can import the frame.pdf from within your main input file as follows:

% main.tex
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{frame.pdf}\newpage


    \animateinline[palindrome,autoplay]{10}
    \multiframe{11}{r=1+-0.1}{%
    \pspicture(2,2)
    \pscircle*[linecolor=red,opacity=0.5](1,1){\r}
    \endpspicture}
    \endanimateinline

\end{document}

Once again, compile the main input file using xelatex only. But compilation becomes faster! Note: latex-dvips-ps2pdf cannot import PDF images, that is why you have to use xelatex only!

NOTE: The main input file must NOT load preview package if you load animate package. Practically, you never need to load preview in the main input file, only sub-files need preview.

share|improve this answer
    
what a great compendium! Thank you! –  Marcel Aug 17 '11 at 10:44
    
for 3D animations it it much more faster to use pst-pdf and then import the created pdf as \animategraphics[controls,loop]{5}{Animate-pics}{}{}. –  Herbert Aug 17 '11 at 11:47
    
@Herbert: Are you sure the PDF animations produced by pst-pdf will still work if they are imported in the main input file? In my experience, PDF animation files will no longer work if they are imported in the main input file. That is why the raw PSTricks code that corresponds to the animation must be inserted to the main input file and recompiled together with the main input file. –  xport Aug 17 '11 at 11:56
    
@xport: latex.userpage.fu-berlin.de/animate.pdf –  Herbert Aug 17 '11 at 12:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.