1

When explaining diagrams (in Economics), making them more complex in a step-by-step manner is often useful for students. What I usually do is to draw a pstricks image (that may contain a lot of details) and when done, I repeatedly copy&paste the code and comment out the parts that I want to be displayed later on.

A simple example for this procedure is

\documentclass[13pt]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{pstricks}
\usepackage{auto-pst-pdf}
\usepackage{pstricks-add}

\begin{document}

\begin{pspicture}(-1,-1)(10,10)
% always show this
\rput(0,0){\psaxes[labels=none,ticks=none]{->}(0,0)(8,8)}
%\psgrid(0,0)(8,8) 
%step1
\psline(1,1)(5,6)
%step2 - final
%\psline(1,6)(6,1)
\end{pspicture}

\begin{pspicture}(-1,-1)(10,10)
% always show this
\rput(0,0){\psaxes[labels=none,ticks=none]{->}(0,0)(8,8)}
%\psgrid(0,0)(8,8) 
%step1
\psline(1,1)(5,6)
%step2 - final
\psline(1,6)(6,1)
\end{pspicture}

\end{document} 

The result is a pdf with extension ...-pics.pdf with two images on separate pages that I can include elsewhere with \includegraphics[page=1]{...-pics.pdf} and \includegraphics[page=2]{...-pics.pdf}

My question: Is there a more elegant way to do this where it is enough to draw the image just once and then tell pstricks that the image should be produced in different versions/steps? Something like

\begin{pspicture}(-1,-1)(10,10)
\stepwise[0]
\rput(0,0){\psaxes[labels=none,ticks=none]{->}(0,0)(8,8)}
\stepwise[1]
\psline(1,1)(5,6)
\stepwise[2]
\psline(1,6)(6,1)
\end{pspicture}

Using several \newcommands and then reusing code is an option, but I am looking for an easier way to this.

1 Answer 1

1

Use the beamer documentclass with a plain canvas:

\documentclass{beamer}
\usepackage{auto-pst-pdf}
\usepackage{pstricks-add}
\setbeamertemplate{navigation symbols}{}
\begin{document}
\frame[plain]{%
    \psset{unit=0.75}
    \begin{pspicture}[showgrid](-1,-1)(10,10)
    \rput(0,0){\psaxes[labels=none,ticks=none]{->}(0,0)(8,8)}
    \psline(1,1)(5,6)          \pause
    \psline(1,6)(6,1)
    \end{pspicture}%
}   
\end{document} 

You can run pdfcrop on that document if you want to delete the whitespace.

5
  • thanks a lot, sounds like a straightforward workflow. However, if the main file is called stepwise.tex, I get stepwise.pdf with only one page and also only one of the two \pslines. However, stepwise-pics.pdf contains two pages with two properly cropped images. Hm - how to make sure that one can see the entire image in the main pdf, too? Because this is what is shown by my LaTeX-Editor....
    – Daniel
    Jul 9, 2016 at 21:48
  • Adding for every pause command another frame containing a pspicture like this \frame[plain]{% \begin{pspicture}[showgrid](-1,-1)(1,1) \end{pspicture} } somehow "solves" the problem.
    – Daniel
    Jul 9, 2016 at 22:37
  • Found it: it is a problem with auto-pst-pdf. But using XeLaTeX for typesetting really solves the problem. (Hopefully with not too many side-effects.) THANKS!
    – Daniel
    Jul 9, 2016 at 23:13
  • Without using package auto-pst-pdf and running xelatex you'll get a pdf with two pages.
    – user2478
    Jul 10, 2016 at 5:57
  • yes, thank you. (I then miss my multi-page pdf, though.)
    – Daniel
    Jul 10, 2016 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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