forked from UniMath/SymmetryBook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tikz-external-hash.sty
54 lines (49 loc) · 1.86 KB
/
tikz-external-hash.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
% Copyright (c) 2019 Takahiro Ueda
%
% This file may be distributed and/or modified under the conditions of
% the LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version. The latest version of
% this license is in:
%
% http://www.latex-project.org/lppl.txt
%
\ProvidesPackage{tikz-external-hash}[2019/10/01 v0.1.1]
% This style file replaces the \tikz command and the tikzpicture environment
% in such a way that externalization uses hash values of picture contents as
% the cache file names.
%
% Usage:
% \usepackage{tikz}
% \usetikzlibrary{external}
% \usepackage{tikz-external-hash}% before \tikzexternalize
% \tikzexternalize
%
\usepackage{tikz}
\usetikzlibrary{external}
\usepackage{etoolbox}
\usepackage{environ}
% Patch \tikzexternal@tikzpicture@replacement in tikzexternalshared.code.tex.
\NewEnviron{tikz@external@hash@tikzpicture}[1][]{%
% Here the cache file name is derived from
% (1) the contents in the picture,
% (2) the options,
% (3) \beamer@pgfextension if defined.
\edef\tikz@external@hash@tempa{#1}%
\@ifundefined{beamer@pgfextension}{}{%
\edef\tikz@external@hash@tempa{%
\tikz@external@hash@tempa;\beamer@pgfextension}%
}%
\edef\tikz@external@hash@tempa{\expandonce\BODY;\tikz@external@hash@tempa}%
\expandafter\tikzexternal@computemdfivesum\expandafter{%
\tikz@external@hash@tempa}%
\xdef\tikzexternal@nextfile{\pgfretval}%
% Now, put the picture.
\let\tikzpicture=\tikzexternal@tikzpicture@replacement@orig
\begin{tikzpicture}[#1]%
\BODY
\end{tikzpicture}%
\let\endtikzpicture=\relax
}
\let\tikzexternal@tikzpicture@replacement@orig=\tikzexternal@tikzpicture@replacement
\let\tikzexternal@tikzpicture@replacement=\tikz@external@hash@tikzpicture
% latest-raw-url: https://gist.githubusercontent.com/tueda/c9a9c073c5f656e7ce870faf2e836be8/raw/tikz-external-hash.sty