3

Is there a preferred format between PNG, PDF, or EPS for use with pdflatex, particularly in terms of compile speed?

If I understand, pdflatex must convert each PNG/EPS file to a PDF file with each compile. Would it be quicker to convert to PDF files prior to compiling?

Is the standalone package a preferred method to accomplish this?

Also, if anyone is familiar with Mathworks' Simulink and Stateflow, is it preferred to use the Matlab commands print and sfprint to create PNG or EPS snapshots of systems, with the intent to use them with pdflatex.

  • 3
    png is a bitmap format so fine for images but avoid using it for line drawings such matlab plots for which a scalable format such as eps or (for pdflatex) pdf is much preferred. – David Carlisle Jun 26 '15 at 20:58
  • 1
    PNG can be used directly. EPS must be converted but they don't have to be re-converted each time, as far as I know. So compilation might take a little longer, but you won't spend the time pre-converting so it will probably be slower overall. (But this is just an a priori guess, and such guesses are never correct!) – cfr Jun 26 '15 at 21:01
  • 1
    I haven't delved into the (massive) spec for PDF, but I'm almost certain it is simpler (i.e. faster) to include a PDF in another. If you're going for raw compile speed, I'd go with PDF. – Sean Allred Jun 26 '15 at 22:08
  • Alternatively, save the raw data to file and use pgfplots to create graphs (or tikz more generally) – JPi Jun 27 '15 at 5:35
2

To build on David Carlisle's comment, there's a judgement call to make for plots with PNG (raster) vs PDF (vector). If you have a scatter plot with thousands of data points for example, there comes a point where vector graphics can make the resulting PDF document (alone or compiled into a LaTeX-produced document) large, slow and unresponsive. In such cases I output to PNG (using R and ggplot2 rather than Matlab, but the principle is the same).

I would suspect that PDF is faster than EPS but I imagine on a modern machine that the difference in compile time would be minimal it wouldn't be worth optimising.

  • 2
    Another (but more workintensiv) solution of your scatter plot problem is, to export it from matlab, R or whatever in two formats, both PNG and PDF. These two images can than be combined for example with inkscape, so that the scatter points are taken from the raster image but overlaid with axis etc. from the vector image. – user36296 Jun 26 '15 at 22:29
  • @samcarter What about Simulink system snapshots? I use the print function to take a snapshot of each subsystem in a large model. I've typically printed to png files. I'm wondering if it is worth converting them all to pdf files, as each png file takes a couple seconds to compile. – kando Jul 9 '15 at 12:59
  • @kando Sorry, I am not familiar with Simulink. – user36296 Jul 9 '15 at 15:22
  • To build on this answer, could you provide an image example of a case in which one would definitely want to use raster and a case in which one would definitely want to use vector? – kando Jan 18 '16 at 14:13

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.