TransWikia.com

Speeding up compilation using precompiled preamble with LuaTeX

TeX - LaTeX Asked on May 27, 2021

Compiling my documents with lualatex takes quite long. I have a complex preamble, and I noticed that it takes long to process this part of the file.

Today, I came across this website, which proposes a trick I haven’t seen on this site before. By pre-compiling the preamble, it claims to speed up compilation approximately three-fold: Faster LaTeX part IV: Use a precompiled preamble (Wayback Machine snapshot).

However, I have not been able to follow this tutorial with LuaLaTeX. How can I pre-compile my preamble with it?

One Answer

I might be missing the point of the question, or fail to see why what my computer does is not what the OP is looking for. Further this is is certainly not the most elegant solution, since I'm at work so I only had Windows & TeXnicCenter+MikTEX2.9 at my disposal. But I think it does what it should.

Here's what I do:

  1. Compile lua_pream.tex with profile LuaTeX⇨PDF(pre) (see below)
  2. Compile lua_nopream.tex with profile LuaTeX_post⇨PDF(post)

The profiles:

LuaTeX⇨PDF(pre) is

luatex  -interaction=nonstopmode -ini -jobname="lua_pream" "&lualatex" mylatexformat.ltx "./lua_pream.tex"

or in TeXnicCenter:

enter image description here

LuaTeX_post⇨PDF(post) is

lualatex -fmt lua_pream "./lua_nopream.tex"

or in TeXnicCenter:

enter image description here

lua_nopream.tex contans not much really

endofdump %%stuff from lua_pream.tex is dumped before here, you only need this if you have a local preamble
% part of the preamble that has to be evaluated each run
begin{document}
The preamble used for this was compiled with vvvv set to vvvv
end{document}

lua_pream.tex contains the preamble

% static part of the preamble (stuff that does not change every now and then)
documentclass{article}
usepackage{luatexbase}
usepackage{geometry}
usepackage{amsmath,amsfonts,amsthm}
usepackage{graphicx}
usepackage{caption}
usepackage{subfig}
usepackage{booktabs}
usepackage{enumitem}
usepackage{xspace}
usepackage{cleveref}
usepackage{hyperref}
usepackage{natbib}
defvvvv{foobar}
% the endofdump part 'saves' everything above into one precompiled preamble, which gets loaded every time the LaTeX document is processed. This saves a lot of time mostly. 
% NOTE: the following line ends the dumping into the preamble format file!
endofdump
begin{document}
        This text plays no role I guess
end{document}

Answered by sheß on May 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP