summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
l---------Master/bin/alpha-linux/cachepic1
l---------Master/bin/i386-cygwin/cachepic1
l---------Master/bin/i386-linux/cachepic1
l---------Master/bin/i386-netbsd/cachepic1
l---------Master/bin/i386-solaris/cachepic1
l---------Master/bin/mips-irix/cachepic1
l---------Master/bin/powerpc-aix/cachepic1
l---------Master/bin/powerpc-linux/cachepic1
l---------Master/bin/sparc-linux/cachepic1
l---------Master/bin/sparc-solaris/cachepic1
l---------Master/bin/universal-darwin/cachepic1
-rwxr-xr-xMaster/bin/win32/cachepic.cmd11
l---------Master/bin/x86_64-linux/cachepic1
-rw-r--r--Master/texmf-dist/doc/latex/cachepic/README10
-rw-r--r--Master/texmf-dist/doc/latex/cachepic/cachepic.pdfbin0 -> 167000 bytes
-rw-r--r--Master/texmf-dist/doc/latex/cachepic/cachepic.tex148
-rw-r--r--Master/texmf-dist/scripts/cachepic/cachepic.cmd11
-rwxr-xr-xMaster/texmf-dist/scripts/cachepic/cachepic.tlu231
-rw-r--r--Master/texmf-dist/tex/latex/cachepic/cachepic.sty62
-rw-r--r--Master/texmf-dist/tex/latex/cachepic/prcachepic.def20
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rwxr-xr-xMaster/tlpkg/libexec/ctan2tds1
-rw-r--r--Master/tlpkg/tlpsrc/cachepic.tlpsrc0
-rw-r--r--Master/tlpkg/tlpsrc/collection-pictures.tlpsrc1
24 files changed, 508 insertions, 1 deletions
diff --git a/Master/bin/alpha-linux/cachepic b/Master/bin/alpha-linux/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/alpha-linux/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/i386-cygwin/cachepic b/Master/bin/i386-cygwin/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/i386-cygwin/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/i386-linux/cachepic b/Master/bin/i386-linux/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/i386-linux/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/i386-netbsd/cachepic b/Master/bin/i386-netbsd/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/i386-netbsd/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/i386-solaris/cachepic b/Master/bin/i386-solaris/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/i386-solaris/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/mips-irix/cachepic b/Master/bin/mips-irix/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/mips-irix/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/powerpc-aix/cachepic b/Master/bin/powerpc-aix/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/powerpc-aix/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/powerpc-linux/cachepic b/Master/bin/powerpc-linux/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/powerpc-linux/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/sparc-linux/cachepic b/Master/bin/sparc-linux/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/sparc-linux/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/sparc-solaris/cachepic b/Master/bin/sparc-solaris/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/sparc-solaris/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/universal-darwin/cachepic b/Master/bin/universal-darwin/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/universal-darwin/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/bin/win32/cachepic.cmd b/Master/bin/win32/cachepic.cmd
new file mode 100755
index 00000000000..6aefa99c0d5
--- /dev/null
+++ b/Master/bin/win32/cachepic.cmd
@@ -0,0 +1,11 @@
+@echo off
+setlocal enableextensions
+if not defined LUA_EXE if exist "%~dp0lua.exe" set LUA_EXE=%~dp0lua.exe
+for %%I in (lua.exe texlua.exe) do if not defined LUA_EXE set LUA_EXE=%%~$PATH:I
+if not defined LUA_EXE goto :nolua
+"%LUA_EXE%" "%~dp0cachepic.tlu" %*
+goto :eof
+
+:nolua
+echo %~nx0: could not locate lua nor texlua interpreter>&2
+exit /b 1 \ No newline at end of file
diff --git a/Master/bin/x86_64-linux/cachepic b/Master/bin/x86_64-linux/cachepic
new file mode 120000
index 00000000000..f51faf9afc3
--- /dev/null
+++ b/Master/bin/x86_64-linux/cachepic
@@ -0,0 +1 @@
+../../texmf-dist/scripts/cachepic/cachepic.tlu \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/cachepic/README b/Master/texmf-dist/doc/latex/cachepic/README
new file mode 100644
index 00000000000..2fe110cbdb1
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cachepic/README
@@ -0,0 +1,10 @@
+The purpose of cachepic package is to simplify and automate conversion
+of document fragments into external EPS or PDF file(s). The package
+consists of two parts: the LaTeX2e style implementing the document
+level interface and a command line tool (written in Lua) for generation
+of external graphics.
+
+The inclusion of already generated graphics requires only the
+cachepic.sty style file and two standard packages: graphicx (obviously)
+and verbatim (for its comment environment). Both should be present in
+every LaTeX distribution.
diff --git a/Master/texmf-dist/doc/latex/cachepic/cachepic.pdf b/Master/texmf-dist/doc/latex/cachepic/cachepic.pdf
new file mode 100644
index 00000000000..667d77fd742
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cachepic/cachepic.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/cachepic/cachepic.tex b/Master/texmf-dist/doc/latex/cachepic/cachepic.tex
new file mode 100644
index 00000000000..d1236f6da0d
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cachepic/cachepic.tex
@@ -0,0 +1,148 @@
+% Copyright 2009 T.M. Trzeciak
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% 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
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is T.M. Trzeciak.
+%
+% This work consists of the files:
+% README.TXT
+% cachepic.tex
+% cachepic.pdf (derived)
+% cachepic.sty
+% prcachepic.def
+% cachepic.tlu
+% cachepic.cmd
+
+
+%\ProvidesFile{cachepic}[2009/09/23 v1.0 cachepic package]
+\documentclass{ltxdoc}
+\usepackage{booktabs}
+\usepackage{verbatim}
+\newcommand\mainfile{main file}
+\newcommand\filename{file name}
+\newcommand\texfrag{fragment}
+\newcommand\option[1]{\textbf{#1}}
+\newcommand{\figref}[2][\figurename~]{#1\ref{#2}}
+\newcommand{\tabref}[2][\tablename~]{#1\ref{#2}}
+\newcommand{\secref}[2][Section~]{#1\ref{#2}}
+\newenvironment{displaytext}{\quote}{\endquote}
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
+
+\begin{document}
+%\GetFileInfo{cachepic}
+
+\title{The \textsf{cachepic} package}
+\author{Tomasz M. Trzeciak \\ \texttt{t34www@gmail.com}}
+\date{September 23, 2009}
+\maketitle
+
+\section{Introduction}
+
+It might be sometimes desirable to convert fragments of your document, e.g. drawings or diagrams, into external graphic files. Such a need may arise when you want to use some specialised package but your document have to compile on a system without said package.
+
+The purpose of \textsf{cachepic} package is to simplify and automate conversion of document fragments into external \textsf{eps} or \textsf{pdf} file(s). The package consists of two parts: the \LaTeXe\ style implementing the document level interface and a command line tool (written in \textsf{Lua}) for generation of external graphics.
+
+\section{Requirements}
+\label{sec:Requirements}
+
+The inclusion of already generated graphics requires only the |cachepic.sty| style file and two standard packages: \textsf{graphicx} (obviously) and \textsf{verbatim} (for its comment environment). Both should be present in every \LaTeX\ distribution.
+
+The graphics generation step requires the full \textsf{cachepic} package, the \textsf{preview} package and a \textsf{Lua} interpreter to execute the conversion script. For Windows platform there is also a batch script wrapper provided for command line use.
+
+\section{Document interface}
+\label{sec:DocInterface}
+
+The package is loaded with the usual |\usepackage{cachepic}|. Currently there are no package specific options available. There are two commands and one environment provided for marking-up document fragments intended for externalization as graphic files.
+
+\DescribeMacro{\cachepic}
+The main command of this package is |\cachepic|\marg{\filename}\marg{\texfrag}. It takes a balanced \LaTeX\ code \meta{\texfrag}, which is typeset and output to a file \meta{\filename} during the post-processing run as described in \secref{sec:CmdTool}.
+
+\DescribeMacro{\cacheinput}
+The second command, |\cacheinput|\marg{\filename}, is just a shorthand for |\cachepic|\marg{\filename}|{\input|\marg{\filename}|}|.
+
+\DescribeEnv{cachepicture}
+Finally, for longer stretches of code there is an environment analogue of the |\cachepic| command:
+
+\begin{displaytext}
+|\begin{cachepicture}|\marg{\filename}\\
+\hspace*{1em}\meta{\texfrag}\\
+|\end{cachepicture}|
+\end{displaytext}
+
+During normal document compilation each \meta{\texfrag} is typeset as usual unless there exists a file \mbox{\meta{\filename}|.eps|} (in \textsf{dvi} mode) or \mbox{\meta{\filename}|.pdf|} (in \textsf{pdf} mode). If such a file exists, it will be included (with the standard |\includegraphics| command) and it will be used in place of the corresponding \meta{\texfrag}.
+
+\section{Graphics generation}
+\label{sec:CmdTool}
+
+\begin{table}
+\centering
+\caption[]{\label{tab:options}
+Options of |cachepic| command line tool.}
+\vspace{1ex}
+\begin{tabular}{l p{0.6\linewidth}}
+\toprule
+\option{option} & description\\
+\midrule
+\option{pdf} & graphics will be output in
+ \textsc{(e)pdf} format; this is the
+ default option\\
+\option{eps} & graphics will be output in
+ \textsc{eps} format\\
+\option{all} & recreate all graphics, already
+ existing ones will be overwritten\\
+\option{multi} & keep all graphics in a sigle file
+ \meta{\mainfile}|-cachepic.pdf|
+ rather then produce separate files
+ (but graphics in separate files take
+ precedence); this option cannot be
+ used together with |-eps|\\
+\option{tight} & no 0.5\,bp margin around the
+ graphic\\
+\option{notex} & don't do any typesetting, only
+ graphic postprocessing; the typesetting has
+ to be done separately and requires the
+ \textsf{preview} package with at least
+ the |active| and |cachepic| options\\
+\option{nopic} & generate no graphics, only
+ \mbox{\meta{\mainfile}|.cachepic|} file\\
+\option{help,h,?} & display help message\\
+\bottomrule
+\end{tabular}
+\end{table}
+
+Graphics files are produced by running a command line tool called (unsurprisingly) |cachepic|. This tool automates the whole process of graphic generation. It can be called from the command line (or through appropriately configured \TeX\ editor) as follows:
+
+\begin{displaytext}
+|cachepic [options] |\meta{\mainfile}
+\end{displaytext}
+
+\noindent All available options are gathered in \tabref{tab:options}. Options start with ``|-|'' or ``|--|'' and can be passed in any order.
+
+Apart from graphic files there is also an auxiliary \mbox{\meta{\mainfile}|.cachepic|} file created. It contains additional information used for graphics inclusion such as the page number (used only in \textsc{pdf} mode with multi-graphics file), margins and the depth of the graphics box. This file is not strictly required but without it some features are not available as explained below.
+
+As mentioned in \secref{sec:Requirements}, the \textsf{preview} package is required for graphics generation but it should not be specified with options in the document preamble or this will likely lead to option clash. To use this package together with \textsf{cachepic}, pass |cachepic| option to the \textsf{preview} package and compile the document separately. Then run the |cachepic| tool with |-notex| option.
+
+Once all the graphics are generated, only the style file |cachepic.sty| is needed to compile the document. If you want to avoid using even this file, you can add the following definitions the document preamble:
+
+\begin{displaytext}
+\begin{verbatim}
+\newcommand\cachepic[2]{\includegraphics{#1}}
+\newcommand\cacheinput[1]{\includegraphics{#1}}
+\newenvironment{cachepicture}[1]{%
+\includegraphics{#1}\comment}{\endcomment}
+\end{verbatim}
+\end{displaytext}
+
+However, since the above definitions don't use the additional information in the \mbox{\meta{\mainfile}|.cachepic|} file, this comes with some limitations. Firstly, information about the graphic's depth, i.e. how much it is lowered below the text baseline, is not preserved. Secondly, graphics stored in a single \textsc{pdf} file cannot be used, because the page number with the graphic is not known. Finally, the default small margin around the graphics is not corrected for, but you can generate the graphics without the margin (see the |-tight| option in \tabref{tab:options}) or use |\includegraphics[trim=0.5bp 0.5bp 0.5bp 0.5bp]{#1}| in the above definitions to correct for that.
+
+\end{document}
+
diff --git a/Master/texmf-dist/scripts/cachepic/cachepic.cmd b/Master/texmf-dist/scripts/cachepic/cachepic.cmd
new file mode 100644
index 00000000000..6aefa99c0d5
--- /dev/null
+++ b/Master/texmf-dist/scripts/cachepic/cachepic.cmd
@@ -0,0 +1,11 @@
+@echo off
+setlocal enableextensions
+if not defined LUA_EXE if exist "%~dp0lua.exe" set LUA_EXE=%~dp0lua.exe
+for %%I in (lua.exe texlua.exe) do if not defined LUA_EXE set LUA_EXE=%%~$PATH:I
+if not defined LUA_EXE goto :nolua
+"%LUA_EXE%" "%~dp0cachepic.tlu" %*
+goto :eof
+
+:nolua
+echo %~nx0: could not locate lua nor texlua interpreter>&2
+exit /b 1 \ No newline at end of file
diff --git a/Master/texmf-dist/scripts/cachepic/cachepic.tlu b/Master/texmf-dist/scripts/cachepic/cachepic.tlu
new file mode 100755
index 00000000000..363d6bb6320
--- /dev/null
+++ b/Master/texmf-dist/scripts/cachepic/cachepic.tlu
@@ -0,0 +1,231 @@
+#!/usr/bin/env texlua
+
+local options = {
+ pdfoutput=true,
+ redoall=false,
+ multipicfile=false,
+ noborder=false,
+ dotypesetting=true,
+ nopostprocess=false,
+}
+
+local usagetext = 'Usage: cachepic [options] latexfile'
+local tryhelp = "Try `cachepic --help' for more information"
+local helptext = [[
+Options start with '-' or '--' and can be any of:
+ -pdf output in (e)pdf format (default)
+ -eps output in eps format
+ -all regenerate all graphics
+ -multi all graphics in one file (implies -pdf)
+ -tight no 0.5bp margin around the graphic
+ -notex no typesetting, only graphic postprocessing
+ -nopic generate no graphics, only .cachepic file
+ -usage display usage message
+ -help,-h,-? display help message]]
+
+local msg = {
+ MultipleInputFiles = "cannot process multiple files:\t%s\t%s",
+ NoInputFile = "no input file given\n" .. tryhelp,
+ UnknownOption = "unknown option: %s\n" .. tryhelp,
+ FileOpenFailed = "could not open file: %s",
+ NoGhostScript = "could not locate ghostscript interpreter",
+ WrongOutputMode = "expected %s output but got %s",
+ NoPreviews = "no cachepic previews found",
+ MultiPicOnlyInPDF = "option '-multi' for all graphics in one file supported only in pdf mode"
+}
+
+function die(msgfmt, ...)
+ error(string.format(msgfmt, ...))
+end
+
+function warn(msgfmt, ...)
+ print('warning: ' .. string.format(msgfmt, ...))
+end
+
+local function qfile(filename)
+ filename = string.gsub(filename, '"', '')
+ if string.find(filename, "[%s%&%(%)%[%]%{%}%^%=%;%!%'%+%,%`%~]") then
+ filename = '"' .. filename .. '"'
+ end
+ return filename
+end
+
+local function syscall(command)
+ print('system: ' .. command)
+ local ret = os.execute(command)
+ if ret > 0 then os.exit(ret)
+ else return ret end
+end
+
+local function copyfile(src, dst)
+ print('copy ' .. qfile(src) .. ' ' .. qfile(dst))
+ local buffer, bufsize = '', 1024
+ local fin = io.open(src, 'rb')
+ if not fin then die(msg.FileOpenFailed, src) end
+ local fout = io.open(dst, 'wb')
+ if not fout then die(msg.FileOpenFailed, dst) end
+ while buffer do
+ fout:write(buffer)
+ buffer = fin:read(bufsize)
+ end
+ fin:close()
+ fout:close()
+end
+
+local isfile = lfs and lfs.isfile or function (fname)
+ -- if we are not running under texlua, then do it the hard way
+ local fh = io.open(fname)
+ return (fh and (fh:close() or true) or false)
+end
+
+local function whichfile(fname, path)
+ if isfile(fname) then return fname end
+ -- make the best guess if it is Windows or Unix
+ local dirsep, pathsep = '/', ':'
+ if (os.type == 'windows') or string.find(path, '\\') or string.find(path, ';') then
+ dirsep, pathsep = '\\', ';' -- Windows
+ end
+ -- iterate path
+ for dir in string.gmatch(path, '[^' .. pathsep .. ']+') do
+ local f = dir .. dirsep .. fname
+ -- print(f)
+ if isfile(f) then return f end
+ end
+ return nil
+end
+
+local function findgs()
+ local path = os.getenv('PATH')
+ for _, fname in ipairs{'gs', 'gswin32c.exe', 'mgs.exe'} do
+ if whichfile(fname, path) then return fname end
+ end
+ die(msg.NoGhostScript)
+end
+
+-- Process options --
+if #arg == 0 then
+ print(usagetext)
+ print(tryhelp)
+ os.exit(0)
+end
+local filename = nil
+for _, argn in ipairs(arg) do
+ local opt, num = string.gsub(argn, '^%-%-?', '')
+ if num == 0 then -- not an option
+ if filename then die(msg.MultipleInputFiles, filename, opt)
+ else filename = opt end
+ elseif opt == 'eps' then options.pdfoutput = false
+ elseif opt == 'pdf' then options.pdfoutput = true
+ elseif opt == 'all' then options.redoall = true
+ elseif opt == 'multi' then options.multipicfile = true
+ elseif opt == 'tight' then options.noborder = true
+ elseif opt == 'notex' then options.dotypesetting = false
+ elseif opt == 'nopic' then options.nopostprocess = true
+ elseif (opt == 'usage') or (opt == 'help') or (opt == 'h') or (opt == '?') then
+ print(usagetext)
+ if opt == 'usage' then os.exit(0) end
+ print(helptext)
+ os.exit(0)
+ else die(msg.UnknownOption, argn) end
+end
+if not filename then
+ die(msg.NoInputFile)
+end
+if options.multipicfile and not options.pdfoutput then
+ warn(msg.MultiPicOnlyInPDF)
+ options.multipicfile = false
+end
+filename = string.gsub(filename, '\\', '/')
+local noextname = string.gsub(filename, '%.[^./]*$', '')
+local jobname = string.match(noextname, '[^/]+$')
+local jobsuffix = (options.dotypesetting and '_cptmp' or '')
+local multipicfilename = noextname .. '-cachepic.pdf'
+
+-- Typeset document --
+if options.dotypesetting then
+ local engine = (options.pdfoutput and 'pdflatex' or 'latex')
+ local psfixbb = (options.pdfoutput and '' or ',psfixbb')
+ local noborder = (options.noborder and ' \\PreviewBorder=0pt' or '')
+ local redoall = (options.redoall and ' \\makeatletter\\def\\cachepic@tryincludepic#1#2{\\xdef\\cachepic@name{#1}#2}\\makeatother' or '')
+ local command = engine .. ' -interaction=nonstopmode -jobname=' .. jobname .. jobsuffix ..
+ ' \\def\\jobname{' .. jobname .. '}' ..
+ ' \\RequirePackage[active,tightpage,delayed,cachepic' .. psfixbb .. ']{preview}' ..
+ noborder .. redoall .. ' \\input{' .. qfile(filename) .. '}'
+ syscall(command)
+end
+
+-- Process log file --
+local iLines = io.lines(noextname .. jobsuffix .. '.log')
+local pics = {}
+local pdfmode = options.pdfoutput
+local trim = '0 0 0 0'
+for line in iLines do
+ local head, c1, c2, c3, c4, c5 = string.match(line,
+ '^Preview:%s*([A-Za-z]+)%s*(%-?%d*)%s*(%-?%d*)%s*(%-?%d*)%s*(%-?%d*)%s*(.*)')
+ if head == 'PDFoutput' then
+ pdfmode = (tonumber(c1) ~= 0)
+ elseif (head == 'Tightpage') and c1 and c2 and c3 and c4 then
+ trim = string.format('%dsp %dsp %dsp %dsp',
+ -tonumber(c1), -tonumber(c2), tonumber(c3), tonumber(c4))
+ elseif (head == 'CachePic') and c1 and c2 and c3 and c4 and c5 then
+ local picname = c5
+ local picpage = tonumber(c1)
+ local baseline = tonumber(c4) or 0
+ local texmacro = string.format('\\CachePicDefMacro{%s}{%d}{trim=%s}{%dsp}',
+ picname, picpage, trim, -baseline)
+ pics[#pics+1] = {name=picname, page=picpage, macro=texmacro}
+ end
+end
+if #pics == 0 then
+ warn(msg.NoPreviews)
+ return
+end
+if pdfmode ~= options.pdfoutput then
+ local expectedmode = options.pdfoutput and 'pdf' or 'dvi'
+ local actualmode = pdfmode and 'pdf' or 'dvi'
+ die(msg.WrongOutputMode, expectedmode, actualmode)
+end
+
+-- Write out cachepic macros --
+io.output(noextname .. '.cachepic')
+for i = 1, #pics do
+ io.write(pics[i].macro, '\n')
+end
+io.close()
+if options.nopostprocess then return end
+
+-- Postprocess pics --
+if options.multipicfile then
+ if options.pdfoutput then
+ -- without option -all the file size will slowly grow
+ -- extra run through GhostScript seems to prevent that
+ -- but it degrades raster graphics or makes them much larger
+ -- no perfect solution it seems
+ copyfile(noextname .. jobsuffix .. '.pdf', multipicfilename)
+ else die(msg.MultiPicOnlyInPDF) end -- this should never happen
+else
+ local ext, cmdtmpl
+ if options.pdfoutput then
+ ext = '.pdf'
+ filename = qfile(noextname .. jobsuffix .. '.pdf')
+ cmdtmpl = findgs() ..
+ ' -sDEVICE=pdfwrite -dQUIET -dBATCH -dNOPAUSE -dCompatibilityLevel=1.4' ..
+ ' -dFirstPage=%s -dLastPage=%s -sOutputFile=%s %s'
+ else
+ ext = '.eps'
+ filename = qfile(noextname .. jobsuffix .. '.dvi')
+ cmdtmpl = 'dvips -E -p %s -l %s -o %s %s'
+ end
+ for i = 1, #pics do
+ local outfile = string.gsub(pics[i].name, '"', '') .. ext
+ if not isfile(outfile) or options.redoall then
+ outfile = qfile(outfile)
+ syscall(string.format(cmdtmpl, pics[i].page, pics[i].page, outfile, filename))
+ end
+ end
+end
+--[[-- GS options preventing lossy image recompression
+ ' -dMonoImageFilter=/CCITTFaxEncode' ..
+ ' -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode' ..
+ ' -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode' ..
+]] \ No newline at end of file
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
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index bccd3872880..80f83229b30 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -45,7 +45,7 @@ my @WorkingTLP = qw(
boites boldtensors bookest booklet booktabs boolexpr bophook bosisio
boxhandler bpchem
bracketkey breakurl bullcntr bussproofs bytefield
- calctab calligra calrsfs captcont caption carlisle casyl
+ cachepic calctab calligra calrsfs captcont caption carlisle casyl
catechis carolmin-ps
cbcoptic cbfonts cc-pl ccaption cclicenses cd cdpbundl cell cellspace
changebar changelayout changepage changes chappg chapterfolder
diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds
index 63385b568fa..c1dea04a70d 100755
--- a/Master/tlpkg/libexec/ctan2tds
+++ b/Master/tlpkg/libexec/ctan2tds
@@ -113,6 +113,7 @@ chdir $startdir || die "chdir($startdir) failed: $!"; # back to raw
'bridge', "die 'skipping, latex 2.09'",
'burmese', "&MAKEflatten",
'c90', "&MAKEc90",
+ 'cachepic', "&MAKEcopy",
'calendar', "die 'skipping, nosell license'",
'camel', "die 'skipping, nosell license'",
'catalogue', "die 'skipping, goes stale too soon'",
diff --git a/Master/tlpkg/tlpsrc/cachepic.tlpsrc b/Master/tlpkg/tlpsrc/cachepic.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/cachepic.tlpsrc
diff --git a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc
index bdb3ae8b387..6ad39f16a6c 100644
--- a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc
@@ -3,6 +3,7 @@ shortdesc Graphics packages and programs
depend asyfig
depend autoarea
depend bardiag
+depend cachepic
depend circuitikz
depend curve
depend curve2e