My best practice (recommendation) is as follows.
- Every diagram should be put in separate file using
standalone document class.
- If you want to use the same font in both diagrams and texts, then create a private package that will be loaded by both the main input file and the diagram input files.
- Always compile the diagram with
latex followed by
dvips followed by
ps2pdf to produce the diagram in PDF. This route is very very fast compared to using
xelatex. Don't load
auto-pst-pdf in this diagram input file.
- Load the PDF diagrams from within the main input file using
\includegraphics, and compile the main input file with
Responding to your comment about the third step, here is the steps you have to do. I don't use TeXStudio so I am not sure there is a shortcut to invoke all of them in one go. Be careful, the following code turn on
-shell-escape for the sake of my own purposes.
Second, write a batch file as follows. Save it with any name as you like, for example,
pstricksbuilder.bat. Save the file in a safe place so you will not lose it if you format your hard drive in the future.
rem %1 TeX input filename without extension
if exist "%~1.pdf" del "%~1.pdf"
if exist "%~1.tex" latex -shell-escape "%~1.tex"
if exist "%~1.dvi" dvips -t unknown "%~1.dvi"
if exist "%~1.ps" gswin64c -dCompatibilityLevel=1.5 -dAutoRotatePages=/None -sDEVICE=pdfwrite -o "%~1.pdf" "%~1.ps"
for %%x in (aux dvi log out ps toc nav snm) do (if exist "%~1.%%x" del "%~1.%%x")
First, install GhostScript 64 bit. If you use Ghostscript 32 bit then you have to change the
gswin32c (I think the name is correct).
Third, register the batch to the
PATH environment variable. I think you know how to do this. If you don't, ask with comments.
Fourth, replace any unused (for example,
DVI Viewer) TeXStudio command with
pstricksbuilder.bat %. Done!
Fifth, use the following test page.
auto-pst-pdf package in your input file. Make sure to pass
pstricks option to
The simplest trick
Having done the trick given above, you now have another one, the simplest trick. You don't need to register to the PATH, etc but just edit the following.