I have been trying to get super-fast compiles with LuaLaTeX by using a pre-built preamble for my documents. However, every time I try to compile, I get this error:
No file main.aux.
[\directlua]:1: attempt to index global 'microtype' (a nil value)
stack traceback:
[\directlua]:1: in main chunk.
MT@ifstreq ...{microtype.if_str_eq([[#1]],[[#2]])}
endcsname
l.3 \begin{document}
?
This is with the following MWE:
% in pream.tex
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Arno Pro}
\usepackage{microtype}
\usepackage{blindtext}
\endofdump
% in main.tex
\title{Test Document}
\author{Me}
\begin{document}
\blindmathpaper
\end{document}
To generate the format I used
lualatex -ini -jobname="pream" "&lualatex" mylatexformat.ltx """pream.tex"""
and to compile main.tex I used
lualatex -fmt pream """main"""
Now, I have seen on the luatex-dev mailing list (linked to from Google) that the issue is that microtype is attempting to use some Lua code, but it can't because Lua code cannot go into a format – it must be run ‘live’ in the normal way.
Robert from the mailing list suggests putting \directlua{require("microtype")} into the document, but does not specify which one to put it in. Besides, wouldn't putting it into main.tex negate the whole (well, some of it) purpose of doing this – pre-loading all packages so compiles are faster?
Anyways, I digress.
Thanks for all the help you guys always offer here on TeX.sx!
\setmainfont{Arno Pro}in a format. – Henri Menke Aug 13 '18 at 00:5954 preloaded fonts. – Luna Razzaghipour Aug 13 '18 at 01:30\documentclass{article}and\usepackage{blindtext}but that is probably “not enough” for you. – Henri Menke Aug 13 '18 at 02:01luatex-devthread you mention, @JosephWright seems to suggest that there might be something like a solution: "One can arrange (using bytecode) to save Lua fragments into a format but this is not really a general solution. Thus Lua code has to be loaded\everyjob. That's fine provided it's expected, but LaTeX packages tend to be designed on the assumption that they will be loaded 'live'." But I have no idea how this would be done practically nor why it wouldn't be a general solution. – Robert Aug 13 '18 at 13:38