2

Problem of me as the following:

My code is compiled with pdflatex.exe --shell-escape -interaction=nonstopmode %.tex

Its image (use TeXstudio)

enter image description here

After compiling, there are two files : filename.pdf and filename-pics.pdf.

Question

How to ignore one of two files if I use the standalone enviroment? May be not?

Minimal Working Example

\documentclass[12pt]{standalone}
\usepackage{newcent}
\usepackage{pstricks,pst-venn}
\usepackage{auto-pst-pdf} 
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
\psframe(-2.8,-2.8)(2.8,2.8)
\psVenn[bgcircle=false](-1,.5)(0,-1)(1,.5){1.5}{4}
\rput(-1,1.2){A}\rput(1,1.2){B}\rput(0,-2.1){C}
\psline(0,1.3)(.4,2.3)  \uput[20](.3,2.4){$?$}
\end{pspicture}
\end{document}

The result :

enter image description here

P/s: When using the standalone environment, they are equivalent.

  • the *-pics.pdf is always a helper file and can be deleted if not needed for other cases. – user2478 Dec 6 '18 at 9:30
  • @Herbert It takes a longer time to compile two files. I don't want so that. :((. But if it is default, I will accept it. – user173875 Dec 6 '18 at 9:55
  • You do not understand the meaning of the helper file. You have to to do nothing, all is done by package auto-pst-pdf. Use \usepackage[cleanup={log,aux,dvi,ps,pdf}]{auto-pst-pdf} and all helper files will be deleted in the end. If you are using standalone then loading auto-pst-pdf makes no sense! – user2478 Dec 6 '18 at 10:42
  • :((, It seems you have misunderstood. My opinion is if I use standalone then *.pdf and *-pics.pdf are equivalent( alike ). I feel that " *-pics.pdf " superfluous. And how to ignore " *-pics.pdf " file. As you say, I will accept its survival. P/s: Truly I use PStricks to draw my picture then together with \includegraphics and compile with pdflatex. :-(( – user173875 Dec 6 '18 at 11:11
  • I already wriote that using standalone and auto-pst-pdf is senseless! The created file <file>-pics.pdf is not used by standalone. See my answer. – user2478 Dec 6 '18 at 12:33
2

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 pdflatex.

Edit

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.

enter image description here

Another Trick

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.

echo off

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 gswin64c to 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.

enter image description here

Fourth, replace any unused (for example, DVI Viewer) TeXStudio command with pstricksbuilder.bat %. Done!

Fifth, use the following test page.

\documentclass[pstricks,border=12pt,12pt]{standalone}
\begin{document}
\begin{pspicture}[showgrid](3,3)

\end{pspicture}
\end{document}

Note: remove auto-pst-pdf package in your input file. Make sure to pass pstricks option to \documentclass[pstricks]{standalone}.

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.

enter image description here

  • Oh, I fixed it. I misunderstood. – user173875 Dec 18 '18 at 12:42
3

For a standalone document the following code:

\documentclass[12pt,pstricks]{standalone}
\usepackage{pst-venn}
\begin{document}
    \begin{pspicture}(-3,-3)(3,3)
    \psframe(-2.8,-2.8)(2.8,2.8)
    \psVenn[bgcircle=false](-1,.5)(0,-1)(1,.5){1.5}{4}
    \rput(-1,1.2){A}\rput(1,1.2){B}\rput(0,-2.1){C}
    \psline(0,1.3)(.4,2.3)  \uput[20](.3,2.4){$?$}
    \end{pspicture}
\end{document}

creates a <file>.pdf and no <file>-pics.pdf!

Using auto-pst-pdf with for example:

\documentclass[12pt]{article}
\usepackage{auto-pst-pdf}
\usepackage{pst-venn}
\begin{document}
    \begin{pspicture}(-3,-3)(3,3)
    \psframe(-2.8,-2.8)(2.8,2.8)
    \psVenn[bgcircle=false](-1,.5)(0,-1)(1,.5){1.5}{4}
    \rput(-1,1.2){A}\rput(1,1.2){B}\rput(0,-2.1){C}
    \psline(0,1.3)(.4,2.3)  \uput[20](.3,2.4){$?$}
    \end{pspicture}
\end{document}

creates a helper file <file>-pics.pdf which collects all images as single pages which will be included automatically into the pdf.

Using documentclass standalone and package auto-pst-pdf id senseless, because standalone itself creates the images!

  • When I compile the first code of you ( I use pdflatex.exe --shell-escape -interaction=nonstopmode %.tex also pdflatex.exe -synctex=1 -interaction=nonstopmode %.tex ), compiler take error. why ?. P/s: The second code works smoothly with pdflatex.exe --shell-escape -interaction=nonstopmode %.tex – user173875 Dec 6 '18 at 12:42
  • standalone and PStricks can only be used with xelatex or latex->dvips-ps2pdf and not with pdflatex. Only the second example can be run with pdflatex --shell-escape ... – user2478 Dec 6 '18 at 12:51
  • Wow, I see. Thank you for your interpretation. :-)). I understood. – user173875 Dec 6 '18 at 12:58

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.