-
Notifications
You must be signed in to change notification settings - Fork 4
Tcolorbox
How to prevent memoization of a tcolorbox
while allowing memoization inside the box contents, e.g. automatically memoizing tikzpicture
s as if they were not inside a tcolorbox
?
Tcolorbox provides a mechanism which does this for TikZ external library, see section 4.24 of tcolorbox manual. The mechanism is activated by executing key shield externalize
:
\tcbset{shield externalize}
The following code hacks this key to provide the same service to Memoize: because tcolorbox executes \tcb@shield@@externalize
after processing the box contents but before typeseting the box, \memoizefalse
(which disables memoization) is in effect only during the latter process.
\makeatletter
\csappto{tcb@shield@@externalize}{\ifdefined\memoizefalse\memoizefalse\fi}
\makeatother
Due to \ifdefined\memoizefalse
, this code is safe to use even when Memoize is not loaded.
To disable memoization of all tcolorbox
environments (while allowing it for any tikzpicture
s inside them, for example),
\makeatletter
\csappto{tcb@shield@@externalize}{\ifdefined\memoizefalse\memoizefalse\fi}
\tcbset{shield externalize}
\makeatother