BlogPublisher
can run in two modes
tex_engine='pdflatex'
using pdflatex and a pre-compiled format. which is super-fast but uses default fonts, ortex_engine='lualatex'
using lualatex and no format, which is slower but allows custom fonts.pdflatex
engineTo create a template called tikz.fmt (about 14MB) run
pdflatex -ini -jobname=tikz "&pdflatex" mylatexformat.ltx dm.tex
Notes.
-ini
or --ini
. Both seem to work.\
in the filename, use /
.-
enclose it in quotes. (Powershell, at least.)&pdflatex
loads the base format for pdflatex.mylatexformat.ltx
(located C:/Users/steve/AppData/Local/Programs/MiKTeX/tex/latex/mylatexformat
) is from the mylatexformat
package file.dm.tex
should include all the packages you want to load in the format, between \documentclass
and \begin{document}
.Here is an example dm.tex
for tikz diagrams. Note the font items are commented out—they only work with extended TeX varieties. The actual document is irrelevant but the libraries and other definitions are important. In particular the format must be rebuilt if other packages are added to the preamble.
\documentclass[border=5mm]{standalone}
% build format: pdflatex -ini -jobname=tikz "&pdflatex" mylatexformat.ltx "tikz-stand-alone.tex"
% needs lualatex - uncomment for Wiley fonts
%\usepackage{fontspec}
%\setmainfont{Stix Two Text}
%\usepackage{unicode-math}
%\setmathfont{Stix Two Math}
% add packages you want included in the format here
\usepackage{url}
\usepackage{tikz}
\usepackage{color}
\usetikzlibrary{arrows,calc,positioning,shadows.blur,decorations.pathreplacing}
\usetikzlibrary{automata}
\usetikzlibrary{fit}
\usetikzlibrary{intersections}
\usetikzlibrary{decorations.markings,decorations.text,decorations.pathmorphing,decorations.shapes}
\usetikzlibrary{decorations.fractals,decorations.footprints}
\usetikzlibrary{graphs}
\usetikzlibrary{matrix}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{mindmap, shadows}
\usetikzlibrary{backgrounds}
\usetikzlibrary{cd}
% really common macros
\newcommand{\grtspacer}{\vphantom{lp}}
\def\dfrac{\displaystyle\frac}
\def\displaystyle\int{\displaystyle\int}
\begin{document}
IRRELEVANT DOCUMENT HERE
\end{document}
The same command runs with lualatex
in place of pdflatex
but the format doesn’t work to create pdf files.
Having built the format, use it to build a TeX file by running
pdflatex --fmt=tikz dm.tex
which is super-fast. It does not handle fonts. dm.tex
does not need any of the header information.
Notes. 1. Anything between documentclass
and \begin{document}
is ignored. 2. New macros can be defined after \begin{document}
.
For example, the following suffices.
\documentclass[border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\path[draw, latex-latex] (0.01, 0.25) -- (1.99, 0.25) node[fill=white, text=black, pos=0.5, align=center] {Jan 1};
\path[draw, latex-latex] (2.01, 0.25) -- (3.99, 0.25) node[fill=white, text=black, pos=0.5, align=center] {Jan 2};
\path[draw, very thin] (0, 0.3) -- (0, -0.1);
\path[draw, very thin] (2, 0.3) -- (2, -0.1);
\path[draw, very thin] (4, 0.3) -- (4, -0.1);
\path[draw, very thin] (1, 0.0) -- (1, -0.1)
$t=0.5$\\ Noon};
node[scale=0.5, below, align=center] {
\path[draw] (-1,0)
$t=0$}
-- (0, 0) node[circle, fill=blue, scale=0.35] {} node[below, align=center] {$t=1$}
-- (2, 0) node[circle, fill=blue, scale=0.35] {} node[below, align=center, pos=1] {$t=2$}
-- (4, 0) node[circle, fill=blue, scale=0.35] {} node[below, align=center, pos=1] {
-- (5, 0);
\node at (4,4) {HELLO};
\end{tikzpicture}
\end{document}
In the folder /S/TELOS/PIR_Proofs/src
pbit_template.tex
used to create the template with pmaketemplate.bat
pdflatex --ini --aux-directory=temp --output-directory=temp --jobname=wiley "&pdflatex" mylatexformat.ltx pbit_template.tex
pbit.tex
a runner, insert your new code in the documentpmakebit.bat
quick-makes pbit.tex
using pdflatex --fmt=temp/wiley.fmt --aux-directory=temp --output-directory=latest pbit.tex
xelatex
you need to include all the header info; you can do this by pasting into pbit_template.tex
, for example.Based on an old Reddit post I gave up trying to get lualatex
to make a format file.
If anyone stumbles into this one day in search of help, I concluded that it is either impossible, or very difficult to get mylatexformat to work nicely with lualatex (or maybe just my vast collection of packages). I did see success by commenting out the lualatex specific packages (fonts etc.), moving some packages like tikz and tikz externalization to the dynamic preamble section and running mylatexformat with pdflatex. This decreased the compile times DRAMATICALY for my use case anyway.