0

When running pdflatex more than once successively, is it possible to:

• Compile your preamble packages
• Snapshot this moment in compilation
• Continue running through the rest of the pdflatex compilation
• Start at the next compilation of pdflatex BUT from the moment of the snapshot.

It seems logical efficient since you're using the exact same packages in each run after the first.

kando
  • 1,338
  • 1
    in some cases, yes, see mylatex.ltx or mylatexformat available in texlive, miktex from ctan. In most cases reading the preamble isn't a large proportion of the processing time so saving it in a format doesn't save so much time, but it can be useful sometimes – David Carlisle Sep 19 '20 at 21:38
  • Does this work with pdflatex as a subset of the listed latex command and if so, does this work as an option within arara calling for pdflatex? – kando Sep 19 '20 at 22:27
  • 1
    yes you can use pdflatex as the format to base the custom format on (that is the usual way) I assume you could set up an arara rule to call the new format once made – David Carlisle Sep 19 '20 at 22:32
  • How .. how long has this been true? ALL THE WASTED YEARS!! :clenches fists towards the skies: – kando Sep 19 '20 at 22:39
  • 1
    I wrote mylatex.ltx in 1994 :-) – David Carlisle Sep 19 '20 at 22:42
  • This is probably a stupid question, but is there any means to check whether the preamble has changed, and if not, to reuse the compile code on future first runs as well? – kando Sep 19 '20 at 22:50
  • Example: If t.lastCompile >= [t.lastModified.preambleFile1 t.lastModified.preambleFile2 t.lastModified.preambleFile3 ...] --> then --> Reuse compile code – kando Sep 19 '20 at 22:51
  • 1
    if you put the preamble code in a separate file myfoo.sty included as \usepfackage{myfoo} then you could use any external tool eg make or a simple shell file date check and re-make the custom format if the source is newer. Never actually done that but that's just usual coding stuff. In practice I'd never needed to do this for a document preamble that wasn't very stable. – David Carlisle Sep 19 '20 at 22:56
  • @DavidCarlisle : Original: 35 [s]. Improved, when generating .fmt also: 28 [s]. Improved, when reusing .fmt: 24 [s]. That's 31% faster! – kando Sep 20 '20 at 04:47
  • 1
    glad you got it working but can you put an answer in an answer post not as an edited question (makes a mess of the site Q&A format otherwise) – David Carlisle Sep 20 '20 at 08:59
  • I can do that — but it was your answer. Is that okay by you? Will do ~ – kando Sep 20 '20 at 16:18
  • 1
    i can avoid to lose a few rep:-) and you may as well post something that you can confirm works, I haven't actually used this for years:-0 – David Carlisle Sep 20 '20 at 18:16

1 Answers1

1

Create precompiled code .fmt file:

According to @DavidCarlisle here,
this is possible using:

$ pdflatex --ini  \&pdflatex  mylatex.ltx <.texFilename>

In arara this is:

% arara: pdflatex: {options: ['-ini','&pdflatex','mylatex.ltx']}
% or
% arara: pdflatex: {options: ['-ini','&pdflatex','mylatexformat.ltx']}

Use precompiled code .fmt file:

You can then reap the rewards using:

$ pdflatex -fmt=mylatex <.texFilename>

In arara this is:

% arara: pdflatex: {options: ['-fmt=mylatexformat'] }
% or
% arara: pdflatex: {options: ['-fmt=mylatex'] }
kando
  • 1,338