summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/cachepic
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-09-29 00:17:10 +0000
committerKarl Berry <karl@freefriends.org>2009-09-29 00:17:10 +0000
commite925ccbee27f08ddfc32e7c27bf5f3883991747a (patch)
tree1213353fed025e209a50008132778bf0b40e3290 /Master/texmf-dist/tex/latex/cachepic
parent65e993b3adaf9d89a85926bb68e1b62df91769fb (diff)
new script cachepic 1.0 (26sep09)
git-svn-id: svn://tug.org/texlive/trunk@15543 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/cachepic')
-rw-r--r--Master/texmf-dist/tex/latex/cachepic/cachepic.sty62
-rw-r--r--Master/texmf-dist/tex/latex/cachepic/prcachepic.def20
2 files changed, 82 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/cachepic/cachepic.sty b/Master/texmf-dist/tex/latex/cachepic/cachepic.sty
new file mode 100644
index 00000000000..1ac36aeb13f
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/cachepic/cachepic.sty
@@ -0,0 +1,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
diff --git a/Master/texmf-dist/tex/latex/cachepic/prcachepic.def b/Master/texmf-dist/tex/latex/cachepic/prcachepic.def
new file mode 100644
index 00000000000..533fd9dcb85
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/cachepic/prcachepic.def
@@ -0,0 +1,20 @@
+% cachepic option for Preview package
+% implements log output of cachpic specific info
+\ifPreview\else\expandafter\endinput\fi
+%\pr@loadcfg{prcachepic}
+\g@addto@macro\pr@ship@end{
+ \ifx\cachepic@name\@undefined
+ \else
+ \typeout{Preview: CachePic
+ \number\pr@snippet\space
+ \number\wd\pr@box\space
+ \number\ht\pr@box\space
+ \number\dp\pr@box\space
+ \cachepic@name}
+ \global\let\cachepic@name\@undefined
+ \fi
+ }
+\PreviewMacro[!!]{\cachepic}
+%\PreviewMacro[!]{\cacheinput}% defined through \cachepic
+\PreviewEnvironment[!]{cachepicture}
+\endinput