blob: 1ac36aeb13fdf38a3e6a413bf27285ee23dbd7a8 (
plain)
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
55
56
57
58
59
60
61
62
|
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cachepic}[2009/05/31]
\RequirePackage{graphicx,verbatim}
\gdef\cachepic@picext{.eps}
\global\let\cachepic@multipicfile=\@undefined
\global\let\cachepic@includepic=\relax%
\ifx\pdfoutput\@undefined \else
\ifx\pdfoutput\relax \else
\ifnum\pdfoutput>\z@
\gdef\cachepic@picext{.pdf}
\IfFileExists{\jobname-cachepic.pdf}{\gdef\cachepic@multipicfile{\jobname-cachepic.pdf}}{}
\fi
\fi
\fi
\providecommand\CachePicDefMacro[4]{%
% #1 macro name (must be a valid file path without extension)
% #2 cached pic page No.
% #3 include graphics optional arguments
% #4 raisebox argument (negative depth)
\expandafter\def\csname cachepic@name@#1\endcsname{
\ifx\cachepic@includepic\@undefined% #1 does not exist, check for \cachepic@multipicfile
\ifx\cachepic@multipicfile\@undefined\else% \cachepic@multipicfile exists
\def\cachepic@includepic{\raisebox{#4}{\includegraphics[page=#2,#3]{\cachepic@multipicfile}}}
\fi
\else% #1 exists (preffered)
\def\cachepic@includepic{\raisebox{#4}{\includegraphics[#3]{#1}}}
\fi
}}
\providecommand\cachepic@tryincludepic[2]{%
% #1 picture name to include
% #2 code to execute if picture file does not exist
\xdef\cachepic@name{#1}%
\let\cachepic@includepic=\@undefined%
\IfFileExists{\cachepic@name\cachepic@picext}{%
\def\cachepic@includepic{\includegraphics{\cachepic@name}}% default include
}{}%
\csname cachepic@name@#1\endcsname% define advanced include if available
\ifx\cachepic@includepic\@undefined#2\else\cachepic@includepic\fi%
}
\newcommand\cachepic[2]{\cachepic@tryincludepic{#1}{#2}}
\newcommand\cacheinput[1]{\cachepic{#1}{\input{#1}}}
\newenvironment{cachepicture}[1]{%
\cachepic@tryincludepic{#1}{%
\let\comment=\relax%
\let\endcomment=\relax%
}%
\comment%
}{%
\endcomment%
}
\AtBeginDocument{\InputIfFileExists{\jobname.cachepic}{}{}}
\endinput
|