summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-06-24 16:44:01 +0000
committerKarl Berry <karl@freefriends.org>2009-06-24 16:44:01 +0000
commitc68f9012130bdc604769e59229abefc28ac1cf04 (patch)
treed94971f342c4ea8f9cbdcf4486ec1673bde87a16 /Master/texmf-dist/tex/latex
parent4873be2e9722a5d9a95aa8edb9859d735853ab27 (diff)
new latex package asyfig (23jun09)
git-svn-id: svn://tug.org/texlive/trunk@13944 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/asyfig/asyalign.sty55
-rw-r--r--Master/texmf-dist/tex/latex/asyfig/asyfig.sty141
-rw-r--r--Master/texmf-dist/tex/latex/asyfig/asyprocess.sty59
3 files changed, 255 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/asyfig/asyalign.sty b/Master/texmf-dist/tex/latex/asyfig/asyalign.sty
new file mode 100644
index 00000000000..1bc05a30f7d
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/asyfig/asyalign.sty
@@ -0,0 +1,55 @@
+%% LaTeX2e file `asyalign.sty'
+%% generated by the `filecontents' environment
+%% from source `asyfig' on 2009/06/24.
+%%
+\ProvidesPackage{asyalign}
+
+% This package provides code for placing Asymptote labels inline in \LaTeX\ documents. It is adapted from code that is usually included within Aymptote's \<filename>|_.pre| file, which provides a \LaTeX\ preamble for |asy| processing; this preamble is skipped with the \pkg{asyfig} package since all figures inherit the preamble from that of the main document.
+
+\RequirePackage{ifpdf}
+
+\newbox\ASYbox
+\newdimen\ASYdimen
+
+\def\ASYbase#1#2{%
+ \setbox\ASYbox=\hbox{#1}%
+ \ASYdimen=\ht\ASYbox
+ \setbox\ASYbox=\hbox{#2}%
+ \lower\ASYdimen\box\ASYbox}
+
+\ifpdf
+ \def\ASYalign(#1,#2)(#3,#4)#5#6{%
+ \leavevmode
+ \setbox\ASYbox=\hbox{#6}%
+ \setbox\ASYbox\hbox{%
+ \kern#3\wd\ASYbox
+ \raise#4\dimexpr\ht\ASYbox+\dp\ASYbox\relax\box\ASYbox}%
+ \put(#1,#2){%
+ \special{pdf:q #5 0 0 cm}%
+ \wd\ASYbox\z@\dp\ASYbox\z@\ht\ASYbox\z@
+ \box\ASYbox
+ \special{pdf:Q}%
+ }}
+ \let\ASYraw\@firstofone
+
+\else
+ \def\ASYalign(#1,#2)(#3,#4)#5#6{%
+ \leavevmode
+ \setbox\ASYbox=\hbox{#6}%
+ \setbox\ASYbox\hbox{%
+ \kern#3\wd\ASYbox
+ \raise#4\dimexpr\ht\ASYbox+\dp\ASYbox\relax\box\ASYbox}%
+ \put(#1,#2){%
+ \special{%
+ ps:gsave currentpoint currentpoint translate
+ [#5 0 0] concat neg exch neg exch translate}%
+ \box\ASYbox
+ \special{ps:currentpoint grestore moveto}%
+ }}
+ \def\ASYraw#1{%
+ currentpoint currentpoint translate matrix currentmatrix
+ 100 12 div -100 12 div scale
+ #1
+ setmatrix neg exch neg exch translate}
+\fi
+
diff --git a/Master/texmf-dist/tex/latex/asyfig/asyfig.sty b/Master/texmf-dist/tex/latex/asyfig/asyfig.sty
new file mode 100644
index 00000000000..30b15b6d796
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/asyfig/asyfig.sty
@@ -0,0 +1,141 @@
+%% LaTeX2e file `asyfig.sty'
+%% generated by the `filecontents' environment
+%% from source `asyfig' on 2009/06/24.
+%%
+\ProvidesPackage{asyfig}[2009/06/23 v0.1a
+ Commands for using asymptote figures]
+
+% This package is the main user interface for inserting external |asy| figures
+% into the document.
+
+\RequirePackage{%
+ asyalign,color,ifmtarg,ifpdf,ifplatform,import,
+ graphicx,pdftexcmds,suffix,xkeyval}
+
+% Better conditionals than |\newif| provides:
+\def\@True{11}
+\def\@False{01}
+\def\asy@If#1{\if#1\relax\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
+
+\let\asy@always\@False
+\let\asy@never\@False
+\let\asy@process\@False
+
+% Package options:
+\define@choicekey*{asyfig.sty}{process}[\@tempa\@tempb]{all,none,auto}{%
+ \ifcase\@tempb\relax
+ \let\asy@always\@True
+ \or
+ \let\asy@never\@True
+ \or
+ \fi
+}
+\ExecuteOptions{process=auto}
+
+\ProcessOptionsX
+
+% \subsection{Auxiliary macros}
+
+\def\asy@splitpath#1/#2/{%
+% Recursive macro that is used like\\
+% \qquad |\asy@splitpath abc/def/ghi.asy/\@nil/|\\
+% It defines |\asy@filename| $\to$ |ghi.asy| and |\asy@path| $\to$ |abc/def/|
+ \ifx\@nil#2\relax
+% If input is \<anything>|/\@nil/| then we've reached the end:
+ \def\asy@filename{#1}%
+ \else
+% Otherwise we're in the middle of the slash-separated list;
+% build up |\asy@path|, and iterate:
+ \edef\asy@path{\asy@path#1/}%
+ \def\@tempa{\asy@splitpath#2/}%
+ \expandafter\@tempa
+ \fi
+}
+
+\newcommand\asypath[1]{\def\asy@pathprefix{#1}}
+\asypath{}
+
+\def\asy@asyfile{\asy@pathprefix\asy@path\asy@filename.asy}
+\def\asy@texfile{\asy@pathprefix\asy@path\asy@filename\string_.tex}
+
+\def\asy@cmdsep{\ifwindows \string& \else; \fi}
+
+% \subsection{The main macro}
+
+\newcommand\asyfig[1]{%
+ \let\asy@path\@empty
+ \asy@splitpath #1/\@nil/%
+ \IfFileExists{\asy@asyfile}{%
+ \asy@If\asy@process{}{%
+ \asy@If\asy@always{%
+ \let\asy@process\@True
+ }{%
+ \IfFileExists{\asy@texfile}{%
+ \asy@If\asy@never{}{%
+ % compare file dates to see if we want to reprocess:
+ \ifnum\pdf@strcmp{\pdf@filemoddate{\asy@texfile}}
+ {\pdf@filemoddate{\asy@asyfile}} < \z@
+ \let\asy@process\@True
+ \fi
+ }%
+ }{% if the .tex file doesn't exist, either
+ % give an error or process the .asy file:
+ \asy@If\asy@never{%
+ \PackageError{asyfig}{%
+ ^^J\space\space\space\space
+ "\asy@pathprefix\asy@path\asy@filename.asy" requires processing%
+ }{%
+ The generated file that is required to insert the asy graphic,
+ ^^J\space\space\space\space
+ "\asy@pathprefix\asy@path\asy@filename\string_.tex"^^J%
+ does not exist.
+ Please process the asy figure manually or de-activate the^^J%
+ [process=none] package option.
+ }%
+ }{%
+ \let\asy@process\@True
+ }
+ }%
+ }}%
+ \asy@If\asy@process{%
+ \edef\@tempa{\asy@pathprefix\asy@path}%
+ \pdf@system{%
+ echo "^^J====== ASY PROCESS =====^^J"
+ \asy@cmdsep
+ \ifx\@tempa\@empty\else
+ cd \@tempa
+ \asy@cmdsep
+ \fi
+ \ifpdf pdf\fi latex
+ -shell-escape
+ -interaction=batchmode
+ -jobname=\asy@filename-comp
+ \unexpanded{%
+ "\RequirePackage{asyprocess}\ProcessAsy
+ \documentclass{article}
+ \begin{document}\ShowAsy
+ \end{document}"
+ }%
+ \asy@cmdsep
+ echo "^^J==== ASY END PROCESS ===^^J"
+ }%
+ }{}%
+ \import{\asy@pathprefix\asy@path}{\asy@filename\string_.tex}%
+ }{%
+ \PackageWarning{asyfig}{%
+ ^^J\space\space
+ "\asy@pathprefix\asy@path\asy@filename.asy" not found.^^J%
+ This warning occurred%
+ }%
+ }%
+ \let\asy@process\@False
+}
+
+% The starred version of \cmd\asyfig\ processes the graphic always:
+\WithSuffix\newcommand\asyfig*[1]{%
+ \begingroup
+ \let\asy@process\@True
+ \csname\NoSuffixName\asyfig\endcsname{#1}%
+ \endgroup
+}
+
diff --git a/Master/texmf-dist/tex/latex/asyfig/asyprocess.sty b/Master/texmf-dist/tex/latex/asyfig/asyprocess.sty
new file mode 100644
index 00000000000..c665b37cba0
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/asyfig/asyprocess.sty
@@ -0,0 +1,59 @@
+%% LaTeX2e file `asyprocess.sty'
+%% generated by the `filecontents' environment
+%% from source `asyfig' on 2009/06/24.
+%%
+\ProvidesPackage{asyprocess}
+\nofiles
+
+\RequirePackage{ifmtarg,ifpdf,catchfile,ifplatform,color,graphicx}
+\RequirePackage[active,tightpage]{preview}
+
+\def\@par@macro{\par}
+
+\def\asy@status{asyprocess-statusfile.txt}
+
+\edef\@tempa{\detokenize{-comp}}
+\@temptokena{\def\asy@strip@comp#1}
+\expandafter\the\expandafter\@temptokena\@tempa#2\@nil{%
+ \@ifmtarg{#2}{%
+ \errorstopmode
+ \PackageError{asyprocess}{%
+ The \string\jobname\space of this compilation must end with `-comp'%
+ }{%
+ You must set the \cmd\jobname\ with the equivalent of^^J\space\space
+ pdflatex -jobname=XYZ-comp ...%
+ }
+ }{}%
+ \edef\asy@compname{#1}}
+\expandafter\expandafter\expandafter
+ \asy@strip@comp\expandafter\jobname\@tempa\@nil
+
+\newcommand\ProcessAsy{%
+ \immediate\write18{%
+ asy -wait -inlinetex -tex \ifpdf pdf\fi latex
+ \asy@compname\space 2> \asy@status}%
+ \CatchFileDef{\@tempb}{\asy@status}{}%
+ \immediate\write18{\ifwindows del \else rm \fi \asy@status}
+ \ifx\@tempb\@par@macro
+ \expandafter\@gobble
+ \else
+ \g@addto@macro\@tempb{^^J^^J%
+ ------------ ASY ERROR ------------^^J%
+ -----------------------------------}%
+ \expandafter\@firstofone
+ \fi{%
+ \errorstopmode
+ \typeout{%
+ -----------------------------------^^J%
+ ------------ ASY ERROR ------------^^J}
+ \typeout{\expandafter\strip@prefix\meaning\@tempb}
+ \batchmode
+ \end{document}}}
+
+\newcommand\ShowAsy{%
+ \begin{preview}
+ \input{\asy@compname_}
+ \end{preview}}
+
+\AtBeginDocument{\InputIfFileExists{\asy@compname_.pre}{}{}}
+