# Why does microtype cause auto-pst-pdf to run slowly?

I have a build process using pdflatex that had been working fine (and reasonably fast) until I added auto-pst-pdf in order to process some EPS figures. Doing this causes rendering to slow down and generates error messages:

-------------------------------------------------
auto-pst-pdf: Auxiliary LaTeX compilation
-------------------------------------------------
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
entering extended mode

kpathsea: Running mktextfm cmr10+20
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input cmr10+20
This is METAFONT, Version 2.718281 (TeX Live 2011)

kpathsea: Running mktexmf cmr10+20

! I can't find file cmr10+20'.
<*> ...ljfour; mag:=1; nonstopmode; input cmr10+20

Please type another input file name
! Emergency stop.
<*> ...ljfour; mag:=1; nonstopmode; input cmr10+20

Transcript written on mfput.log.
grep: cmr10+20.log: No such file or directory
mktextfm: mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input cmr10+20' failed to make cmr10+20.tfm.
kpathsea: Appending font creation commands to missfont.log.

kpathsea: Running mktextfm cmr10-20
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input cmr10-20
This is METAFONT, Version 2.718281 (TeX Live 2011)

kpathsea: Running mktexmf cmr10-20

! I can't find file cmr10-20'.
<*> ...ljfour; mag:=1; nonstopmode; input cmr10-20

Please type another input file name
! Emergency stop.
<*> ...ljfour; mag:=1; nonstopmode; input cmr10-20

Transcript written on mfput.log.
grep: cmr10-20.log: No such file or directory
mktextfm: mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input cmr10-20' failed to make cmr10-20.tfm.
-------------------------------------------------
auto-pst-pdf: End auxiliary LaTeX compilation
-------------------------------------------------


Even for a minimal file using the article class (see MWE), I see a few such messages. For a file of any complexity, and using more complex document classes, I see many dozens, resulting in rendering times that are unacceptable, and, in some instances, time-outs and pdflatex crashes.

Commenting out the line

\RequirePackage[protrusion=true,expansion,tracking=true,kerning=true,spacing=true]{microtype}


in my document class restores performance and eliminates crashes.

It appears that by turning off expansion I can reduce these symptoms, but I don't know why. What do these errors mean? Do they mean that I'm not "really" getting font expansion anyway (perhaps because of some font limitations)? Is there an incompatibility between microtype and auto-pst-pdf? Is there something I can do to restore performance while still using all the features of microtype?

\documentclass{article}

\usepackage{auto-pst-pdf}

\RequirePackage[protrusion=true,expansion,tracking=true,kerning=true,spacing=true]{microtype}

\begin{document}

\end{document}

-
Related Question: Disable microtype for a portion of a document. –  Peter Grill Jun 9 '12 at 4:28
Wow!! Surprising that it takes that much time for this complicated document. But, as per the warnings in the log file, if you add \microtypecontext{spacing=nonfrench}, it appears to run slightly (not much) faster. –  Peter Grill Jun 9 '12 at 4:31
@PeterGrill: I've expanded the question a bit. –  raxacoricofallapatorius Jun 9 '12 at 5:21
This is also relevant. –  raxacoricofallapatorius Jun 10 '12 at 14:11

use it this way:

\documentclass{article}
\usepackage{auto-pst-pdf}
\ifpdf
\usepackage[tracking,kerning,spacing]{microtype}
\fi
\begin{document}
foo
\end{document}

-
Wow, is it really that simple? Just to be sure I understand what's happening here: I get microtype in my document as before, but it just gets skipped on the pass that processes the EPS files, right? (I use expansion too, but even adding that back in this seems to work.) –  raxacoricofallapatorius Jun 9 '12 at 14:31
right ... I suppose that you convert images where expansion isn't really needed –  Herbert Jun 9 '12 at 14:36
Yes, I can certainly do without it there. –  raxacoricofallapatorius Jun 9 '12 at 14:45
With auto-pst-pdf one step of the compilation generates a dvi. So you must be careful to use either only options which works in both modes (dvi and pdf) or to use ifpdf to use different option depending on the mode.
One example of a mode dependant option is expansion: In dvi output expansion is normally not possible see the documentation of microtype.
The best is to remove the protrusion and expansion option. microtype is clever enough to enable the options only in pdf-mode when they are sensible.
So even if I disable expansion and protrusion, I'll be getting them (on the pdflatex pass)? –  raxacoricofallapatorius Jun 9 '12 at 14:32