8

I looked at many posts about the use of latexmk, but wasn't able to find what to write in order to satisfy my requirements. Yet I'm sure it is possible, but my skills in Perl amounts to about nothing.

What I would like to do with a file, say mymainfile.tex:

  1. make a format file including the static part of the preamble, named mymainfile-xelatex.fmt if I use xelatex, and store it in the fmt/ subdirectory of the directory that contains mymainfile.tex (I can do that just with mylatexformat)

  2. regenerate the format if the (static part of the) preamble has changed (loading new packages, defining new commands or modifying existing commands).

  3. Compiling mymainfile.tex with the customised format file.

The difficulty for me is point 2), and possibly point 1) — that is, not having to write a first macro to make the format, and the launching latexmk, but preferably that everything be done from latexmk.

Moreover I prefer not to write the static part of the preamble in a separate file, but keep it in mymainfile.tex as usual, and use the \endofdump command from the mylatexformat package

I use MiKTeX 2.9 on WinEdt 7.

Bernard
  • 271,350
  • Does the answer there (by the author of latexmk) help you? There's also http://tex.stackexchange.com/questions/79493/ultrafast-pdflatex-with-precompiling. – krlmlr Nov 10 '13 at 21:23
  • Well, not exactly. It is one of the answers I had read. I must say I didn't understand all the code given there, but I understood one thing: it supposes the static part of the preamble to be written in a separate file. What I would like to be able to do is to have it in the main document as usual, only delimited by the command \endofdump (from mylatexformat package) or \begin{document} if there is no dynamic part of the preamble. I guessed one can take advantage of LaTeXmk's ability to detect changes in the preamble to let it redo the customised format. – Bernard Nov 11 '13 at 01:16
  • Hi @bernard. Are there any news here? – Johannes_B Mar 15 '15 at 16:58
  • @Johannes_B: Unfortunately no. I confess I had so many things to do that I had forgotten this problem. Thanks for reminding me; as soon as I have some time, I'll look after it. – Bernard Mar 15 '15 at 18:15
  • Just doing a bit of cleaning around, no need to hurry ;-) – Johannes_B Mar 15 '15 at 18:17
  • mylatexformat's job is to not need moving the preamble to a separate file.
  • The format name (specified with -jobname) must be mymainfile, not mymainfile-sth, to avoid certain issues with \jobname having the wrong value in the static preamble. (Maybe the format name can be renamed after the build, haven't tried.)
  • – Blaisorblade Jul 18 '17 at 18:08
  • But if you accept having a separate file and give up on mylatexformat, you can use this answer: https://tex.stackexchange.com/a/37730/1340 Otherwise, it's much harder to only build B only when some lines of A change. – Blaisorblade Jul 18 '17 at 18:09