Debian Codegraph @

texmf-dist/tex/latex/cachepic/cachepic.sty

raw
1 \NeedsTeXFormat{LaTeX2e}
2 \ProvidesPackage{cachepic}[2009/05/31]
3
4 \RequirePackage{graphicx,verbatim}
5
6 \gdef\cachepic@picext{.eps}
7 \global\let\cachepic@multipicfile=\@undefined
8 \global\let\cachepic@includepic=\relax%
9
10 \ifx\pdfoutput\@undefined \else
11 \ifx\pdfoutput\relax \else
12 \ifnum\pdfoutput>\z@
13 \gdef\cachepic@picext{.pdf}
14 \IfFileExists{\jobname-cachepic.pdf}{\gdef\cachepic@multipicfile{\jobname-cachepic.pdf}}{}
15 \fi
16 \fi
17 \fi
18
19 \providecommand\CachePicDefMacro[4]{%
20 % #1 macro name (must be a valid file path without extension)
21 % #2 cached pic page No.
22 % #3 include graphics optional arguments
23 % #4 raisebox argument (negative depth)
24 \expandafter\def\csname cachepic@name@#1\endcsname{
25 \ifx\cachepic@includepic\@undefined% #1 does not exist, check for \cachepic@multipicfile
26 \ifx\cachepic@multipicfile\@undefined\else% \cachepic@multipicfile exists
27 \def\cachepic@includepic{\raisebox{#4}{\includegraphics[page=#2,#3]{\cachepic@multipicfile}}}
28 \fi
29 \else% #1 exists (preffered)
30 \def\cachepic@includepic{\raisebox{#4}{\includegraphics[#3]{#1}}}
31 \fi
32 }}
33
34 \providecommand\cachepic@tryincludepic[2]{%
35 % #1 picture name to include
36 % #2 code to execute if picture file does not exist
37 \xdef\cachepic@name{#1}%
38 \let\cachepic@includepic=\@undefined%
39 \IfFileExists{\cachepic@name\cachepic@picext}{%
40 \def\cachepic@includepic{\includegraphics{\cachepic@name}}% default include
41 }{}%
42 \csname cachepic@name@#1\endcsname% define advanced include if available
43 \ifx\cachepic@includepic\@undefined#2\else\cachepic@includepic\fi%
44 }
45
46 \newcommand\cachepic[2]{\cachepic@tryincludepic{#1}{#2}}
47
48 \newcommand\cacheinput[1]{\cachepic{#1}{\input{#1}}}
49
50 \newenvironment{cachepicture}[1]{%
51 \cachepic@tryincludepic{#1}{%
52 \let\comment=\relax%
53 \let\endcomment=\relax%
54 }%
55 \comment%
56 }{%
57 \endcomment%
58 }
59
60 \AtBeginDocument{\InputIfFileExists{\jobname.cachepic}{}{}}
61
62 \endinput