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 found this interesting question Draw closed curve in Tikz for which an even interesting answer was provided by the user Garbage Collector.

Just for the fun of it, I tried compiling his answer on my system, which I have pasted here:

\documentclass[pstricks,border=3pt]{standalone}
\usepackage{pstricks-add}
\def\N{15}
\begin{document}
\psLoop{20}{%
\begin{pspicture}[showgrid=false](-2,-2)(2,5)
    \psclip{\psbezier[linestyle=none](0,5)(-6.8,-4.3)(6.8,-4.3)(0,5)}
        \psLoop{\N}{
            \rput(!rand 21 mod 10 div 1 sub rand 51 mod 10 div 1 sub){$+$}
            \rput(!rand 21 mod 10 div 1 sub rand 51 mod 10 div 1 sub){$-$}}%
    \endpsclip
    \psbezier[linecolor=orange](0,5)(-6.8,-4.3)(6.8,-4.3)(0,5)
\end{pspicture}}
\end{document}

I received 120 error messages, all of them read: 13: Undefined control sequence \end{pspicture}}. Can someone shed any light on this matter?

share|improve this question

closed as too localized by Werner, lockstep, egreg, diabonas, percusse Sep 24 '12 at 11:45

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
The code works OK here. Did you compile with latex instead of pdflatex? –  Gonzalo Medina Sep 24 '12 at 1:42
    
@GonzaloMedina Yeah that was the error. I used pdflatex instead of latex. I haven't used anything other than pdflatex. What's the output I should expect while using latex? I tried opening the .dvi file that was generated but it shows an unexpected result. While scrolling down on the .dvi file I got the error: –  Shashank Sawant Sep 24 '12 at 1:54
    
Error: /undefined in tx@Dict Operand stack: --nostringval-- PermitFileReading --nostringval-- PermitFileWriting --nostringval-- Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1914 1 3 %oparray_pop 1913 1 3 %oparray_pop 1897 1 3 %oparray_pop 1787 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push -- –  Shashank Sawant Sep 24 '12 at 1:55
    
nostringval-- Dictionary stack: --dict:1166/1684(ro)(G)-- --dict:0/20(G)-- --dict:78/200(L)-- --dict:95/300(L)-- Current allocation mode is local Last OS error: No such file or directory MiKTeX GPL Ghostscript 9.00: Unrecoverable error, exit code 1 –  Shashank Sawant Sep 24 '12 at 1:55
1  
@convert the dvi to pdf using dvipdf, for example. –  Gonzalo Medina Sep 24 '12 at 2:01

1 Answer 1

up vote 2 down vote accepted

Try the following code that compiles the PSTricks code behind the scene. You just need to type pdflatex -shell-escape main in your terminal or DOS command window.

In the directory in which this input file exists, you will get GIF animation, PDF animation, PNG frames. Make sure that you have installed ImageMagick (the latest version is recommended to make sure that remove option is available).

% this filename is main.tex
% compile it with "pdflatex -shell-escape main" (without the quotes)

\documentclass[preview,border={7pt 0pt 7pt 0pt}]{standalone}
\usepackage{filecontents}
\begin{filecontents*}{WaterDrop.tex}
\documentclass[pstricks,border=3pt]{standalone}
\usepackage{pstricks-add}
\def\N{15}
\begin{document}
\psLoop{20}{%
\begin{pspicture}[showgrid=false](-2,-2)(2,5)
    \psclip{\psbezier[linestyle=none](0,5)(-6.8,-4.3)(6.8,-4.3)(0,5)}
        \psLoop{\N}{
            \rput(!rand 21 mod 10 div 1 sub rand 51 mod 10 div 1 sub){$+$}
            \rput(!rand 21 mod 10 div 1 sub rand 51 mod 10 div 1 sub){$-$}}%
    \endpsclip
    \psbezier[linecolor=orange](0,5)(-6.8,-4.3)(6.8,-4.3)(0,5)
\end{pspicture}}
\end{document}
\end{filecontents*}

\immediate\write18{latex WaterDrop}
\immediate\write18{dvips WaterDrop}
\immediate\write18{ps2pdf WaterDrop.ps}% sometimes you need to disable auto rotate in ps2pdf. Please follow up if you really need it!
% delete auxiliary files generated by the 3 commands above.
% cmd /c del WaterDrop.ext is Windows command, adapt it to other OS.
\makeatletter
\@for\x:={tex,dvi,ps,log,aux}\do{\immediate\write18{cmd /c del WaterDrop.\x}}
\makeatother

% convert to GIF animation
\immediate\write18{convert -delay 100 -loop 0 -density 200 -alpha remove WaterDrop.pdf WaterDrop.gif}

% convert to PNG
\makeatletter
\immediate\write18{convert -density 200 -alpha on WaterDrop.pdf WaterDrop-\@percentchar02d.png}
\makeatother

\usepackage{animate}
\begin{document}
%\animategraphics[controls,autoplay,loop,scale=<integer>]{<frame rate>}{<PDF filename without extension>}{<left blank>}{<left blank>}
\animategraphics[controls,autoplay,loop,scale=1]{3}{WaterDrop}{}{}
\end{document}
share|improve this answer
    
For more details, see How to create animations and videos in a single input file. –  cyanide-based food Sep 25 '12 at 20:11

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