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 use LaTeX regularly, and several times I have included .eps images. I am learning how to use PSTricks. I have used it to create .ps and .pdf files with images. There is plenty of free information on the web, but I haven't seen the answer to this question: how do you include the pictures that PSTricks produces in your LaTeX file?

share|improve this question

3 Answers 3

up vote 5 down vote accepted

If you have image files (EPS or PDF) you can include them with the graphicx package and \includegraphic{<filename>}. latex needs an EPS and pdflatex a PDF file. If you put both in your folder and omit the suffix in the including macro the package decied which file to use automatically.

If you want to include the PSTricks code directly you may use the {pspicture}environment.

share|improve this answer

If you write each PSTricks diagram in a separate TeX input file and compile it with latex-dvips-ps2pdf (much faster) or xelatex (slower) to obtain a PDF output, you might need the PDF output without white spaces around it.

To obtain the tight PDF output, use the following template for each diagram you want to make.


% your drawing code goes here!

It will be better if you put all your TeX input files for creating diagrams in a special folder outside other projects you have. This method will make your diagrams consumable to many projects easily. My directory structures look like below.

enter image description here

All my TeX input file for creating diagrams are placed in Diagrams. The PDF outputs associated with the input files are also in Diagrams for sure.

Another project, namely ProjectA, might use the diagrams you have made before. For example, let Main.tex be the input file in ProjectA folder. You can import the diagrams easily as follows.


\caption{This is my PSTricks template.}

The important points are:

  • Load graphicx and set the graphics path. Adjust the scale to meet your preference.
  • Compile it with pdflatex or xelatex. You cannot use latex-dvips-ps2pdf unless you have EPS equivalent for each PDF output.
share|improve this answer
In case anyone is interested, I ended up using \documentclass[12pt]{standalone} in the file where the picture was drawn. It worked fine. –  bogus Mar 25 '12 at 19:41
@user20520: standalone internally uses preview package. –  Please don't touch Mar 25 '12 at 19:47
@bogus: I updated the template in my answer, now it uses standalone class you prefer. –  Please don't touch Sep 7 '13 at 2:57

Say your PSTricks figure file looks like this:


saved by the name picture_file.tex in the same folder as your main latex file.

In your latex main file, saved by the name main_file.tex, add

\usepackage{pstricks}    %for embedding pspicture.
\usepackage{graphicx}    %for figure environment.

in the preamble. (You can add additional things also as your needs.)

Now, the picture_file.tex can be included in the main_file.tex as:

\caption{your caption} \label{fig:figureone}

Only the main_file.tex needs be compiled.


  1. If you use different fonts other than default ones, the fonts in figures will blend perfectly with the rest of the document by this method.
  2. Make sure the \documentclass[...]{...} does not have minimal or letter as the type, in which case, the figure environment would not be recognized.
share|improve this answer

Your Answer


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.