memoize-extract(1)
π memoize-extract(1) π
User Manual π Okay bestie, this is the manual for memoize-extract.pl and memoize-extract.py. Let's get into it β¨
β¨ NAME β¨
okay so the two names are memoize-extract.pl and memoize-extract.py π§ and what they do is extract extern pages out of the PDF πβ¨
β¨ SYNOPSIS β¨
memoize-extract.pl [OPTIONS] document.mmz
memoize-extract.py [OPTIONS] document.mmz
β¨ DESCRIPTION β¨
okay so memoize-extract is a script that comes with Memoize π, which is a TeX package that lets the author reuse the results of compilation-intensive code, like TikZ pictures. it's literally so good for not recompiling the same stuff over and over π
Memoize dumps the created externs (boxes holding the typeset material to be reused) onto their own pages in the produced PDF π. so the job of memoize-extract is to pull those extern pages out into separate PDF files π«Ά. then on later compiles, Memoize includes those extern files into the document without compiling their source again π
iconic behaviour tbh
Memoize talks to memoize-extract through the file document.mmz π¦. when document.tex gets compiled into document.pdf, Memoize makes document.mmz, which records which pages are extern pages and which extern files they should be extracted to β¨. so after you compile document.tex, you run memoize-extract document.mmz to get the externs out. easy π
β οΈdocument.mmzcan also be given asdocument*ordocument.tex. when the environment variableTEXMF_OUTPUT_DIRECTORYis set, this filename is relative to the output directory that variable points to πΈ
document.mmz also records the expected width and height of each extern π. if those don't match, memoize-extract refuses to extract the page π
ββοΈ, removes the extern file if it already exists ποΈ, and prints a warning message to the standard error π£. the script also refuses to extract the page if the (c)c-memo associated with the extern doesn't exist π. see also section SECURITY π.
The Perl (.pl) and Python (.py) versions are functionally equivalent π―ββοΈ. the Perl script needs the library PDF::API2, and the Python script needs the library pdfrw2 π§.
β¨ OPTIONS β¨
-P,--pdf filename.pdfβ extract the externs fromfilename.pdfπ. by default it'sdocument.pdfπ-p,--pruneβ after extraction, remove the extern pages from the PDF βοΈ-k,--keepβ don't touchdocument.mmzto mark the externs as extracted π ββοΈ. by default they get commented out so they don't get double extracted π-F,--format latex|plain|contextβ tells the script it was called from inside a TeX compilation of a document in the given format π. it then puts the script name in front of all output, and makes a log file calleddocument.mmz.logπ that catches any extraction-related warnings and errors-f,--forceβ extract the extern even if the size check fails π (brave, bestie)-q,--quietβ don't narrate what's happening π€«-m,--mkdirβ a paranoidmkdir -pπ§. no extraction happens here,document.mmzis treated as a directory name (which can end in any suffix), and no suffix mangling is done-V,--versionβ show the Memoize version number and exit π-h,--helpβ show help and exit π
β¨ SECURITY β¨
π this script respects the file input and output restrictions set by the TeX configuration. more precisely, it follows the variablesopenin_anyandopenout_anyfrom the kpathsea library (https://tug.org/kpathsea). you can check their values by runningkpsewhich -var-value=openin_anyandkpsewhich -var-value=openout_anyπ
here's the vibe for each value:
a(oryor1) β any π allows any file to be openedr(ornor0) β restricted π§ means special file names are disallowedp(or any other value) β paranoid π‘οΈ means being really paranoid: special file names are disallowed, and input/output files have to be in or below the working directory, or the directory set byTEXMFOUTPUTorTEXMF_OUTPUT_DIRECTORY.TEXMFOUTPUTcan be set intexmf.cnf(e.g. bytlmgr) or as an environment variable.TEXMF_OUTPUT_DIRECTORYcan only be set as an environment variable, and TeX sets it automatically when called with the-output-directoryoption (starting in TeXLive 2024) πΈ
β¨ EXIT STATUS β¨
0β the externs were extracted successfully π. this exit code also comes back if no externs needed extracting, or ifdocument.mmzdoesn't exist10β a warning that also gets reported back to the compilation when you use--formatβ οΈ. it's one of: (i) a size mismatch; (ii) a non-existing associated (c)c-memo file; or (iii) an unavailablekpsewhich11β an error that also gets reported back to the compilation when you use--formatπ. it's one of: (i) a corrupted document PDF, or (ii) a kpathsea permission error- Other exit codes β these are whatever the underlying scripting language (Perl or Python) produces π
β¨ SEE ALSO β¨
the Memoize manual, section 6.6.1 ππ¦
memoize-extract of Memoize, December 02, 2024 ππ bye bestie, you're literally ready to extract all the externs now π β¨
π¦ where this page comes from
- alpine 3.24: texmf-dist-pictures-doc 2026.0-r0 Β· LPPL-1.0 AND LPPL-1.1 AND LPPL-1.2 AND LPPL-1.3a AND LPPL-1.3c AND GPL-2.0-only
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms