# Deleting ps automatically

While using the pdf latex chain, how can one delete the *.ps file automatically right after the pdf has been created? *.ps files can be big (~100 MB). Hence, this question.

• I use pdftex, which doesn't create a .ps file. In general, the same program you used to make the chain may have an option to delete the .ps file afterwards. Jan 27 '14 at 5:32
• If you have to follow the DVI > PS > PDF chain, perhaps using xelatex might be of help to compile directly to PDF.
– Werner
Jan 27 '14 at 6:04
• Assuming latex -> dvips - > ps2pdf, it's down to the script you use for the build to do the deletion. We'll need more detail about how you do things. Jan 27 '14 at 6:56
• Presumably this question should not be tagged pdftex, as there are no ps files in that case Jan 27 '14 at 10:01
• @DavidCarlisle: You can edit the tags of questions. :-) Jan 28 '14 at 10:39

One way of doing this is to compile with arara instead of the usual build chain in TeXstudio. arara is a compilation tool where you describe which steps should be part of the compilation sequence in comments placed at the top of the file. A description of setting up arara in TeXstudio can be found in https://tex.stackexchange.com/a/118899/586

A minimal example is

% arara: latex
% arara: dvips
% arara: ps2pdf
% arara: clean: { files: [ test.dvi, test.ps ] }

\documentclass{article}
\begin{document}
Hello world!
\end{document}


If this is saved in test.tex, then running arara test.tex will compile the sequence latex - dvips - ps2pdf, and then remove the test.dvi and test.ps files. Note that in %arara: ps2pdf the ps2pdf part is not the name of a binary, it is the name of a rule, which is defined by arara. As such, you can't just put the name of any program here.

Sample terminal output:

testdir$ls test.tex testdir$ arara test.tex
__ _ _ __ __ _ _ __ __ _
/ _ | '__/ _ | '__/ _ |
| (_| | | | (_| | | | (_| |
\__,_|_|  \__,_|_|  \__,_|

Running LaTeX... SUCCESS
Running DVIPS... SUCCESS
Running PS2PDF... SUCCESS
Running CleaningTool... SUCCESS
Running CleaningTool... SUCCESS
testdir$ls test.aux test.log test.pdf test.tex testdir$
`