I have several document of the form



% some macros


What is the procedure to use mylatex or mylatexformat?

1 Answer 1


It helps to have a real example rather than fake code as in the question:




% some macros


Then the comments in mylatex.ltx should be clear enough except that initex is accessed as pdflatex --ini these days usually

This loads all the packages and makes a format

$ pdflatex --ini  \&pdflatex  mylatex.ltx myfile

This typesets the document, without needing to load the packages.

pdflatex \&mylatex myfile

The log shows:

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=mylatex 2015.9.23)  23 SEP 2015 12:56
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**&mylatex myfile
LaTeX2e <2015/10/01>
Babel <3.9m> and hyphenation patterns for 79 languages loaded.
CUSTOMISED FORMAT. Preloaded files:
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size10.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
    tikz.sty    2015/08/07 v3.0.1a (rcs-revision 1.151)
     pgf.sty    2015/08/07 v3.0.1a (rcs-revision 1.15)
  pgfrcs.sty    2015/08/07 v3.0.1a (rcs-revision 1.31)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
 pgfcore.sty    2010/04/11 v3.0.1a (rcs-revision 1.7)
graphicx.sty    2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
graphics.sty    2014/10/28 v1.0p Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
  pgfsys.sty    2014/07/09 v3.0.1a (rcs-revision 1.48)
pgfsyssoftpath.code.tex    2013/09/09  (rcs-revision 1.9)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
pgfcomp-version-0-65.sty    2007/07/03 v3.0.1a (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v3.0.1a (rcs-revision 1.1)
  pgffor.sty    2013/12/13 v3.0.1a (rcs-revision 1.25)
 siunitx.sty    2015/09/14 v2.6l A comprehensive (SI) units package
   expl3.sty    2015/09/11 v6002 L3 programming layer (loader) 
expl3-code.tex    2015/09/11 v6002 L3 programming layer 
l3unicode-data.def    2015/07/20 v5676 L3 Unicode data
l3pdfmode.def    2015/09/10 v5983 L3 Experimental driver: PDF mode
  xparse.sty    2015/09/11 v6001 L3 Experimental document command parser
 amstext.sty    2000/06/29 v2.01
  amsgen.sty    1999/11/30 v2.0
   array.sty    2014/10/28 v2.4c Tabular extension package (FMi)
l3keys2e.sty    2015/09/11 v6001 LaTeX2e option processing using LaTeX3 keys
translator.sty    2010/06/12 ver 1.10
pstricks.sty    2013/12/12 v0.60 LaTeX wrapper for `PSTricks' (RN,HV)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
pstricks.tex    2015/09/11 v2.63 `PSTricks' (tvz,hv)
pst-xkey.tex    2005/11/25 v1.6 PSTricks specialization of xkeyval (HA)
 xkeyval.sty    2014/12/03 v2.7a package option processing (HA)
 xkeyval.tex    2014/12/03 v2.7a key=value parser (HA)
  pst-fp.tex    2015/09/11 v2.63 `PST-fp' (hv)
  • 1
    Note I picked three large packages here but it doesn't really save enough time to be worth the bother I wrote mylatex.ltx back in 1988 or so when on a pc it could take quarter of an hour just to load the preamble, so not doing that was a big win. Sep 23, 2015 at 12:08
  • 1
    just use the saved format pdflatex \&mylatex secondfile and it will use the saved preamble not the one in the document (so make sure they are the same:-) You need to be doing this thousands of times to make it worth doing at all, If it saves a fraction of a second each time, you need to do it a lot before you save the time asking about it (I have never used it, but it was useful for some friends on slower machines last century) Sep 23, 2015 at 12:59
  • 1
    The command \pdfmapfile gave me trouble when running it through mylatexformat. Figured it was worth mentioning.
    – 1010011010
    Sep 23, 2015 at 13:26
  • 1
    @Colas you can put it anywhere and refer to the full path after & when you use it, or put it anywhere in your TEXFORMATS path and and just use &mylatex if you need to save different ones, you can rename it. Sep 23, 2015 at 14:27
  • 1
    @Colas you may need & not \& or you may need quotes or whatever. the actual command passed to tex has to have & before the format name, the backslash is to hide the & from my commandline (bash shell). Alternatively you can just use pdftex and specify the format as a magic %&mylatex comment as the first line of each document file. Sep 23, 2015 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .