# How to crop an image made with pstricks?

I'm writing this piece of code, which will be an image to incorporate in a paper, and I would like to crop it along the edges of the frame I have drawn. I know the frame is almost the size of the page and so, apparently, there would be no need for any cropping, but this is only a test. I read about the standalone class, which was supposed to solve this problem for me but I don't know what is going on. Could you lend me a helping hand here?

Thank you very much.

'\documentclass{standalone}
\usepackage{pst-plot}

\begin{document}

\begin{pspicture}(-1,-1)(6,6)
\psgrid[griddots=10,gridlabels=10pt, subgriddiv=0, gridcolor=black!20](1,2)(0,0)(19.5,26)

\psframe[linewidth=0.065cm,linecolor=black](0,0)(19.5,26)

\end{pspicture}

\end{document}'

• Please use the {} code button to format code blocks rather than the quotation button. Alternatively, ctrl+k. The result should be that each line is indented by 4 spaces and there is no > (unless it is part of your code, of course). – cfr Apr 16 '16 at 0:32
• What's the problem exactly? What do you mean that you don't know what is going on? What happens? Do you get an error? If so, what error exactly? – cfr Apr 16 '16 at 0:34
• The problem is that the image is not cropped when I use the standalone class. – Gabu Apr 16 '16 at 0:55

Use

 \documentclass[pstricks]{standalone}


Then it uses the dimensions of the pspicture Environment for cropping

Is this what you want? The starred version of the pspicture environment crops what it contains to its dimensions:

\documentclass{standalone}

\usepackage{auto-pst-pdf}

\begin{document}

\begin{pspicture*}(-1,-1)(6,6)
\psgrid[griddots=10,gridlabels=10pt, subgriddiv=0, gridcolor=black!20](1,2)(0,0)(19.5,26)

\psframe[linewidth=0.065cm,linecolor=black](0,0)(19.5,26)

\end{pspicture*}

\end{document}


• Something along these lines, yes. :) – Gabu Apr 16 '16 at 1:51
• What I don't get is why the dimensions of the grid are so different from those of the pspicture environment. – Bernard Apr 16 '16 at 1:56
• I copied your code and run it. It does not work for me. – Gabu Apr 16 '16 at 4:53
• @Gabu: I suppose you've compiled with pdflatex. The auto-pst-pdf package is done for that (pdflatex can't manage postscript code by itself). You have to launch pdf latex with the --enable-write18 switch if you're under MiKTeX, or -shell-escape (TeX Live, MacTeX). Alternative way: compile with xelatex. – Bernard Apr 16 '16 at 9:51