4

I am trying to precompile with xelatex so subsequent compilations could be quick. Here is the MWE. This is the file that I will compile to produce the desired output.

%&myone
%xelatex -ini -jobname="one" "&xelatex" mylatexformat.ltx myone.tex
\begin{document}
Hello World!
\end{document}

This is myone.tex:

%xelatex -ini -jobname="myone" "&xelatex" mylatexformat.ltx myone.tex
\documentclass{article}
\begin{document}
\end{document}

When I issue:

xelatex -ini -jobname="myone" "&xelatex" mylatexformat.ltx myone.tex

It produces an error:

! Can't \dump a format with native fonts or font-mappings.

How do I proceed with precompiling?

4
  • 1
    as the error message says, you can not dump system font loading into the format (luatex has similar restrictions). Commented Oct 13, 2017 at 7:44
  • @DavidCarlisle I am not an expert. But does this not defeat the very idea of precompiling? Also, is there a workaround?
    – deshmukh
    Commented Oct 13, 2017 at 11:54
  • 1
    the format of format files was determined in around 1980 several decades before opentype fonts were invented so defeat or not that is just the way it is. you can of course arrange to load as much tex macros (eg big packages like tikz) but in xetex and luatex you need to leave the font loading until runtime. Commented Oct 13, 2017 at 11:58
  • @DavidCarlisle OK. I have now dropped all references to fonts, etc. and still get the same error while pre-compiling. Is it that it is just not possible to pre-compile using xelatex? Please see the update question.
    – deshmukh
    Commented Oct 14, 2017 at 6:09

1 Answer 1

5

xelatex can not dump a format after an OpenType font has been loaded. By default xelatex uses TU (Unicode) encoding as the initial default, so when the class does \normalfont OpenType latin modern is used and dump is disabled.

This sets the default back to classic 7-bit TeX encoding, then the tfm latin modern will be used during initex run, and TU is re-enabled in \everyjob

\def\encodingdefault{OT1}\normalfont
\everyjob\expandafter{\the\everyjob\def\encodingdefault{TU}\normalfont}
\documentclass{article}
\begin{document}
\end{document}

with a log of

.....
Beginning to dump on file myone.fmt
 (preloaded format=myone 2017.10.14)
...
2
  • Coming to this a couple years after it was posted, because I had this problem too. Commented Feb 24, 2019 at 22:27
  • Coming to this a couple years after it was posted, because I had this problem too. My goal is to reduce the long "compile" time for a paper. The "compile" time appears to mostly be spent loading a bazillion (at rough count) packages. When I rebuild the pdf of a single documentation lots of times when I'm tweaking the text, it gets boring to watch xelatex do exactly the same thing unchanged that it did the last 20 runs; I would like it to load the result of that, then proceed to load my tweaked text. Is there an alternative way to do store a pre-processed dump of my preamble? Commented Feb 24, 2019 at 22:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .