I use pgfplots with externalization for generating plots in my document. For heavy plots the output PDF for a figure can grow to few hundred KB. I used Adobe Acrobat to optimize the PDFs which resulted in a significantly reduced size (from 300 KB to 20 KB). My tikzpictures purely contain plots but no text.

First, what kind of information is stored in the original file which makes it huge compared to the optimized version?

Second, to optimize the files, one way is to use Ghost script for post-processing the PDF files, however, is there anyway we can get tikz to generate smaller files in the first place? Or can we make LaTeX optimizes the PDFs generated by tikz externalization without the need for separate post-processing?

  • 1
    Can you tell us what you get when you write Compresslevel =\the\pdfcompresslevel Minor = \the\pdfminorversion obj level compression =\the\pdfobjcompresslevel right into your document? I believe 9, 5, 2 are the values which should result in small values. These parameters are for pdflatex, by the way. – Christian Feuersänger Apr 6 '14 at 18:17
  • @ChristianFeuersänger, I have tried puting \pdfminorversion=5 \pdfcompresslevel=9 \pdfobjcompresslevel=2 in the beginning of my document but there is no change in size of the generated PDFs using tikz externalize! My plots are scatter plots which contain over 3000,4000 points, I assume after optimizing using Acrobat some dense regions are merged into a bigger object while the output of externalize are individual point. Would that be the reason for large files produced by externalize? – M.Reza Apr 7 '14 at 18:13
  • 2
    That could be the case... I do not know if Acrobat applies lossy vector-to-bitmap compression. But I suppose it has more options for lossless compression that pdftex. Unfortunately, I am unaware of more levels of compression by means of latex. I only know the options to reduce the sampling density or to choose a different (simpler) marker or to prefer a surf plot with shader=interp. The postprocessing could be inserted into the externalization command, I suppose. – Christian Feuersänger Apr 7 '14 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.