Skip to content
Sašo Živanović edited this page Oct 19, 2024 · 10 revisions

This page lists some commands and environments, marking the issues they present to memoization, and providing solutions where possible. (On this page, "manual" refers to the Memoize manual, which can be found at http://mirrors.ctan.org/macros/generic/memoize/doc/memoize-doc.pdf.)

Each entry marks the category of the issue which the package, command or environment presents to Memoize:

  • Memoization: The code resists memoization, in one way or another. Two common causes are category code changes (addressable by key verbatim) and vertical mode (addressable by key capture=vbox). A more complicated example would be code which either produces no externs, or multiple externs; see manual section 4.4.
  • Dependencies: The code submitted to memoization contains a command which refers to "the outside world", like a cross-reference or a command whose definition might change. The memoized code should be recompiled if the cross-reference or the definition of the command changes. The canonical example is \ref.
  • Effects: The memoized code has effects other than just producing typeset material. For example, it might update some global counter, or update a cross-reference. The canonical example is \label. (This is really a subcategory of memoization issues.)
  • Auto: This pertains to commands which are memoized automatically, by submitting them to key auto; see manual section 2.3 and the cross-references therein. The issue is how to determine where the invocation of the command stops, i.e. what are its arguments?
    • Some commands conform to the LaTeX3 argument specification (even if they are not defined in a LaTeX3 way; note that LaTeX3-style commands never require any user intervention); these can be addressed by auto-key args, see manual section 2.3 and the cross-references therein.
    • Commands with weird argument structure require a dedicated collector or such, see manual section 4.5. The canonical example is \tikz.
Package Command or environment Issue Notes
LaTeX \ref dependencies Automatically loaded built-in support; see manual section 3.3.
\label effects Automatically loaded built-in support; see manual sections 4.2.1 and 4.2.3.
verbatim memoization Use verbatim and capture=vbox.
Algorithmic algorithmic memoization Use capture=vbox.
Beamer other In Beamer class, load Memoize by \RequirePackage before \documentclass{beamer}
dependencies Automatically loaded built-in support; see manual sections 5.7.4, 2.7 and 4.2.4. Use per overlay to produce a separate extern for each overlay.
Biblatex dependencies Built-in support can be loaded by executing key biblatex; see manual section 5.7.5.
Forest Automatically loaded built-in support: environment forest and command \Forest are automemoized; see manual section 5.7.3.
PGF effects Automatically loaded built-in support; see manual section 5.7.1.
Tcolorbox breakable or float boxes memoization Such tcolorboxes cannot be memoized. Automatically switching memoization off for these and only these boxes is non-trivial, an attempt is made in memoize-doc.sty, used to typeset Memoize documentation. Full support can most likely only be implemented from within tcolorbox itself.
TikZ Automatically loaded built-in support: environment tikzpicture and command \tikz are automemoized; see manual section 5.7.3.
\tikz auto Automatically loaded built-in support: a dedicated collector; see manual section 5.7.2.
remember picture memoization Pictures using this key cannot be externalized; see manual section 3.1.
TikZ: matrix \matrix memoization Use verbatim.
Clone this wiki locally