📜 ⬆️ ⬇️

Optimization of vector graphics for LaTeX'a.

Why optimization is needed : eps and pdf files saved by a vector editor are not always fully compatible with LaTeX. In addition, reducing their size has a positive effect on the size of the document and the speed of the dvi viewer.

In addition to the vector editor itself, we will need eps2eps and epstopdf. These two utilities exist on Windows, Linux, and Mac OS. On Windows, they are included in MiKTeX. In Linux and Mac OS, as far as I know, they also come with TeX.

The whole process is as follows. Create an image in the editor and save in eps. We run it through eps2eps and already this optimized file - via epstopdf. Optimized eps and pdf file LaTeX'u (actually pdfTeX'u). Recall that when compiling \includegraphics{your_image} in dvi, your_image.eps is automatically used, in pdf - your_image.pdf .

')
Eps2eps format:
eps2eps -dNOCACHE input.eps output.eps

The -dNOCACHE converts fonts to curves. Without it, the fonts will be bitmaps.



Notes : The name of the output file must be different from the input, otherwise we get an empty eps file. Check the result, especially the quality of fonts, never hurts. It is useful to keep the original eps, the text after processing cannot be edited.


Epstopdf format:
epstopdf input.eps
We get input.pdf.


In order not to do everything manually each time, I wrote a small script for Windows:
@echo off

for /f "delims=." %%a in ('dir /b *.eps') do eps2eps -dNOCACHE %%a.eps %%a.prep_tmp
del /Q *.eps
ren *.prep_tmp *.eps

for %%a in (*.eps) do epstopdf %%a


All eps files in the current directory are processed by eps2eps, and their pdf versions are created. Be careful, the original eps is overwritten! Make copies!

Source: https://habr.com/ru/post/51878/


All Articles