# How can I generate a PS and a PDF file from a single .tex file?

I am submitting a paper for a conference and it requires me to send the .tex source along with the PS and PDF files.

I have no problem generating the PDF file; I simply use the pdflatex. However, since my .tex makes use of the PNG, JPEG and PDF figures, I can't use latex + dvips to create the PS file.

How can I solve this problem? Note that converting all my figures to PS won't solve the problem, because I would need two different .tex files since the includegraphics commands would be different.

-
The `\includegraphics` commands don't have to be different. If you leave off the extension then it works out the best format to include. So then you can have the PS versions and the PDF ones alongside each other with `latex` using the PS versions and `pdflatex` using the PDF ones. – Loop Space Aug 20 '11 at 20:46
Yes, that worked for me so the problem is now solved for me. The problem is that I had to manually convert all my figures to PS. I wonder if there is an easier solution for this problem. – Alceu Costa Aug 20 '11 at 21:22
Are you on Linux? If so, `foreach f in *.pdf; do pdftops \$f; done` should do the trick (though the exact syntax might be shell-specific - I use `zsh`). – Loop Space Aug 20 '11 at 21:26

If you're using PDF pictures, you may not be able to output to PS without at some point doing a conversion. Comments on one of the other answers suggest using `pdftops` rather than `pdf2ps`, I have no personal experience. You may be able to just convert the figures, then compile with both `latex`/`dvips` and `pdflatex`, or it may be easier to just compile with `pdflatex` and then convert the final document to PS.

-

Here's how I solved the proposed question.

First, as Andrew Stacey noted, I don't need to have different `\includegraphics` commands. This can be achieved by simply leaving off the image file extension.

The next step consisted in generating EPS versions of all my figures. I did this manually, but as noted in the comments, that could've been much easier by using a script and a command line image conversion application (note that `pdftops` wouldn't work for JPEG or PNG images).

Finally, I generated the PS file with `latex + dvips` and the PDF with `latexpdf`. Alternatively, it would be possible to generate the PDF file with `latex + dvips + ps2pdf`.

Note that this approach is better than generating the PDF file and then using `pdf2ps` or `pdftops` to create the PS file. This is because `pdf2ps` and `pdftops` outputs a excessively big PS file (see Jukka comment on chl answer).

-
I think that if you use the `convert` command from the `ImageMagic` (?spelling?) package then it doesn't need to know the input format to do the conversion so would work with `jpeg`, `png`, and `pdf` without changing the format. Alternatively, it wouldn't be hard to write a short shell script that converted all the images using specific tools according to their type. – Loop Space Aug 22 '11 at 6:36

May be there are better solutions, but this worked out well for me. If you use adobe, you can easily save the .pdf file in .ps format. This is pretty much the same way as when you save a .doc file as .pdf.

-
Welcome to TeX.SX! Thanks for answering and participating here. – LaRiFaRi May 19 '15 at 9:11

Can't you just use `pdf2ps` which comes with the Ghostscript Tools? (See here for an example bash script which makes use of `gs` directly.)

-
`pdf2ps` is a very bad idea; try `pdftops` instead. See, for example, stefaanlippens.net/pdf2ps_vs_pdftops – Jukka Suomela Aug 20 '11 at 21:17
The main problem that I had with pdf2ps is that the output file is huge. For example, my PDF file size was 1.2 MB while the generated PS file had more than 20 MB. – Alceu Costa Aug 20 '11 at 21:19
@Alceu: Did you try pdftops? It seems to work very well, and I have used it in a similar situation. – Jukka Suomela Aug 20 '11 at 21:21
@Jukka (+1) Thanks. It's really faster compared to `pdf2ps`, but about the size I got similar results on a very basic document (pdf: 1,8M; pdf2ps: 8,6M; pdftops: 9,9M). – chl Aug 20 '11 at 21:30
I don't have pdftops installed here. I think that the problem with the size of the PS file is related to conversion of fonts to bitmaps. – Alceu Costa Aug 20 '11 at 21:40