I read about precompiling the preamble in https://tex.stackexchange.com/a/15606/4918 and it worked fine with pdflatex
but how can I do this for xelatex
?
I tried
xelatex -ini -shell-escape -job-name="header" "&xelatex header.tex\dump"
but it ends with an error:
! Can't \dump a format with native fonts or font-mappings.
<*> &xelatex header.tex\dump
Best Answer
I had the same problem myself once. The first solution is of course, to take
\usepackage{fontspec}
out of the preamble document and put it right before\begin{document}
in the main document.But as you, just like me, want to load
fontspec
in a custom document class, you could usethere.
\AtEndPreamble
works similar to the standardLaTeX
command\AtBeginDocument
, only that the code inside can itself use\AtBeginDocument
likefontspec
does.Unfortunately this means that you can't cut the compile time of
fontspec
here. The same problem exists withunicode-math
andpolyglossia
for example. (While I had no problems withbabel
.)And here is an explanation as to why this is not possible, that I found on the
XeTeX
mailing list: